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 0x0001 |
#define | BGWORKER_BYPASS_ROLELOGINCHECK 0x0002 |
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 0x0001 |
Definition at line 156 of file bgworker.h.
#define BGWORKER_BYPASS_ROLELOGINCHECK 0x0002 |
Definition at line 157 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 852 of file bgworker.c.
References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_BYPASS_ALLOWCONN, BGWORKER_BYPASS_ROLELOGINCHECK, dbname, ereport, errcode(), errmsg(), ERROR, FATAL, INIT_PG_OVERRIDE_ALLOW_CONNS, INIT_PG_OVERRIDE_ROLE_LOGIN, InitPostgres(), InvalidOid, IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, SetProcessingMode, and username.
Referenced by ApplyLauncherMain(), and worker_spi_main().
Definition at line 886 of file bgworker.c.
References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_BYPASS_ALLOWCONN, BGWORKER_BYPASS_ROLELOGINCHECK, ereport, errcode(), errmsg(), ERROR, FATAL, INIT_PG_OVERRIDE_ALLOW_CONNS, INIT_PG_OVERRIDE_ROLE_LOGIN, InitPostgres(), IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, and SetProcessingMode.
Referenced by autoprewarm_database_main(), InitializeLogRepWorker(), ParallelWorkerMain(), and worker_spi_main().
void BackgroundWorkerUnblockSignals | ( | void | ) |
Definition at line 926 of file bgworker.c.
References UnBlockSig.
Referenced by ApplyLauncherMain(), autoprewarm_database_main(), autoprewarm_main(), BackgroundWorkerMain(), ParallelApplyWorkerMain(), ParallelWorkerMain(), SetupApplyOrSyncWorker(), test_shm_mq_main(), and worker_spi_main().
BgwHandleStatus GetBackgroundWorkerPid | ( | BackgroundWorkerHandle * | handle, |
pid_t * | pidp | ||
) |
Definition at line 1157 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 1371 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 939 of file bgworker.c.
References BackgroundWorkerData, BackgroundWorkerList, BackgroundWorker::bgw_name, BackgroundWorker::bgw_notify_pid, DEBUG1, dlist_push_head(), elog, ereport, errcode(), errdetail_plural(), errhint(), errmsg(), errmsg_internal(), ERROR, IsPostmasterEnvironment, IsUnderPostmaster, LOG, max_worker_processes, MCXT_ALLOC_NO_OOM, MemoryContextAllocExtended(), PostmasterContext, process_shared_preload_libraries_in_progress, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_lnode, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, and SanityCheckBackgroundWorker().
Referenced by _PG_init(), ApplyLauncherRegister(), and apw_start_leader_worker().
bool RegisterDynamicBackgroundWorker | ( | BackgroundWorker * | worker, |
BackgroundWorkerHandle ** | handle | ||
) |
Definition at line 1045 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 1296 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 1257 of file bgworker.c.
References BGWH_POSTMASTER_DIED, BGWH_STOPPED, CHECK_FOR_INTERRUPTS, GetBackgroundWorkerPid(), MyLatch, ResetLatch(), 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 1212 of file bgworker.c.
References BGWH_NOT_YET_STARTED, BGWH_POSTMASTER_DIED, BGWH_STARTED, CHECK_FOR_INTERRUPTS, GetBackgroundWorkerPid(), MyLatch, ResetLatch(), WaitLatch(), WL_LATCH_SET, and WL_POSTMASTER_DEATH.
Referenced by apw_start_leader_worker(), and worker_spi_launch().
|
extern |
Definition at line 192 of file postmaster.c.
Referenced by BackgroundWorkerInitializeConnection(), BackgroundWorkerInitializeConnectionByOid(), BackgroundWorkerMain(), bgworker_die(), get_backend_type_for_log(), ParallelApplyWorkerMain(), ParallelWorkerMain(), ProcessInterrupts(), test_shm_mq_main(), and worker_spi_main().