260 (
errmsg(
"inconsistent background worker state (\"max_worker_processes\"=%d, total slots=%d)",
312 if (!allow_new_workers)
354 (
errcode(ERRCODE_OUT_OF_MEMORY),
355 errmsg(
"out of memory")));
398 elog(
DEBUG1,
"worker notification PID %d is not valid",
644 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
645 errmsg(
"background worker \"%s\": background workers without shared memory access are not supported",
655 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
656 errmsg(
"background worker \"%s\": cannot request database access if starting at postmaster start",
669 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
670 errmsg(
"background worker \"%s\": invalid restart interval",
684 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
685 errmsg(
"background worker \"%s\": parallel workers may not be configured for restart",
693 if (strcmp(worker->
bgw_type,
"") == 0)
705 sigprocmask(SIG_SETMASK, &
BlockSig, NULL);
708 (
errcode(ERRCODE_ADMIN_SHUTDOWN),
709 errmsg(
"terminating background worker \"%s\" due to administrator command",
719 sigjmp_buf local_sigjmp_buf;
723 if (startup_data == NULL)
724 elog(
FATAL,
"unable to find bgworker entry");
784 if (sigsetjmp(local_sigjmp_buf, 1) != 0)
867 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
868 errmsg(
"database connection requirement not indicated during registration")));
878 (
errmsg(
"invalid processing mode in background worker")));
901 (
errcode(ERRCODE_PROGRAM_LIMIT_EXCEEDED),
902 errmsg(
"database connection requirement not indicated during registration")));
912 (
errmsg(
"invalid processing mode in background worker")));
922 sigprocmask(SIG_SETMASK, &
BlockSig, NULL);
942 static int numworkers = 0;
964 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
965 errmsg(
"background worker \"%s\": must be registered in \"shared_preload_libraries\"",
975 elog(
ERROR,
"cannot register background worker \"%s\" after shmem init",
987 (
errcode(ERRCODE_FEATURE_NOT_SUPPORTED),
988 errmsg(
"background worker \"%s\": only dynamic background workers can request notification",
1002 (
errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
1003 errmsg(
"too many background workers"),
1004 errdetail_plural(
"Up to %d background worker can be registered with the current settings.",
1005 "Up to %d background workers can be registered with the current settings.",
1008 errhint(
"Consider increasing the configuration parameter \"%s\".",
"max_worker_processes")));
1021 (
errcode(ERRCODE_OUT_OF_MEMORY),
1022 errmsg(
"out of memory")));
1132 (*handle)->slot = slotno;
1133 (*handle)->generation = generation;
1231 WAIT_EVENT_BGWORKER_STARTUP);
1274 WAIT_EVENT_BGWORKER_SHUTDOWN);
1299 bool signal_postmaster =
false;
1309 signal_postmaster =
true;
1314 if (signal_postmaster)
1343 if (strcmp(libraryname,
"postgres") == 0)
1383 if (slot->
pid > 0 && slot->
pid == pid)
void ParallelApplyWorkerMain(Datum main_arg)
void ascii_safe_strlcpy(char *dest, const char *src, size_t destsiz)
#define pg_memory_barrier()
#define pg_read_barrier()
#define pg_write_barrier()
void ParallelWorkerMain(Datum main_arg)
void ApplyWorkerMain(Datum main_arg)
void RegisterBackgroundWorker(BackgroundWorker *worker)
static RegisteredBgWorker * FindRegisteredWorkerBySlotNumber(int slotno)
BgwHandleStatus WaitForBackgroundWorkerStartup(BackgroundWorkerHandle *handle, pid_t *pidp)
void BackgroundWorkerInitializeConnection(const char *dbname, const char *username, uint32 flags)
static bool SanityCheckBackgroundWorker(BackgroundWorker *worker, int elevel)
void ReportBackgroundWorkerPID(RegisteredBgWorker *rw)
void TerminateBackgroundWorker(BackgroundWorkerHandle *handle)
static const struct @18 InternalBGWorkers[]
void ReportBackgroundWorkerExit(RegisteredBgWorker *rw)
BgwHandleStatus WaitForBackgroundWorkerShutdown(BackgroundWorkerHandle *handle)
void ResetBackgroundWorkerCrashTimes(void)
void BackgroundWorkerShmemInit(void)
void BackgroundWorkerUnblockSignals(void)
struct BackgroundWorkerSlot BackgroundWorkerSlot
void BackgroundWorkerInitializeConnectionByOid(Oid dboid, Oid useroid, uint32 flags)
void BackgroundWorkerBlockSignals(void)
const char * GetBackgroundWorkerTypeByPid(pid_t pid)
dlist_head BackgroundWorkerList
void ForgetBackgroundWorker(RegisteredBgWorker *rw)
BgwHandleStatus GetBackgroundWorkerPid(BackgroundWorkerHandle *handle, pid_t *pidp)
static BackgroundWorkerArray * BackgroundWorkerData
static bgworker_main_type LookupBackgroundWorkerFunction(const char *libraryname, const char *funcname)
static void bgworker_die(SIGNAL_ARGS)
void BackgroundWorkerStopNotifications(pid_t pid)
Size BackgroundWorkerShmemSize(void)
void BackgroundWorkerStateChange(bool allow_new_workers)
void BackgroundWorkerMain(char *startup_data, size_t startup_data_len)
bool RegisterDynamicBackgroundWorker(BackgroundWorker *worker, BackgroundWorkerHandle **handle)
bgworker_main_type fn_addr
void ForgetUnstartedBackgroundWorkers(void)
struct BackgroundWorkerArray BackgroundWorkerArray
#define BGW_NEVER_RESTART
#define BGWORKER_BYPASS_ROLELOGINCHECK
#define BGWORKER_CLASS_PARALLEL
@ BgWorkerStart_PostmasterStart
#define BGWORKER_BACKEND_DATABASE_CONNECTION
#define BGWORKER_BYPASS_ALLOWCONN
#define BGWORKER_SHMEM_ACCESS
void(* bgworker_main_type)(Datum main_arg)
#define MAX_PARALLEL_WORKER_LIMIT
#define Assert(condition)
#define FLEXIBLE_ARRAY_MEMBER
void * load_external_function(const char *filename, const char *funcname, bool signalNotFound, void **filehandle)
int errmsg_internal(const char *fmt,...)
void EmitErrorReport(void)
ErrorContextCallback * error_context_stack
int errdetail_plural(const char *fmt_singular, const char *fmt_plural, unsigned long n,...)
int errhint(const char *fmt,...)
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
sigjmp_buf * PG_exception_stack
#define ereport(elevel,...)
#define MCXT_ALLOC_NO_OOM
bool IsPostmasterEnvironment
#define dlist_foreach(iter, lhead)
static void dlist_delete(dlist_node *node)
static void dlist_push_head(dlist_head *head, dlist_node *node)
#define dlist_foreach_modify(iter, lhead)
#define DLIST_STATIC_INIT(name)
#define dlist_container(type, membername, ptr)
void ResetLatch(Latch *latch)
int WaitLatch(Latch *latch, int wakeEvents, long timeout, uint32 wait_event_info)
#define WL_POSTMASTER_DEATH
void ApplyLauncherMain(Datum main_arg)
bool LWLockAcquire(LWLock *lock, LWLockMode mode)
void LWLockRelease(LWLock *lock)
void pfree(void *pointer)
MemoryContext TopMemoryContext
void * MemoryContextAllocExtended(MemoryContext context, Size size, int flags)
void * MemoryContextAlloc(MemoryContext context, Size size)
MemoryContext PostmasterContext
void MemoryContextDelete(MemoryContext context)
#define GetProcessingMode()
#define CHECK_FOR_INTERRUPTS()
#define HOLD_INTERRUPTS()
#define IsInitProcessingMode()
#define SetProcessingMode(mode)
#define INIT_PG_OVERRIDE_ROLE_LOGIN
#define INIT_PG_OVERRIDE_ALLOW_CONNS
BackendType MyBackendType
bool process_shared_preload_libraries_in_progress
void SendPostmasterSignal(PMSignalReason reason)
@ PMSIGNAL_BACKGROUND_WORKER_CHANGE
pqsigfunc pqsignal(int signo, pqsigfunc func)
void FloatExceptionHandler(SIGNAL_ARGS)
void StatementCancelHandler(SIGNAL_ARGS)
void InitPostgres(const char *in_dbname, Oid dboid, const char *username, Oid useroid, bits32 flags, char *out_dbname)
BackgroundWorker * MyBgworkerEntry
bool PostmasterMarkPIDForWorkerNotify(int pid)
void procsignal_sigusr1_handler(SIGNAL_ARGS)
void init_ps_display(const char *fixed_part)
Size add_size(Size s1, Size s2)
void * ShmemInitStruct(const char *name, Size size, bool *foundPtr)
Size mul_size(Size s1, Size s2)
void pg_usleep(long microsec)
static pg_noinline void Size size
uint32 parallel_terminate_count
uint32 parallel_register_count
BackgroundWorkerSlot slot[FLEXIBLE_ARRAY_MEMBER]
char bgw_function_name[BGW_MAXLEN]
char bgw_name[BGW_MAXLEN]
char bgw_type[BGW_MAXLEN]
BgWorkerStartTime bgw_start_time
char bgw_extra[BGW_EXTRALEN]
char bgw_library_name[MAXPGPATH]
TimestampTz rw_crashed_at
BackgroundWorker rw_worker
void TablesyncWorkerMain(Datum main_arg)
void InitializeTimeouts(void)