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\"")));
873#ifdef HAVE_INT_OPTRESET
880#if !defined(WIN32) || defined(_MSC_VER)
987 if (output_config_variable != NULL)
992 puts(config_val ? config_val :
"");
1022 win32ChildQueue = CreateIoCompletionPort(INVALID_HANDLE_VALUE, NULL, 0, 1);
1023 if (win32ChildQueue == NULL)
1025 (
errmsg(
"could not create I/O completion port for child queue")));
1069 errmsg(
"could not remove file \"%s\": %m",
1091 (
errmsg(
"ending log output to stderr"),
1092 errhint(
"Future log output will go to log destination \"%s\".",
1103 (
errmsg(
"starting %s", PG_VERSION_STR)));
1129 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1130 errmsg(
"invalid list syntax in parameter \"%s\"",
1131 "listen_addresses")));
1134 foreach(l, elemlist)
1136 char *curhost = (
char *)
lfirst(l);
1138 if (strcmp(curhost,
"*") == 0)
1157 if (!listen_addr_saved)
1160 listen_addr_saved =
true;
1165 (
errmsg(
"could not create listen socket for \"%s\"",
1171 (
errmsg(
"could not create any TCP/IP sockets")));
1181 DNSServiceErrorType
err;
1189 err = DNSServiceRegister(&bonjour_sdref,
1193 "_postgresql._tcp.",
1201 if (
err != kDNSServiceErr_NoError)
1203 (
errmsg(
"DNSServiceRegister() failed: error code %ld",
1231 (
errcode(ERRCODE_INVALID_PARAMETER_VALUE),
1232 errmsg(
"invalid list syntax in parameter \"%s\"",
1233 "unix_socket_directories")));
1236 foreach(l, elemlist)
1238 char *socketdir = (
char *)
lfirst(l);
1256 (
errmsg(
"could not create Unix-domain socket in directory \"%s\"",
1262 (
errmsg(
"could not create any Unix-domain sockets")));
1273 (
errmsg(
"no socket created for listening")));
1280 if (!listen_addr_saved)
1304 write_stderr(
"%s: could not change permissions of external PID file \"%s\": %m\n",
1308 write_stderr(
"%s: could not write external PID file \"%s\": %m\n",
1348#ifdef HAVE_PTHREAD_IS_THREADED_NP
1361 if (pthread_is_threaded_np() != 0)
1363 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
1364 errmsg(
"postmaster became multithreaded during startup"),
1365 errhint(
"Set the LC_ALL environment variable to a valid locale.")));
1428 elog(
LOG,
"could not close listen socket: %m");
1468 (
errmsg(
"%s: could not locate my own executable path",
argv0)));
1473 postgres_exec_path) < 0)
1475 (
errmsg(
"%s: could not locate matching postgres executable",
1496 errmsg(
"could not open directory \"%s\": %m",
1498 errhint(
"This may indicate an incomplete PostgreSQL installation, or that the file \"%s\" has been moved away from its proper location.",
1525 write_stderr(
"%s: could not find the database system\n"
1526 "Expected to find it in the directory \"%s\",\n"
1527 "but could not open file \"%s\": %m\n",
1563 return Max(seconds * 1000, 0);
1601 if (next_wakeup == 0 || this_wakeup < next_wakeup)
1602 next_wakeup = this_wakeup;
1606 if (next_wakeup != 0)
1613 return Min(60 * 1000, ms);
1640 if (accept_connections)
1654 time_t last_lockfile_recheck_time,
1660 last_lockfile_recheck_time = last_touch_time = time(NULL);
1676 for (
int i = 0;
i < nevents;
i++)
1708 elog(
LOG,
"could not close client socket: %m");
1727#ifdef HAVE_PTHREAD_IS_THREADED_NP
1733 Assert(pthread_is_threaded_np() == 0);
1762 (
errmsg(
"issuing %s to recalcitrant children",
1784 (
errmsg(
"performing immediate shutdown because data directory lock file is invalid")));
1787 last_lockfile_recheck_time =
now;
1799 last_touch_time =
now;
1874 errmsg_internal(
"could not close postmaster death monitoring pipe in child process: %m")));
1893 elog(
LOG,
"could not close listen socket: %m");
1921 close(DNSServiceRefSockFD(bonjour_sdref));
2004 (
errmsg(
"received SIGHUP, reloading configuration files")));
2026 (
errmsg(
"SSL configuration was not reloaded")));
2049 switch (postgres_signal_arg)
2112 (
errmsg(
"received smart shutdown request")));
2117 sd_notify(0,
"STOPPING=1");
2153 (
errmsg(
"received fast shutdown request")));
2158 sd_notify(0,
"STOPPING=1");
2171 (
errmsg(
"aborting any active transactions")));
2195 (
errmsg(
"received immediate shutdown request")));
2200 sd_notify(0,
"STOPPING=1");
2242 while ((pid = waitpid(-1, &exitstatus, WNOHANG)) > 0)
2270 (
errmsg(
"shutdown at recovery target")));
2291 (
errmsg(
"aborting startup due to startup process failure")));
2324 _(
"startup process"));
2347 (
errmsg(
"database system is ready to accept connections")));
2352 sd_notify(0,
"READY=1");
2369 _(
"background writer process"));
2402 _(
"checkpointer process"));
2419 _(
"WAL writer process"));
2435 _(
"WAL receiver process"));
2450 _(
"WAL summarizer process"));
2466 _(
"autovacuum launcher process"));
2482 _(
"archiver process"));
2515 _(
"slot sync worker process"));
2569 const char *procname;
2570 bool crashed =
false;
2571 bool logged =
false;
2573 bool bp_bgworker_notify;
2605 if (exitstatus == ERROR_WAIT_NO_CHILDREN)
2646 if (bp_bgworker_notify)
2673 procname, bp_pid, exitstatus);
2797 (
errmsg(
"terminating any other active server processes")));
2816 char activity_buffer[1024];
2817 const char *activity = NULL;
2822 sizeof(activity_buffer));
2830 (
errmsg(
"%s (PID %d) exited with exit code %d",
2832 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2841 (
errmsg(
"%s (PID %d) was terminated by exception 0x%X",
2842 procname, pid,
WTERMSIG(exitstatus)),
2843 errhint(
"See C include file \"ntstatus.h\" for a description of the hexadecimal value."),
2844 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2851 (
errmsg(
"%s (PID %d) was terminated by signal %d: %s",
2852 procname, pid,
WTERMSIG(exitstatus),
2854 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2863 (
errmsg(
"%s (PID %d) exited with unrecognized status %d",
2864 procname, pid, exitstatus),
2865 activity ?
errdetail(
"Failed process was running: %s", activity) : 0));
2953#ifdef USE_ASSERT_CHECKING
3180 (
errmsg(
"shutting down due to startup process failure")));
3186 (
errmsg(
"shutting down because \"restart_after_crash\" is off")));
3198 (
errmsg(
"all server processes terminated; reinitializing")));
3234#define PM_TOSTR_CASE(sym) case sym: return #sym
3264 elog(
DEBUG1,
"updating PMState from %s to %s",
3403#define PM_TOSTR_CASE(sym) case sym: return #sym
3444 pid_t pid = pmchild->
pid;
3450 (
int) pmchild->
pid)));
3452 if (
kill(pid, signal) < 0)
3453 elog(
DEBUG3,
"kill(%ld,%d) failed: %m", (
long) pid, signal);
3462 if (
kill(-pid, signal) < 0)
3463 elog(
DEBUG3,
"kill(%ld,%d) failed: %m", (
long) (-pid), signal);
3478 bool signaled =
false;
3567 (
errcode(ERRCODE_OUT_OF_MEMORY),
3568 errmsg(
"out of memory")));
3581 &startup_data,
sizeof(startup_data),
3586 int save_errno = errno;
3591 (
errmsg(
"could not fork new process for connection: %m")));
3600 (
int) pid, (
int) client_sock->
sock)));
3625 snprintf(buffer,
sizeof(buffer),
"E%s%s\n",
3626 _(
"could not fork new process for connection: "),
3636 rc =
send(client_sock->
sock, buffer, strlen(buffer) + 1, 0);
3637 }
while (rc < 0 && errno ==
EINTR);
3648#ifdef HAVE_PTHREAD_IS_THREADED_NP
3657 if (pthread_is_threaded_np() != 0)
3659 (
errcode(ERRCODE_OBJECT_NOT_IN_PREREQUISITE_STATE),
3660 errmsg(
"postmaster became multithreaded"),
3661 errhint(
"Set the LC_ALL environment variable to a valid locale.")));
3683 bool request_state_update =
false;
3721 sd_notify(0,
"READY=1");
3738 (
errmsg(
"database system is ready to accept read-only connections")));
3743 sd_notify(0,
"READY=1");
3839 (
errmsg(
"WAL was shut down unexpectedly")));
3852 request_state_update =
true;
3860 request_state_update =
true;
3871 if (request_state_update)
3963 (
errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
3964 errmsg(
"no slot available for new autovacuum worker process")));
3968 elog(
LOG,
"no postmaster child slot available for aux process");
4005 elog(
PANIC,
"no postmaster child slot available for syslogger");
4079#define OPTS_FILE "postmaster.opts"
4081 if ((fp = fopen(
OPTS_FILE,
"w")) == NULL)
4089 fprintf(fp,
"%s", fullprogname);
4090 for (
i = 1;
i < argc;
i++)
4137 (
errcode(ERRCODE_CONFIGURATION_LIMIT_EXCEEDED),
4138 errmsg(
"no slot available for new background worker process")));
4152 if (worker_pid == -1)
4156 (
errmsg(
"could not fork background worker process: %m")));
4226#define MAX_BGWORKERS_TO_LAUNCH 100
4227 int num_launched = 0;
4281 if (notify_pid != 0)
4401 elog(
ERROR,
"could not find a free IO worker ID");
4460waitpid(pid_t pid,
int *exitstatus,
int options)
4462 win32_deadchild_waitinfo *childinfo;
4469 if (!GetQueuedCompletionStatus(win32ChildQueue, &dwd, &
key, &ovl, 0))
4475 childinfo = (win32_deadchild_waitinfo *)
key;
4476 pid = childinfo->procId;
4482 UnregisterWaitEx(childinfo->waitHandle, NULL);
4484 if (!GetExitCodeProcess(childinfo->procHandle, &exitcode))
4489 write_stderr(
"could not read exit code for process\n");
4492 *exitstatus = exitcode;
4498 CloseHandle(childinfo->procHandle);
4514pgwin32_deadchild_callback(PVOID lpParameter, BOOLEAN TimerOrWaitFired)
4517 if (TimerOrWaitFired)
4527 if (!PostQueuedCompletionStatus(win32ChildQueue,
4529 (ULONG_PTR) lpParameter,
4531 write_stderr(
"could not post child completion status\n");
4543pgwin32_register_deadchild_callback(HANDLE procHandle, DWORD procId)
4545 win32_deadchild_waitinfo *childinfo;
4547 childinfo =
palloc(
sizeof(win32_deadchild_waitinfo));
4548 childinfo->procHandle = procHandle;
4549 childinfo->procId = procId;
4551 if (!RegisterWaitForSingleObject(&childinfo->waitHandle,
4553 pgwin32_deadchild_callback,
4556 WT_EXECUTEONLYONCE | WT_EXECUTEINWAITTHREAD))
4558 (
errmsg_internal(
"could not register process for wait: error code %lu",
4588 errmsg_internal(
"could not create pipe to monitor postmaster death: %m")));
4601 errmsg_internal(
"could not set postmaster death monitoring pipe to nonblocking mode: %m")));
4607 if (DuplicateHandle(GetCurrentProcess(),
4608 GetCurrentProcess(),
4609 GetCurrentProcess(),
4613 DUPLICATE_SAME_ACCESS) == 0)
4615 (
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)
pid_t postmaster_child_launch(BackendType child_type, int child_slot, const void *startup_data, size_t startup_data_len, ClientSocket *client_sock)
const char * PostmasterChildName(BackendType child_type)
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)