85#include <systemd/sd-daemon.h>
88#ifdef HAVE_PTHREAD_IS_THREADED_NP
159 for (
int i = 0;
i < nargs;
i++)
160 mask.
mask |= 1 << t[
i];
164#define btmask_add(mask, ...) \
166 lengthof(((BackendType[]){__VA_ARGS__})), \
167 (BackendType[]){__VA_ARGS__} \
173 mask.
mask &= ~(1 << t);
182 for (
int i = 0;
i < nargs;
i++)
187#define btmask_all_except(...) \
188 btmask_all_except_n( \
189 lengthof(((BackendType[]){__VA_ARGS__})), \
190 (BackendType[]){__VA_ARGS__} \
196 return (mask.
mask & (1 << t)) != 0;
284#define SmartShutdown 1
285#define FastShutdown 2
286#define ImmediateShutdown 3
368#define SIGKILL_CHILDREN_AFTER_SECS 5
407static DNSServiceRef bonjour_sdref = NULL;
433 int pid,
int exitstatus);
450static bool CreateOptsFile(
int argc,
char *argv[],
char *fullprogname);
460static pid_t waitpid(pid_t pid,
int *exitstatus,
int options);
461static void WINAPI pgwin32_deadchild_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired);
463static HANDLE win32ChildQueue;
470} win32_deadchild_waitinfo;
474#define EXIT_STATUS_0(st) ((st) == 0)
475#define EXIT_STATUS_1(st) (WIFEXITED(st) && WEXITSTATUS(st) == 1)
476#define EXIT_STATUS_3(st) (WIFEXITED(st) && WEXITSTATUS(st) == 3)
486HANDLE PostmasterHandle;
498 bool listen_addr_saved =
false;
499 char *output_config_variable = NULL;
548 sigprocmask(SIG_SETMASK, &
BlockSig, NULL);
598 while ((opt =
getopt(argc, argv,
"B:bC:c:D:d:EeFf:h:ijk:lN:OPp:r:S:sTt:W:-:")) != -1)
612 output_config_variable = strdup(
optarg);
625 (
errcode(ERRCODE_SYNTAX_ERROR),
639 (
errcode(ERRCODE_SYNTAX_ERROR),
640 errmsg(
"--%s requires a value",
644 (
errcode(ERRCODE_SYNTAX_ERROR),
645 errmsg(
"-c %s requires a value",
678 write_stderr(
"%s: invalid argument for option -f: \"%s\"\n",
751 write_stderr(
"%s: invalid argument for option -t: \"%s\"\n",
763 write_stderr(
"Try \"%s --help\" for more information.\n",
776 write_stderr(
"Try \"%s --help\" for more information.\n",
788 if (output_config_variable != NULL)
813 puts(config_val ? config_val :
"");
842 write_stderr(
"%s: \"superuser_reserved_connections\" (%d) plus \"reserved_connections\" (%d) must be less than \"max_connections\" (%d)\n",
850 (
errmsg(
"WAL archival cannot be enabled when \"wal_level\" is \"minimal\"")));
853 (
errmsg(
"WAL streaming (\"max_wal_senders\" > 0) requires \"wal_level\" to be \"replica\" or \"logical\"")));
856 (
errmsg(
"WAL cannot be summarized when \"wal_level\" is \"minimal\"")));
859 (
errmsg(
"replication slot synchronization (\"sync_replication_slots\" = on) requires \"wal_level\" >= \"logical\"")));
876#ifdef HAVE_INT_OPTRESET
990 if (output_config_variable != NULL)
995 puts(config_val ? config_val :
"");
1025 win32ChildQueue = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
1026 if (win32ChildQueue == NULL)
1028 (
errmsg(
"could not create I/O completion port for child queue")));
1072 errmsg(
"could not remove file \"%s\": %m",
1094 (
errmsg(
"ending log output to stderr"),
1095 errhint(
"Future log output will go to log destination \"%s\".",
1106 (
errmsg(
"starting %s", PG_VERSION_STR)));
1132 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1133 errmsg(
"invalid list syntax in parameter \"%s\"",
1134 "listen_addresses")));
1137 foreach(l, elemlist)
1139 char *curhost = (
char *)
lfirst(l);
1141 if (strcmp(curhost,
"*") == 0)
1160 if (!listen_addr_saved)
1163 listen_addr_saved =
true;
1168 (
errmsg(
"could not create listen socket for \"%s\"",
1174 (
errmsg(
"could not create any TCP/IP sockets")));
1184 DNSServiceErrorType
err;
1192 err = DNSServiceRegister(&bonjour_sdref,
1196 "_postgresql._tcp.",
1204 if (
err != kDNSServiceErr_NoError)
1206 (
errmsg(
"DNSServiceRegister() failed: error code %ld",
1234 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1235 errmsg(
"invalid list syntax in parameter \"%s\"",
1236 "unix_socket_directories")));
1239 foreach(l, elemlist)
1241 char *socketdir = (
char *)
lfirst(l);
1259 (
errmsg(
"could not create Unix-domain socket in directory \"%s\"",
1265 (
errmsg(
"could not create any Unix-domain sockets")));
1276 (
errmsg(
"no socket created for listening")));
1283 if (!listen_addr_saved)
1307 write_stderr(
"%s: could not change permissions of external PID file \"%s\": %m\n",
1311 write_stderr(
"%s: could not write external PID file \"%s\": %m\n",
1351#ifdef HAVE_PTHREAD_IS_THREADED_NP
1364 if (pthread_is_threaded_np() != 0)
1366 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1367 errmsg(
"postmaster became multithreaded during startup"),
1368 errhint(
"Set the LC_ALL environment variable to a valid locale.")));
1431 elog(
LOG,
"could not close listen socket: %m");
1471 (
errmsg(
"%s: could not locate my own executable path",
argv0)));
1476 postgres_exec_path) < 0)
1478 (
errmsg(
"%s: could not locate matching postgres executable",
1499 errmsg(
"could not open directory \"%s\": %m",
1501 errhint(
"This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
1528 write_stderr(
"%s: could not find the database system\n"
1529 "Expected to find it in the directory \"%s\",\n"
1530 "but could not open file \"%s\": %m\n",
1560 time_t curtime = time(NULL);
1574 return seconds * 1000;
1612 if (next_wakeup == 0 || this_wakeup < next_wakeup)
1613 next_wakeup = this_wakeup;
1617 if (next_wakeup != 0)
1624 return Min(60 * 1000, ms);
1651 if (accept_connections)
1665 time_t last_lockfile_recheck_time,
1671 last_lockfile_recheck_time = last_touch_time = time(NULL);
1687 for (
int i = 0;
i < nevents;
i++)
1719 elog(
LOG,
"could not close client socket: %m");
1738#ifdef HAVE_PTHREAD_IS_THREADED_NP
1744 Assert(pthread_is_threaded_np() == 0);
1773 (
errmsg(
"issuing %s to recalcitrant children",
1795 (
errmsg(
"performing immediate shutdown because data directory lock file is invalid")));
1798 last_lockfile_recheck_time =
now;
1810 last_touch_time =
now;
1885 errmsg_internal(
"could not close postmaster death monitoring pipe in child process: %m")));
1904 elog(
LOG,
"could not close listen socket: %m");
1932 close(DNSServiceRefSockFD(bonjour_sdref));
2015 (
errmsg(
"received SIGHUP, reloading configuration files")));
2037 (
errmsg(
"SSL configuration was not reloaded")));
2060 switch (postgres_signal_arg)
2123 (
errmsg(
"received smart shutdown request")));
2128 sd_notify(0,
"STOPPING=1");
2164 (
errmsg(
"received fast shutdown request")));
2169 sd_notify(0,
"STOPPING=1");
2182 (
errmsg(
"aborting any active transactions")));
2206 (
errmsg(
"received immediate shutdown request")));
2211 sd_notify(0,
"STOPPING=1");
2253 while ((pid = waitpid(-1, &exitstatus, WNOHANG)) > 0)
2281 (
errmsg(
"shutdown at recovery target")));
2302 (
errmsg(
"aborting startup due to startup process failure")));
2335 _(
"startup process"));
2358 (
errmsg(
"database system is ready to accept connections")));
2363 sd_notify(0,
"READY=1");
2380 _(
"background writer process"));
2413 _(
"checkpointer process"));
2430 _(
"WAL writer process"));
2446 _(
"WAL receiver process"));
2461 _(
"WAL summarizer process"));
2477 _(
"autovacuum launcher process"));
2493 _(
"archiver process"));
2526 _(
"slot sync worker process"));
2580 const char *procname;
2581 bool crashed =
false;
2582 bool logged =
false;
2584 bool bp_bgworker_notify;
2616 if (exitstatus == ERROR_WAIT_NO_CHILDREN)
2664 if (bp_bgworker_notify)
2691 procname, bp_pid, exitstatus);
2815 (
errmsg(
"terminating any other active server processes")));
2834 char activity_buffer[1024];
2835 const char *activity = NULL;
2840 sizeof(activity_buffer));
2848 (
errmsg(
"%s (PID %d) exited with exit code %d",
2850 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2859 (
errmsg(
"%s (PID %d) was terminated by exception 0x%X",
2860 procname, pid,
WTERMSIG(exitstatus)),
2861 errhint(
"See C include file \"ntstatus.h\" for a description of the hexadecimal value."),
2862 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2869 (
errmsg(
"%s (PID %d) was terminated by signal %d: %s",
2870 procname, pid,
WTERMSIG(exitstatus),
2872 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2881 (
errmsg(
"%s (PID %d) exited with unrecognized status %d",
2882 procname, pid, exitstatus),
2883 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2971#ifdef USE_ASSERT_CHECKING
3198 (
errmsg(
"shutting down due to startup process failure")));
3204 (
errmsg(
"shutting down because \"restart_after_crash\" is off")));
3216 (
errmsg(
"all server processes terminated; reinitializing")));
3252#define PM_TOSTR_CASE(sym) case sym: return #sym
3282 elog(
DEBUG1,
"updating PMState from %s to %s",
3421#define PM_TOSTR_CASE(sym) case sym: return #sym
3462 pid_t pid = pmchild->
pid;
3468 (
int) pmchild->
pid)));
3470 if (
kill(pid, signal) < 0)
3471 elog(
DEBUG3,
"kill(%ld,%d) failed: %m", (
long) pid, signal);
3480 if (
kill(-pid, signal) < 0)
3481 elog(
DEBUG3,
"kill(%ld,%d) failed: %m", (
long) (-pid), signal);
3496 bool signaled =
false;
3585 (
errcode(ERRCODE_OUT_OF_MEMORY),
3586 errmsg(
"out of memory")));
3599 &startup_data,
sizeof(startup_data),
3604 int save_errno = errno;
3609 (
errmsg(
"could not fork new process for connection: %m")));
3618 (
int) pid, (
int) client_sock->
sock)));
3643 snprintf(buffer,
sizeof(buffer),
"E%s%s\n",
3644 _(
"could not fork new process for connection: "),
3654 rc =
send(client_sock->
sock, buffer, strlen(buffer) + 1, 0);
3655 }
while (rc < 0 && errno ==
EINTR);
3666#ifdef HAVE_PTHREAD_IS_THREADED_NP
3675 if (pthread_is_threaded_np() != 0)
3677 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3678 errmsg(
"postmaster became multithreaded"),
3679 errhint(
"Set the LC_ALL environment variable to a valid locale.")));
3701 bool request_state_update =
false;
3739 sd_notify(0,
"READY=1");
3756 (
errmsg(
"database system is ready to accept read-only connections")));
3761 sd_notify(0,
"READY=1");
3857 (
errmsg(
"WAL was shut down unexpectedly")));
3870 request_state_update =
true;
3878 request_state_update =
true;
3889 if (request_state_update)
3981 (
errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
3982 errmsg(
"no slot available for new autovacuum worker process")));
3986 elog(
LOG,
"no postmaster child slot available for aux process");
4023 elog(
PANIC,
"no postmaster child slot available for syslogger");
4097#define OPTS_FILE "postmaster.opts"
4099 if ((fp = fopen(
OPTS_FILE,
"w")) == NULL)
4107 fprintf(fp,
"%s", fullprogname);
4108 for (
i = 1;
i < argc;
i++)
4155 (
errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
4156 errmsg(
"no slot available for new background worker process")));
4170 if (worker_pid == -1)
4174 (
errmsg(
"could not fork background worker process: %m")));
4244#define MAX_BGWORKERS_TO_LAUNCH 100
4245 int num_launched = 0;
4299 if (notify_pid != 0)
4419 elog(
ERROR,
"could not find a free IO worker slot");
4478waitpid(pid_t pid,
int *exitstatus,
int options)
4480 win32_deadchild_waitinfo *childinfo;
4487 if (!GetQueuedCompletionStatus(win32ChildQueue, &dwd, &
key, &ovl, 0))
4493 childinfo = (win32_deadchild_waitinfo *)
key;
4494 pid = childinfo->procId;
4500 UnregisterWaitEx(childinfo->waitHandle, NULL);
4502 if (!GetExitCodeProcess(childinfo->procHandle, &exitcode))
4507 write_stderr(
"could not read exit code for process\n");
4510 *exitstatus = exitcode;
4516 CloseHandle(childinfo->procHandle);
4532pgwin32_deadchild_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
4535 if (TimerOrWaitFired)
4545 if (!PostQueuedCompletionStatus(win32ChildQueue,
4547 (ULONG_PTR) lpParameter,
4549 write_stderr(
"could not post child completion status\n");
4561pgwin32_register_deadchild_callback(HANDLE procHandle, DWORD procId)
4563 win32_deadchild_waitinfo *childinfo;
4565 childinfo =
palloc(
sizeof(win32_deadchild_waitinfo));
4566 childinfo->procHandle = procHandle;
4567 childinfo->procId = procId;
4569 if (!RegisterWaitForSingleObject(&childinfo->waitHandle,
4571 pgwin32_deadchild_callback,
4574 WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD))
4576 (
errmsg_internal(
"could not register process for wait: error code %lu",
4606 errmsg_internal(
"could not create pipe to monitor postmaster death: %m")));
4619 errmsg_internal(
"could not set postmaster death monitoring pipe to nonblocking mode: %m")));
4625 if (DuplicateHandle(GetCurrentProcess(),
4626 GetCurrentProcess(),
4627 GetCurrentProcess(),
4631 DUPLICATE_SAME_ACCESS) == 0)
4633 (
errmsg_internal(
"could not duplicate postmaster handle: error code %lu",
bool AutoVacuumingActive(void)
void AutoVacWorkerFailed(void)
bool CheckDateTokenTables(void)
long TimestampDifferenceMilliseconds(TimestampTz start_time, TimestampTz stop_time)
bool TimestampDifferenceExceeds(TimestampTz start_time, TimestampTz stop_time, int msec)
TimestampTz GetCurrentTimestamp(void)
Datum now(PG_FUNCTION_ARGS)
pg_time_t timestamptz_to_time_t(TimestampTz t)
const char * pgstat_get_crashed_backend_activity(int pid, char *buffer, int buflen)
void secure_destroy(void)
int secure_initialize(bool isServerStart)
void ReportBackgroundWorkerPID(RegisteredBgWorker *rw)
void ReportBackgroundWorkerExit(RegisteredBgWorker *rw)
void ResetBackgroundWorkerCrashTimes(void)
dlist_head BackgroundWorkerList
void ForgetBackgroundWorker(RegisteredBgWorker *rw)
void BackgroundWorkerStopNotifications(pid_t pid)
void BackgroundWorkerStateChange(bool allow_new_workers)
void ForgetUnstartedBackgroundWorkers(void)
#define BGW_NEVER_RESTART
@ BgWorkerStart_RecoveryFinished
@ BgWorkerStart_ConsistentState
@ BgWorkerStart_PostmasterStart
#define write_stderr(str)
int find_my_exec(const char *argv0, char *retpath)
int find_other_exec(const char *argv0, const char *target, const char *versionstr, char *retpath)
#define fprintf(file, fmt, msg)
int errcode_for_socket_access(void)
int errmsg_internal(const char *fmt,...)
int errcode_for_file_access(void)
int errdetail(const char *fmt,...)
int errhint(const char *fmt,...)
bool message_level_is_interesting(int elevel)
char * Log_destination_string
int errcode(int sqlerrcode)
int errmsg(const char *fmt,...)
#define LOG_DESTINATION_STDERR
#define ereport(elevel,...)
void err(int eval, const char *fmt,...)
void ReleaseExternalFD(void)
void RemovePgTempFilesInDir(const char *tmpdirname, bool missing_ok, bool unlink_all)
void RemovePgTempFiles(void)
DIR * AllocateDir(const char *dirname)
void ReserveExternalFD(void)
void set_max_safe_fds(void)
FILE * AllocateFile(const char *name, const char *mode)
#define PG_MODE_MASK_OWNER
#define PG_TEMP_FILES_DIR
char pkglib_path[MAXPGPATH]
TimestampTz MyStartTimestamp
bool IsPostmasterEnvironment
char my_exec_path[MAXPGPATH]
void ProcessConfigFile(GucContext context)
void SetConfigOption(const char *name, const char *value, GucContext context, GucSource source)
const char * GetConfigOption(const char *name, bool missing_ok, bool restrict_privileged)
bool SelectConfigFiles(const char *userDoption, const char *progname)
void ParseLongOption(const char *string, char **name, char **value)
void InitializeGUCOptions(void)
int GetConfigOptionFlags(const char *name, bool missing_ok)
#define GUC_RUNTIME_COMPUTED
Assert(PointerIsAligned(start, uint64))
#define dlist_foreach(iter, lhead)
#define dlist_foreach_modify(iter, lhead)
#define dlist_container(type, membername, ptr)
void on_proc_exit(pg_on_exit_callback function, Datum arg)
void shmem_exit(int code)
void InitializeShmemGUCs(void)
void CreateSharedMemoryAndSemaphores(void)
void SetLatch(Latch *latch)
void ResetLatch(Latch *latch)
const char * PostmasterChildName(BackendType child_type)
pid_t postmaster_child_launch(BackendType child_type, int child_slot, void *startup_data, size_t startup_data_len, ClientSocket *client_sock)
void ApplyLauncherRegister(void)
void list_free(List *list)
void list_free_deep(List *list)
DispatchOption parse_dispatch_option(const char *name)
char * pstrdup(const char *in)
void pfree(void *pointer)
MemoryContext TopMemoryContext
MemoryContext PostmasterContext
#define AllocSetContextCreate
#define ALLOCSET_DEFAULT_SIZES
bool pgaio_workers_enabled(void)
#define BACKEND_NUM_TYPES
void ChangeToDataDir(void)
void process_shmem_requests(void)
void AddToDataDirLockFile(int target_line, const char *str)
void InitProcessLocalLatch(void)
const char * GetBackendTypeDesc(BackendType backendType)
void process_shared_preload_libraries(void)
void TouchSocketLockFiles(void)
bool RecheckDataDirLockFile(void)
void CreateDataDirLockFile(bool amPostmaster)
static MemoryContext MemoryContextSwitchTo(MemoryContext context)
static PgChecksumMode mode
int getopt(int nargc, char *const *nargv, const char *ostr)
PGDLLIMPORT char * optarg
uint32 pg_prng_uint32(pg_prng_state *state)
void pg_prng_seed(pg_prng_state *state, uint64 seed)
pg_prng_state pg_global_prng_state
#define pg_prng_strong_seed(state)
bool PgArchCanRestart(void)
#define PM_STATUS_STARTING
#define PM_STATUS_STOPPING
#define PM_STATUS_STANDBY
#define LOCK_FILE_LINE_LISTEN_ADDR
#define LOCK_FILE_LINE_PM_STATUS
#define LOCK_FILE_LINE_SOCKET_DIR
PMChild * AssignPostmasterChildSlot(BackendType btype)
bool ReleasePostmasterChildSlot(PMChild *pmchild)
void InitPostmasterChildSlots(void)
PMChild * AllocDeadEndChild(void)
dlist_head ActiveChildList
PMChild * FindPostmasterChildByPid(int pid)
bool CheckPostmasterSignal(PMSignalReason reason)
void SetQuitSignalReason(QuitSignalReason reason)
bool IsPostmasterChildWalSender(int slot)
@ PMSIGNAL_START_AUTOVAC_WORKER
@ PMSIGNAL_RECOVERY_STARTED
@ PMSIGNAL_START_WALRECEIVER
@ PMSIGNAL_START_AUTOVAC_LAUNCHER
@ PMSIGNAL_BEGIN_HOT_STANDBY
@ PMSIGNAL_RECOVERY_CONSISTENT
@ PMSIGNAL_XLOG_IS_SHUTDOWN
@ PMSIGNAL_BACKGROUND_WORKER_CHANGE
@ PMSIGNAL_ROTATE_LOGFILE
@ PMSIGNAL_ADVANCE_STATE_MACHINE
void get_pkglib_path(const char *my_exec_path, char *ret_path)
const char * pg_strsignal(int signum)
bool pg_set_noblock(pgsocket sock)
#define PG_BACKEND_VERSIONSTR
void set_debug_options(int debug_flag, GucContext context, GucSource source)
CommandDest whereToSendOutput
bool set_plan_disabling_options(const char *arg, GucContext context, GucSource source)
const char * get_stats_option_name(const char *arg)
static const char * userDoption
void InitializeMaxBackends(void)
void InitializeFastPathLocks(void)
static int CountChildren(BackendTypeMask targetMask)
static void process_pm_pmsignal(void)
static CAC_state canAcceptConnections(BackendType backend_type)
static volatile sig_atomic_t pending_pm_reload_request
static PMChild * PgArchPMChild
static void handle_pm_shutdown_request_signal(SIGNAL_ARGS)
static volatile sig_atomic_t pending_pm_fast_shutdown_request
static const BackendTypeMask BTYPE_MASK_NONE
static void LogChildExit(int lev, const char *procname, int pid, int exitstatus)
static void maybe_start_bgworkers(void)
static void CloseServerPorts(int status, Datum arg)
static void InitPostmasterDeathWatchHandle(void)
#define EXIT_STATUS_1(st)
StaticAssertDecl(BACKEND_NUM_TYPES< 32, "too many backend types for uint32")
void InitProcessGlobals(void)
#define ImmediateShutdown
static int DetermineSleepTime(void)
static void report_fork_failure_to_client(ClientSocket *client_sock, int errnum)
static pgsocket * ListenSockets
static const BackendTypeMask BTYPE_MASK_ALL
#define btmask_all_except(...)
static void handle_pm_reload_request_signal(SIGNAL_ARGS)
static const char * pm_signame(int signal)
#define EXIT_STATUS_0(st)
static void PostmasterStateMachine(void)
static BackendTypeMask btmask_del(BackendTypeMask mask, BackendType t)
static void StartSysLogger(void)
static void TerminateChildren(int signal)
static bool btmask_contains(BackendTypeMask mask, BackendType t)
static void process_pm_child_exit(void)
#define btmask_add(mask,...)
static BackendTypeMask btmask_all_except_n(int nargs, BackendType *t)
static int ServerLoop(void)
static bool HaveCrashedWorker
static PMChild * AutoVacLauncherPMChild
static void HandleFatalError(QuitSignalReason reason, bool consider_sigabrt)
static PMChild * BgWriterPMChild
static void checkControlFile(void)
void PostmasterMain(int argc, char *argv[])
static void LaunchMissingBackgroundProcesses(void)
bool remove_temp_files_after_crash
static void signal_child(PMChild *pmchild, int signal)
static PMChild * StartChildProcess(BackendType type)
static volatile sig_atomic_t pending_pm_shutdown_request
static time_t AbortStartTime
static bool SignalChildren(int signal, BackendTypeMask targetMask)
static bool start_autovac_launcher
static PMChild * WalReceiverPMChild
static bool maybe_reap_io_worker(int pid)
static PMChild * WalWriterPMChild
bool ClientAuthInProgress
static void handle_pm_pmsignal_signal(SIGNAL_ARGS)
static PMChild * WalSummarizerPMChild
static void maybe_adjust_io_workers(void)
BackgroundWorker * MyBgworkerEntry
static void UpdatePMState(PMState newState)
static PMChild * StartupPMChild
static volatile sig_atomic_t pending_pm_pmsignal
static PMChild * SysLoggerPMChild
static bool StartBackgroundWorker(RegisteredBgWorker *rw)
static int BackendStartup(ClientSocket *client_sock)
#define PM_TOSTR_CASE(sym)
static int NumListenSockets
char * Unix_socket_directories
int postmaster_alive_fds[2]
static bool ReachedNormalRunning
#define SIGKILL_CHILDREN_AFTER_SECS
static bool CreateOptsFile(int argc, char *argv[], char *fullprogname)
static pg_noreturn void ExitPostmaster(int status)
static PMChild * io_worker_children[MAX_IO_WORKERS]
static void HandleChildCrash(int pid, int exitstatus, const char *procname)
static BackendTypeMask btmask_add_n(BackendTypeMask mask, int nargs, BackendType *t)
static void handle_pm_child_exit_signal(SIGNAL_ARGS)
static const char * pmstate_name(PMState state)
static int io_worker_count
void ClosePostmasterPorts(bool am_syslogger)
static void StartAutovacuumWorker(void)
bool send_abort_for_crash
static WaitEventSet * pm_wait_set
static void getInstallationPaths(const char *argv0)
static volatile sig_atomic_t pending_pm_immediate_shutdown_request
int AuthenticationTimeout
static void unlink_external_pid_file(int status, Datum arg)
static StartupStatusEnum StartupStatus
static bool WalReceiverRequested
static volatile sig_atomic_t pending_pm_child_exit
#define MAX_BGWORKERS_TO_LAUNCH
static void dummy_handler(SIGNAL_ARGS)
static void process_pm_shutdown_request(void)
static void CleanupBackend(PMChild *bp, int exitstatus)
static BackendTypeMask btmask(BackendType t)
static PMChild * CheckpointerPMChild
static PMChild * SlotSyncWorkerPMChild
static bool bgworker_should_start_now(BgWorkerStartTime start_time)
static void ConfigurePostmasterWaitSet(bool accept_connections)
bool PostmasterMarkPIDForWorkerNotify(int pid)
int SuperuserReservedConnections
static bool StartWorkerNeeded
static bool avlauncher_needs_signal
#define EXIT_STATUS_3(st)
static void process_pm_reload_request(void)
PGDLLIMPORT bool LoadedSSL
#define POSTMASTER_FD_OWN
#define POSTMASTER_FD_WATCH
int ListenServerPort(int family, const char *hostName, unsigned short portNumber, const char *unixSocketDir, pgsocket ListenSockets[], int *NumListenSockets, int MaxListen)
int AcceptConnection(pgsocket server_fd, ClientSocket *client_sock)
void TouchSocketFiles(void)
void RemoveSocketFiles(void)
static int fd(const char *x, int i)
void pg_queue_signal(int signum)
void pgwin32_signal_initialize(void)
bool sync_replication_slots
bool SlotSyncWorkerCanRestart(void)
bool ValidateSlotSyncParams(int elevel)
void appendStringInfo(StringInfo str, const char *fmt,...)
void appendStringInfoString(StringInfo str, const char *s)
void initStringInfo(StringInfo str)
CAC_state canAcceptConnections
TimestampTz socket_created
char bgw_name[BGW_MAXLEN]
char bgw_type[BGW_MAXLEN]
BgWorkerStartTime bgw_start_time
struct RegisteredBgWorker * rw
TimestampTz rw_crashed_at
BackgroundWorker rw_worker
bool CheckLogrotateSignal(void)
void RemoveLogrotateSignalFiles(void)
int SysLogger_Start(int child_slot)
#define LOG_METAINFO_DATAFILE
#define TimestampTzPlusMilliseconds(tz, ms)
bool SplitDirectoriesString(char *rawstring, char separator, List **namelist)
bool SplitGUCList(char *rawstring, char separator, List **namelist)
void FreeWaitEventSetAfterFork(WaitEventSet *set)
void InitializeWaitEventSupport(void)
int AddWaitEventToSet(WaitEventSet *set, uint32 events, pgsocket fd, Latch *latch, void *user_data)
int WaitEventSetWait(WaitEventSet *set, long timeout, WaitEvent *occurred_events, int nevents, uint32 wait_event_info)
void FreeWaitEventSet(WaitEventSet *set)
WaitEventSet * CreateWaitEventSet(ResourceOwner resowner, int nevents)
#define send(s, buf, len, flags)
void InitializeWalConsistencyChecking(void)
void LocalProcessControlFile(bool reset)
#define XLogArchivingActive()
#define XLogArchivingAlways()
#define XLOG_CONTROL_FILE
bool CheckPromoteSignal(void)
void RemovePromoteSignalFiles(void)