PostgreSQL Source Code
git master
|
Go to the source code of this file.
Data Structures | |
struct | BackgroundWorker |
Macros | |
#define | BGWORKER_SHMEM_ACCESS 0x0001 |
#define | BGWORKER_BACKEND_DATABASE_CONNECTION 0x0002 |
#define | BGWORKER_CLASS_PARALLEL 0x0010 |
#define | BGW_DEFAULT_RESTART_INTERVAL 60 |
#define | BGW_NEVER_RESTART -1 |
#define | BGW_MAXLEN 96 |
#define | BGW_EXTRALEN 128 |
#define | BGWORKER_BYPASS_ALLOWCONN 1 |
Typedefs | |
typedef void(* | bgworker_main_type) (Datum main_arg) |
typedef struct BackgroundWorker | BackgroundWorker |
typedef enum BgwHandleStatus | BgwHandleStatus |
typedef struct BackgroundWorkerHandle | BackgroundWorkerHandle |
Enumerations | |
enum | BgWorkerStartTime { BgWorkerStart_PostmasterStart , BgWorkerStart_ConsistentState , BgWorkerStart_RecoveryFinished } |
enum | BgwHandleStatus { BGWH_STARTED , BGWH_NOT_YET_STARTED , BGWH_STOPPED , BGWH_POSTMASTER_DIED } |
Functions | |
void | RegisterBackgroundWorker (BackgroundWorker *worker) |
bool | RegisterDynamicBackgroundWorker (BackgroundWorker *worker, BackgroundWorkerHandle **handle) |
BgwHandleStatus | GetBackgroundWorkerPid (BackgroundWorkerHandle *handle, pid_t *pidp) |
BgwHandleStatus | WaitForBackgroundWorkerStartup (BackgroundWorkerHandle *handle, pid_t *pidp) |
BgwHandleStatus | WaitForBackgroundWorkerShutdown (BackgroundWorkerHandle *) |
const char * | GetBackgroundWorkerTypeByPid (pid_t pid) |
void | TerminateBackgroundWorker (BackgroundWorkerHandle *handle) |
void | BackgroundWorkerInitializeConnection (const char *dbname, const char *username, uint32 flags) |
void | BackgroundWorkerInitializeConnectionByOid (Oid dboid, Oid useroid, uint32 flags) |
void | BackgroundWorkerBlockSignals (void) |
void | BackgroundWorkerUnblockSignals (void) |
Variables | |
PGDLLIMPORT BackgroundWorker * | MyBgworkerEntry |
#define BGW_DEFAULT_RESTART_INTERVAL 60 |
Definition at line 84 of file bgworker.h.
#define BGW_EXTRALEN 128 |
Definition at line 87 of file bgworker.h.
#define BGW_MAXLEN 96 |
Definition at line 86 of file bgworker.h.
#define BGW_NEVER_RESTART -1 |
Definition at line 85 of file bgworker.h.
#define BGWORKER_BACKEND_DATABASE_CONNECTION 0x0002 |
Definition at line 60 of file bgworker.h.
#define BGWORKER_BYPASS_ALLOWCONN 1 |
Definition at line 155 of file bgworker.h.
#define BGWORKER_CLASS_PARALLEL 0x0010 |
Definition at line 68 of file bgworker.h.
#define BGWORKER_SHMEM_ACCESS 0x0001 |
Definition at line 53 of file bgworker.h.
typedef struct BackgroundWorker BackgroundWorker |
typedef struct BackgroundWorkerHandle BackgroundWorkerHandle |
Definition at line 72 of file bgworker.h.
typedef enum BgwHandleStatus BgwHandleStatus |
typedef void(* bgworker_main_type) (Datum main_arg) |
Definition at line 72 of file bgworker.h.
enum BgwHandleStatus |
Enumerator | |
---|---|
BGWH_STARTED | |
BGWH_NOT_YET_STARTED | |
BGWH_STOPPED | |
BGWH_POSTMASTER_DIED |
Definition at line 103 of file bgworker.h.
enum BgWorkerStartTime |
Enumerator | |
---|---|
BgWorkerStart_PostmasterStart | |
BgWorkerStart_ConsistentState | |
BgWorkerStart_RecoveryFinished |
Definition at line 77 of file bgworker.h.
void BackgroundWorkerBlockSignals | ( | void | ) |
void BackgroundWorkerInitializeConnection | ( | const char * | dbname, |
const char * | username, | ||
uint32 | flags | ||
) |
Definition at line 5600 of file postmaster.c.
References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_BYPASS_ALLOWCONN, dbname, ereport, errcode(), errmsg(), ERROR, FATAL, InitPostgres(), InvalidOid, IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, SetProcessingMode, and username.
Referenced by ApplyLauncherMain(), and worker_spi_main().
Definition at line 5627 of file postmaster.c.
References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_BYPASS_ALLOWCONN, ereport, errcode(), errmsg(), ERROR, FATAL, InitPostgres(), IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, and SetProcessingMode.
Referenced by autoprewarm_database_main(), InitializeApplyWorker(), and ParallelWorkerMain().
void BackgroundWorkerUnblockSignals | ( | void | ) |
Definition at line 5660 of file postmaster.c.
References UnBlockSig.
Referenced by ApplyLauncherMain(), ApplyWorkerMain(), autoprewarm_database_main(), autoprewarm_main(), ParallelApplyWorkerMain(), ParallelWorkerMain(), StartBackgroundWorker(), test_shm_mq_main(), and worker_spi_main().
BgwHandleStatus GetBackgroundWorkerPid | ( | BackgroundWorkerHandle * | handle, |
pid_t * | pidp | ||
) |
Definition at line 1071 of file bgworker.c.
References Assert(), BackgroundWorkerData, BGWH_NOT_YET_STARTED, BGWH_STARTED, BGWH_STOPPED, BackgroundWorkerSlot::generation, BackgroundWorkerHandle::generation, BackgroundWorkerSlot::in_use, InvalidPid, LW_SHARED, LWLockAcquire(), LWLockRelease(), max_worker_processes, BackgroundWorkerSlot::pid, BackgroundWorkerArray::slot, and BackgroundWorkerHandle::slot.
Referenced by check_worker_status(), shm_mq_counterparty_gone(), shm_mq_wait_internal(), WaitForBackgroundWorkerShutdown(), WaitForBackgroundWorkerStartup(), WaitForParallelWorkersToAttach(), WaitForParallelWorkersToFinish(), and WaitForReplicationWorkerAttach().
const char* GetBackgroundWorkerTypeByPid | ( | pid_t | pid | ) |
Definition at line 1285 of file bgworker.c.
References BackgroundWorkerData, BGW_MAXLEN, BackgroundWorker::bgw_type, LW_SHARED, LWLockAcquire(), LWLockRelease(), BackgroundWorkerSlot::pid, BackgroundWorkerArray::slot, BackgroundWorkerArray::total_slots, and BackgroundWorkerSlot::worker.
Referenced by pg_stat_get_activity().
void RegisterBackgroundWorker | ( | BackgroundWorker * | worker | ) |
Definition at line 875 of file bgworker.c.
References BackgroundWorkerList, BackgroundWorker::bgw_library_name, BackgroundWorker::bgw_name, BackgroundWorker::bgw_notify_pid, DEBUG1, ereport, errcode(), errdetail_plural(), errhint(), errmsg(), errmsg_internal(), IsUnderPostmaster, LOG, malloc, max_worker_processes, process_shared_preload_libraries_in_progress, RegisteredBgWorker::rw_backend, RegisteredBgWorker::rw_child_slot, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_lnode, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, SanityCheckBackgroundWorker(), and slist_push_head().
Referenced by _PG_init(), ApplyLauncherRegister(), and apw_start_leader_worker().
bool RegisterDynamicBackgroundWorker | ( | BackgroundWorker * | worker, |
BackgroundWorkerHandle ** | handle | ||
) |
Definition at line 959 of file bgworker.c.
References Assert(), BackgroundWorkerData, BackgroundWorker::bgw_flags, BGWORKER_CLASS_PARALLEL, ERROR, BackgroundWorkerSlot::generation, BackgroundWorkerSlot::in_use, InvalidPid, IsUnderPostmaster, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), MAX_PARALLEL_WORKER_LIMIT, max_parallel_workers, palloc(), BackgroundWorkerArray::parallel_register_count, BackgroundWorkerArray::parallel_terminate_count, pg_write_barrier, BackgroundWorkerSlot::pid, PMSIGNAL_BACKGROUND_WORKER_CHANGE, SanityCheckBackgroundWorker(), SendPostmasterSignal(), BackgroundWorkerArray::slot, success, BackgroundWorkerSlot::terminate, BackgroundWorkerArray::total_slots, and BackgroundWorkerSlot::worker.
Referenced by apw_start_database_worker(), apw_start_leader_worker(), LaunchParallelWorkers(), logicalrep_worker_launch(), setup_background_workers(), and worker_spi_launch().
void TerminateBackgroundWorker | ( | BackgroundWorkerHandle * | handle | ) |
Definition at line 1210 of file bgworker.c.
References Assert(), BackgroundWorkerData, BackgroundWorkerSlot::generation, BackgroundWorkerHandle::generation, LW_EXCLUSIVE, LWLockAcquire(), LWLockRelease(), max_worker_processes, PMSIGNAL_BACKGROUND_WORKER_CHANGE, SendPostmasterSignal(), BackgroundWorkerArray::slot, BackgroundWorkerHandle::slot, and BackgroundWorkerSlot::terminate.
Referenced by cleanup_background_workers(), and DestroyParallelContext().
BgwHandleStatus WaitForBackgroundWorkerShutdown | ( | BackgroundWorkerHandle * | handle | ) |
Definition at line 1171 of file bgworker.c.
References BGWH_POSTMASTER_DIED, BGWH_STOPPED, CHECK_FOR_INTERRUPTS, GetBackgroundWorkerPid(), MyLatch, ResetLatch(), WAIT_EVENT_BGWORKER_SHUTDOWN, WaitLatch(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.
Referenced by apw_start_database_worker(), and WaitForParallelWorkersToExit().
BgwHandleStatus WaitForBackgroundWorkerStartup | ( | BackgroundWorkerHandle * | handle, |
pid_t * | pidp | ||
) |
Definition at line 1126 of file bgworker.c.
References BGWH_NOT_YET_STARTED, BGWH_POSTMASTER_DIED, BGWH_STARTED, CHECK_FOR_INTERRUPTS, GetBackgroundWorkerPid(), MyLatch, ResetLatch(), WAIT_EVENT_BGWORKER_STARTUP, WaitLatch(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.
Referenced by apw_start_leader_worker(), and worker_spi_launch().
|
extern |
Definition at line 193 of file postmaster.c.
Referenced by BackgroundWorkerInitializeConnection(), BackgroundWorkerInitializeConnectionByOid(), bgworker_die(), do_start_bgworker(), get_backend_type_for_log(), ParallelApplyWorkerMain(), ParallelWorkerMain(), ProcessInterrupts(), StartBackgroundWorker(), test_shm_mq_main(), and worker_spi_main().