PostgreSQL Source Code
git master
|
#include "postgres.h"
#include <unistd.h>
#include <signal.h>
#include <time.h>
#include <sys/wait.h>
#include <ctype.h>
#include <sys/stat.h>
#include <sys/socket.h>
#include <fcntl.h>
#include <sys/param.h>
#include <netdb.h>
#include <limits.h>
#include "access/xlog.h"
#include "access/xlogrecovery.h"
#include "common/file_perm.h"
#include "common/file_utils.h"
#include "common/ip.h"
#include "common/pg_prng.h"
#include "lib/ilist.h"
#include "libpq/libpq.h"
#include "libpq/pqsignal.h"
#include "pg_getopt.h"
#include "pgstat.h"
#include "port/pg_bswap.h"
#include "postmaster/autovacuum.h"
#include "postmaster/auxprocess.h"
#include "postmaster/bgworker_internals.h"
#include "postmaster/pgarch.h"
#include "postmaster/postmaster.h"
#include "postmaster/syslogger.h"
#include "postmaster/walsummarizer.h"
#include "replication/logicallauncher.h"
#include "replication/slotsync.h"
#include "replication/walsender.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "tcop/backend_startup.h"
#include "tcop/tcopprot.h"
#include "utils/datetime.h"
#include "utils/memutils.h"
#include "utils/pidfile.h"
#include "utils/timestamp.h"
#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
struct | bkend |
Macros | |
#define | BACKEND_TYPE_NORMAL 0x0001 /* normal backend */ |
#define | BACKEND_TYPE_AUTOVAC 0x0002 /* autovacuum worker process */ |
#define | BACKEND_TYPE_WALSND 0x0004 /* walsender process */ |
#define | BACKEND_TYPE_BGWORKER 0x0008 /* bgworker process */ |
#define | BACKEND_TYPE_ALL 0x000F /* OR of all the above */ |
#define | MAXLISTEN 64 |
#define | NoShutdown 0 |
#define | SmartShutdown 1 |
#define | FastShutdown 2 |
#define | ImmediateShutdown 3 |
#define | SIGKILL_CHILDREN_AFTER_SECS 5 |
#define | SignalChildren(sig) SignalSomeChildren(sig, BACKEND_TYPE_ALL) |
#define | PgArchStartupAllowed() |
#define | EXIT_STATUS_0(st) ((st) == 0) |
#define | EXIT_STATUS_1(st) (WIFEXITED(st) && WEXITSTATUS(st) == 1) |
#define | EXIT_STATUS_3(st) (WIFEXITED(st) && WEXITSTATUS(st) == 3) |
#define | OPTS_FILE "postmaster.opts" |
#define | MAX_BGWORKERS_TO_LAUNCH 100 |
Typedefs | |
typedef struct bkend | Backend |
Enumerations | |
enum | StartupStatusEnum { STARTUP_NOT_RUNNING , STARTUP_RUNNING , STARTUP_SIGNALED , STARTUP_CRASHED } |
enum | PMState { PM_INIT , PM_STARTUP , PM_RECOVERY , PM_HOT_STANDBY , PM_RUN , PM_STOP_BACKENDS , PM_WAIT_BACKENDS , PM_SHUTDOWN , PM_SHUTDOWN_2 , PM_WAIT_DEAD_END , PM_NO_CHILDREN } |
#define BACKEND_TYPE_ALL 0x000F /* OR of all the above */ |
Definition at line 140 of file postmaster.c.
#define BACKEND_TYPE_AUTOVAC 0x0002 /* autovacuum worker process */ |
Definition at line 137 of file postmaster.c.
#define BACKEND_TYPE_BGWORKER 0x0008 /* bgworker process */ |
Definition at line 139 of file postmaster.c.
#define BACKEND_TYPE_NORMAL 0x0001 /* normal backend */ |
Definition at line 136 of file postmaster.c.
#define BACKEND_TYPE_WALSND 0x0004 /* walsender process */ |
Definition at line 138 of file postmaster.c.
#define EXIT_STATUS_0 | ( | st | ) | ((st) == 0) |
Definition at line 470 of file postmaster.c.
#define EXIT_STATUS_1 | ( | st | ) | (WIFEXITED(st) && WEXITSTATUS(st) == 1) |
Definition at line 471 of file postmaster.c.
#define EXIT_STATUS_3 | ( | st | ) | (WIFEXITED(st) && WEXITSTATUS(st) == 3) |
Definition at line 472 of file postmaster.c.
#define FastShutdown 2 |
Definition at line 266 of file postmaster.c.
#define ImmediateShutdown 3 |
Definition at line 267 of file postmaster.c.
#define MAX_BGWORKERS_TO_LAUNCH 100 |
#define MAXLISTEN 64 |
Definition at line 220 of file postmaster.c.
#define NoShutdown 0 |
Definition at line 264 of file postmaster.c.
#define OPTS_FILE "postmaster.opts" |
#define PgArchStartupAllowed | ( | ) |
Definition at line 441 of file postmaster.c.
#define SIGKILL_CHILDREN_AFTER_SECS 5 |
Definition at line 346 of file postmaster.c.
#define SignalChildren | ( | sig | ) | SignalSomeChildren(sig, BACKEND_TYPE_ALL) |
Definition at line 422 of file postmaster.c.
#define SmartShutdown 1 |
Definition at line 265 of file postmaster.c.
enum PMState |
Enumerator | |
---|---|
PM_INIT | |
PM_STARTUP | |
PM_RECOVERY | |
PM_HOT_STANDBY | |
PM_RUN | |
PM_STOP_BACKENDS | |
PM_WAIT_BACKENDS | |
PM_SHUTDOWN | |
PM_SHUTDOWN_2 | |
PM_WAIT_DEAD_END | |
PM_NO_CHILDREN |
Definition at line 314 of file postmaster.c.
enum StartupStatusEnum |
Enumerator | |
---|---|
STARTUP_NOT_RUNNING | |
STARTUP_RUNNING | |
STARTUP_SIGNALED | |
STARTUP_CRASHED |
Definition at line 253 of file postmaster.c.
|
static |
Definition at line 4345 of file postmaster.c.
References AssignPostmasterChildSlot(), BACKEND_TYPE_BGWORKER, bkend::bgworker_notify, bkend::bkend_type, CAC_OK, canAcceptConnections(), bkend::cancel_key, bkend::child_slot, bkend::dead_end, ereport, errcode(), errmsg(), LOG, MCXT_ALLOC_NO_OOM, MyCancelKey, MyPMChildSlot, palloc_extended(), RandomCancelKey(), RegisteredBgWorker::rw_backend, and RegisteredBgWorker::rw_child_slot.
Referenced by do_start_bgworker().
|
static |
Definition at line 3544 of file postmaster.c.
References AssignPostmasterChildSlot(), B_BACKEND, BACKEND_TYPE_NORMAL, BackendList, bkend::bgworker_notify, bkend::bkend_type, CAC_OK, canAcceptConnections(), BackendStartupData::canAcceptConnections, bkend::cancel_key, bkend::child_slot, bkend::dead_end, DEBUG2, dlist_push_head(), bkend::elem, ereport, errcode(), errmsg(), errmsg_internal(), LOG, MCXT_ALLOC_NO_OOM, MyCancelKey, MyPMChildSlot, palloc_extended(), pfree(), bkend::pid, postmaster_child_launch(), RandomCancelKey(), ReleasePostmasterChildSlot(), report_fork_failure_to_client(), ClientSocket::sock, STATUS_ERROR, and STATUS_OK.
Referenced by ServerLoop().
void BackgroundWorkerBlockSignals | ( | void | ) |
void BackgroundWorkerInitializeConnection | ( | const char * | dbname, |
const char * | username, | ||
uint32 | flags | ||
) |
Definition at line 4155 of file postmaster.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 4189 of file postmaster.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 4229 of file postmaster.c.
References UnBlockSig.
Referenced by ApplyLauncherMain(), autoprewarm_database_main(), autoprewarm_main(), BackgroundWorkerMain(), ParallelApplyWorkerMain(), ParallelWorkerMain(), SetupApplyOrSyncWorker(), test_shm_mq_main(), and worker_spi_main().
|
static |
Definition at line 4303 of file postmaster.c.
References BgWorkerStart_ConsistentState, BgWorkerStart_PostmasterStart, BgWorkerStart_RecoveryFinished, PM_HOT_STANDBY, PM_INIT, PM_NO_CHILDREN, PM_RECOVERY, PM_RUN, PM_SHUTDOWN, PM_SHUTDOWN_2, PM_STARTUP, PM_STOP_BACKENDS, PM_WAIT_BACKENDS, PM_WAIT_DEAD_END, pmState, and start_time.
Referenced by maybe_start_bgworkers().
|
static |
Definition at line 1895 of file postmaster.c.
References BACKEND_TYPE_ALL, BACKEND_TYPE_BGWORKER, BACKEND_TYPE_NORMAL, CAC_NOTCONSISTENT, CAC_OK, CAC_RECOVERY, CAC_SHUTDOWN, CAC_STARTUP, CAC_TOOMANY, connsAllowed, CountChildren(), FatalError, MaxLivePostmasterChildren(), NoShutdown, PM_HOT_STANDBY, PM_RECOVERY, PM_RUN, PM_STARTUP, pmState, and Shutdown.
Referenced by assign_backendlist_entry(), BackendStartup(), and StartAutovacuumWorker().
|
static |
Definition at line 1487 of file postmaster.c.
References AllocateFile(), DataDir, ExitPostmaster(), FreeFile(), MAXPGPATH, PG_BINARY_R, progname, snprintf, and write_stderr.
Referenced by PostmasterMain().
|
static |
Definition at line 2790 of file postmaster.c.
References _, BackendList, BackgroundWorkerStopNotifications(), bkend::bgworker_notify, bkend::child_slot, dlist_mutable_iter::cur, bkend::dead_end, DEBUG2, dlist_container, dlist_delete(), dlist_foreach_modify, EXIT_STATUS_0, EXIT_STATUS_1, HandleChildCrash(), LOG, LogChildExit(), pfree(), bkend::pid, and ReleasePostmasterChildSlot().
Referenced by process_pm_child_exit().
|
static |
Definition at line 2695 of file postmaster.c.
References _, BackgroundWorkerList, BackgroundWorkerStopNotifications(), BackgroundWorker::bgw_type, bkend::bgworker_notify, slist_mutable_iter::cur, DEBUG1, dlist_delete(), bkend::elem, EXIT_STATUS_0, EXIT_STATUS_1, GetCurrentTimestamp(), HandleChildCrash(), LOG, LogChildExit(), MAXPGPATH, pfree(), ReleasePostmasterChildSlot(), ReportBackgroundWorkerExit(), RegisteredBgWorker::rw_backend, RegisteredBgWorker::rw_child_slot, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, slist_container, slist_foreach_modify, and snprintf.
Referenced by process_pm_child_exit().
void ClosePostmasterPorts | ( | bool | am_syslogger | ) |
Definition at line 1955 of file postmaster.c.
References close, closesocket, elog, ereport, errcode_for_file_access(), errmsg_internal(), FATAL, FreeWaitEventSetAfterFork(), i, ListenSockets, LOG, NumListenSockets, pfree(), pm_wait_set, postmaster_alive_fds, POSTMASTER_FD_OWN, ReleaseExternalFD(), and syslogPipe.
Referenced by postmaster_child_launch().
|
static |
Definition at line 1387 of file postmaster.c.
References closesocket, elog, i, ListenSockets, LOG, NumListenSockets, and RemoveSocketFiles().
Referenced by PostmasterMain().
|
static |
Definition at line 1601 of file postmaster.c.
References AddWaitEventToSet(), CreateWaitEventSet(), FreeWaitEventSet(), i, ListenSockets, MyLatch, NumListenSockets, PGINVALID_SOCKET, pm_wait_set, WL_LATCH_SET, and WL_SOCKET_ACCEPT.
Referenced by PostmasterStateMachine(), and ServerLoop().
|
static |
Definition at line 3878 of file postmaster.c.
References BACKEND_TYPE_ALL, BACKEND_TYPE_NORMAL, BACKEND_TYPE_WALSND, BackendList, bkend::bkend_type, bkend::child_slot, dlist_iter::cur, bkend::dead_end, dlist_container, dlist_foreach, and IsPostmasterChildWalSender().
Referenced by canAcceptConnections(), and PostmasterStateMachine().
|
static |
Definition at line 4101 of file postmaster.c.
References ereport, errcode_for_file_access(), errmsg(), fprintf, i, LOG, and OPTS_FILE.
Referenced by PostmasterMain().
|
static |
Definition at line 1516 of file postmaster.c.
References AbortStartTime, BackgroundWorkerList, BGW_NEVER_RESTART, BackgroundWorker::bgw_restart_time, slist_mutable_iter::cur, ForgetBackgroundWorker(), GetCurrentTimestamp(), HaveCrashedWorker, Max, Min, NoShutdown, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, Shutdown, SIGKILL_CHILDREN_AFTER_SECS, slist_container, slist_foreach_modify, StartWorkerNeeded, TimestampDifferenceMilliseconds(), and TimestampTzPlusMilliseconds.
Referenced by ServerLoop().
|
static |
Definition at line 4244 of file postmaster.c.
References Assert(), assign_backendlist_entry(), B_BG_WORKER, BackendList, BackgroundWorker::bgw_name, DEBUG1, dlist_push_head(), bkend::elem, ereport, errmsg(), errmsg_internal(), GetCurrentTimestamp(), LOG, pfree(), bkend::pid, postmaster_child_launch(), ReleasePostmasterChildSlot(), ReportBackgroundWorkerPID(), RegisteredBgWorker::rw_backend, RegisteredBgWorker::rw_child_slot, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_pid, and RegisteredBgWorker::rw_worker.
Referenced by maybe_start_bgworkers().
|
static |
|
static |
Definition at line 3668 of file postmaster.c.
References ereport, errcode(), errdetail(), errmsg_internal(), LOG, and proc_exit().
Referenced by checkControlFile(), PostmasterMain(), PostmasterStateMachine(), process_pm_child_exit(), and StartChildProcess().
|
static |
Definition at line 1433 of file postmaster.c.
References AllocateDir(), argv0, ereport, errcode_for_file_access(), errhint(), errmsg(), ERROR, FATAL, find_my_exec(), find_other_exec(), FreeDir(), get_pkglib_path(), my_exec_path, PG_BACKEND_VERSIONSTR, and pkglib_path.
Referenced by PostmasterMain().
|
static |
Definition at line 2343 of file postmaster.c.
References MyLatch, pending_pm_child_exit, and SetLatch().
Referenced by PostmasterMain().
|
static |
Definition at line 2075 of file postmaster.c.
References MyLatch, pending_pm_pmsignal, and SetLatch().
Referenced by PostmasterMain().
|
static |
Definition at line 2085 of file postmaster.c.
References MyLatch, pending_pm_reload_request, and SetLatch().
Referenced by PostmasterMain().
|
static |
Definition at line 2168 of file postmaster.c.
References MyLatch, pending_pm_fast_shutdown_request, pending_pm_immediate_shutdown_request, pending_pm_shutdown_request, SetLatch(), and SIGQUIT.
Referenced by PostmasterMain().
|
static |
Definition at line 2874 of file postmaster.c.
References AbortStartTime, AutoVacPID, BACKEND_TYPE_BGWORKER, BackendList, BackgroundWorkerList, BgWriterPID, bkend::bkend_type, CheckpointerPID, bkend::child_slot, dlist_mutable_iter::cur, slist_iter::cur, bkend::dead_end, dlist_container, dlist_delete(), dlist_foreach_modify, bkend::elem, ereport, errmsg(), FatalError, ImmediateShutdown, LOG, LogChildExit(), pfree(), PgArchPID, bkend::pid, PM_HOT_STANDBY, PM_RECOVERY, PM_RUN, PM_SHUTDOWN, PM_STOP_BACKENDS, PM_WAIT_BACKENDS, PMQUIT_FOR_CRASH, pmState, ReleasePostmasterChildSlot(), RegisteredBgWorker::rw_backend, RegisteredBgWorker::rw_child_slot, RegisteredBgWorker::rw_pid, SetQuitSignalReason(), Shutdown, sigquit_child(), slist_container, slist_foreach, SlotSyncWorkerPID, STARTUP_SIGNALED, StartupPID, StartupStatus, WalReceiverPID, WalSummarizerPID, and WalWriterPID.
Referenced by CleanupBackend(), CleanupBackgroundWorker(), and process_pm_child_exit().
|
static |
Definition at line 4703 of file postmaster.c.
References Assert(), ereport, errcode_for_file_access(), errcode_for_socket_access(), errmsg_internal(), FATAL, MyProcPid, postmaster_alive_fds, POSTMASTER_FD_WATCH, PostmasterPid, and ReserveExternalFD().
Referenced by PostmasterMain().
void InitProcessGlobals | ( | void | ) |
Definition at line 2032 of file postmaster.c.
References GetCurrentTimestamp(), MyProcPid, MyStartTime, MyStartTimestamp, pg_global_prng_state, pg_prng_seed(), pg_prng_strong_seed, pg_prng_uint32(), timestamptz_to_time_t(), and unlikely.
Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().
|
static |
Definition at line 3061 of file postmaster.c.
References ereport, errdetail(), errhint(), errmsg(), EXIT_STATUS_0, pg_strsignal(), pgstat_get_crashed_backend_activity(), WEXITSTATUS, WIFEXITED, WIFSIGNALED, and WTERMSIG.
Referenced by CleanupBackend(), CleanupBackgroundWorker(), HandleChildCrash(), and process_pm_child_exit().
int MaxLivePostmasterChildren | ( | void | ) |
Definition at line 4145 of file postmaster.c.
References autovacuum_max_workers, max_wal_senders, max_worker_processes, and MaxConnections.
Referenced by canAcceptConnections(), PMSignalShmemInit(), PMSignalShmemSize(), and processCancelRequest().
|
static |
Definition at line 4409 of file postmaster.c.
References BackgroundWorkerList, BGW_NEVER_RESTART, BackgroundWorker::bgw_notify_pid, BackgroundWorker::bgw_restart_time, BackgroundWorker::bgw_start_time, bgworker_should_start_now(), slist_mutable_iter::cur, do_start_bgworker(), FatalError, ForgetBackgroundWorker(), GetCurrentTimestamp(), HaveCrashedWorker, kill, MAX_BGWORKERS_TO_LAUNCH, now(), RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, SIGUSR1, slist_container, slist_foreach_modify, StartWorkerNeeded, and TimestampDifferenceExceeds().
Referenced by PostmasterMain(), process_pm_child_exit(), process_pm_pmsignal(), and ServerLoop().
|
static |
Definition at line 4089 of file postmaster.c.
References B_SLOTSYNC_WORKER, LOG, PM_HOT_STANDBY, pmState, Shutdown, SlotSyncWorkerCanRestart(), SlotSyncWorkerPID, SmartShutdown, StartChildProcess(), sync_replication_slots, and ValidateSlotSyncParams().
Referenced by process_pm_child_exit(), and ServerLoop().
|
static |
Definition at line 4051 of file postmaster.c.
References B_WAL_RECEIVER, PM_HOT_STANDBY, PM_RECOVERY, PM_STARTUP, pmState, Shutdown, SmartShutdown, StartChildProcess(), WalReceiverPID, and WalReceiverRequested.
Referenced by process_pm_pmsignal(), and ServerLoop().
|
static |
Definition at line 4070 of file postmaster.c.
References B_WAL_SUMMARIZER, PM_HOT_STANDBY, PM_RUN, pmState, Shutdown, SmartShutdown, StartChildProcess(), summarize_wal, and WalSummarizerPID.
Referenced by process_pm_child_exit(), and ServerLoop().
void PostmasterMain | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 489 of file postmaster.c.
References AddToDataDirLockFile(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ApplyLauncherRegister(), ARCHIVE_MODE_OFF, Assert(), autovac_init(), B_BG_WRITER, B_CHECKPOINTER, B_STARTUP, BgWriterPID, BlockSig, bonjour_name, ChangeToDataDir(), checkControlFile(), checkDataDir(), CheckDateTokenTables(), CheckpointerPID, CloseServerPorts(), CreateDataDirLockFile(), CreateOptsFile(), CreateSharedMemoryAndSemaphores(), DEBUG3, DestNone, dummy_handler(), enable_bonjour, EnableSSL, environ, ereport, err(), errcode(), errcode_for_file_access(), errhint(), errmsg(), errmsg_internal(), ERROR, ExitPostmaster(), external_pid_file, FATAL, fprintf, get_stats_option_name(), GetConfigOption(), GetConfigOptionFlags(), GetCurrentTimestamp(), getInstallationPaths(), getopt(), GUC_RUNTIME_COMPUTED, handle_pm_child_exit_signal(), handle_pm_pmsignal_signal(), handle_pm_reload_request_signal(), handle_pm_shutdown_request_signal(), HbaFileName, InitializeGUCOptions(), InitializeLatchSupport(), InitializeMaxBackends(), InitializeShmemGUCs(), InitializeWalConsistencyChecking(), InitPostmasterDeathWatchHandle(), InitProcessGlobals(), InitProcessLocalLatch(), IsBinaryUpgrade, IsPostmasterEnvironment, lfirst, list_free(), list_free_deep(), ListenAddresses, ListenServerPort(), ListenSockets, load_hba(), load_ident(), LoadedSSL, LocalProcessControlFile(), LOCK_FILE_LINE_LISTEN_ADDR, LOCK_FILE_LINE_PM_STATUS, LOCK_FILE_LINE_SOCKET_DIR, LOG, Log_destination, LOG_DESTINATION_STDERR, Log_destination_string, LOG_METAINFO_DATAFILE, max_wal_senders, MaxConnections, MAXLISTEN, maybe_start_bgworkers(), MemoryContextSwitchTo(), my_exec_path, MyProcPid, name, NIL, NumListenSockets, on_proc_exit(), optarg, opterr, optind, palloc(), ParseLongOption(), pfree(), pg_hton16, PG_MODE_MASK_OWNER, PG_TEMP_FILES_DIR, PGC_POSTMASTER, PGC_S_ARGV, PGC_S_OVERRIDE, PGC_SUSET, PgStartTime, pgwin32_signal_initialize(), PM_STARTUP, PM_STATUS_STARTING, pmState, PostmasterContext, PostmasterPid, PostPortNumber, pqinitmask(), pqsignal(), process_shared_preload_libraries(), process_shmem_requests(), progname, pstrdup(), RemoveLogrotateSignalFiles(), RemovePgTempFiles(), RemovePgTempFilesInDir(), RemovePromoteSignalFiles(), ReservedConnections, S_IRGRP, S_IROTH, S_IRUSR, S_IWUSR, secure_initialize(), SelectConfigFiles(), ServerLoop(), set_debug_options(), set_max_safe_fds(), set_plan_disabling_options(), set_stack_base(), SetConfigOption(), SIG_IGN, SIGALRM, SIGCHLD, SIGHUP, SIGPIPE, SIGQUIT, SIGUSR1, SIGUSR2, SplitDirectoriesString(), SplitGUCList(), StartChildProcess(), STARTUP_RUNNING, StartupPID, StartupStatus, STATUS_OK, success, summarize_wal, SuperuserReservedConnections, SysLogger_Start(), SysLoggerPID, TopMemoryContext, UnBlockSig, Unix_socket_directories, unlink_external_pid_file(), userDoption, value, wal_level, WAL_LEVEL_MINIMAL, WARNING, whereToSendOutput, write_stderr, and XLogArchiveMode.
Referenced by main().
bool PostmasterMarkPIDForWorkerNotify | ( | int | pid | ) |
Definition at line 4528 of file postmaster.c.
References BackendList, bkend::bgworker_notify, dlist_iter::cur, dlist_container, dlist_foreach, and bkend::pid.
Referenced by BackgroundWorkerStateChange().
|
static |
Definition at line 3127 of file postmaster.c.
References AbortStartTime, Assert(), AutoVacPID, B_CHECKPOINTER, B_STARTUP, BACKEND_TYPE_ALL, BACKEND_TYPE_NORMAL, BACKEND_TYPE_WALSND, BackendList, BgWriterPID, CheckpointerPID, ConfigurePostmasterWaitSet(), connsAllowed, CountChildren(), CreateSharedMemoryAndSemaphores(), dlist_is_empty(), ereport, errmsg(), ExitPostmaster(), FatalError, ForgetUnstartedBackgroundWorkers(), ImmediateShutdown, LocalProcessControlFile(), LOG, NoShutdown, PgArchPID, PM_HOT_STANDBY, PM_NO_CHILDREN, PM_RUN, PM_SHUTDOWN, PM_SHUTDOWN_2, PM_STARTUP, PM_STOP_BACKENDS, PM_WAIT_BACKENDS, PM_WAIT_DEAD_END, pmState, remove_temp_files_after_crash, RemovePgTempFiles(), ResetBackgroundWorkerCrashTimes(), restart_after_crash, shmem_exit(), Shutdown, signal_child(), SignalChildren, SignalSomeChildren(), SIGQUIT, SIGUSR2, SlotSyncWorkerPID, StartChildProcess(), STARTUP_CRASHED, STARTUP_RUNNING, StartupPID, StartupStatus, WalReceiverPID, WalSummarizerPID, and WalWriterPID.
Referenced by process_pm_child_exit(), process_pm_pmsignal(), and process_pm_shutdown_request().
|
static |
Definition at line 2353 of file postmaster.c.
References _, AbortStartTime, AddToDataDirLockFile(), Assert(), AutoVacPID, AutoVacuumingActive(), B_ARCHIVER, B_AUTOVAC_LAUNCHER, B_BG_WRITER, B_CHECKPOINTER, B_WAL_WRITER, BgWriterPID, CheckpointerPID, CleanupBackend(), CleanupBackgroundWorker(), connsAllowed, DEBUG4, ereport, errmsg(), errmsg_internal(), EXIT_STATUS_0, EXIT_STATUS_1, EXIT_STATUS_3, ExitPostmaster(), FatalError, HandleChildCrash(), HaveCrashedWorker, IsBinaryUpgrade, LOCK_FILE_LINE_PM_STATUS, LOG, LogChildExit(), Max, maybe_start_bgworkers(), MaybeStartSlotSyncWorker(), MaybeStartWalSummarizer(), NoShutdown, pending_pm_child_exit, PgArchPID, PgArchStartupAllowed, PM_RUN, PM_SHUTDOWN, PM_SHUTDOWN_2, PM_STARTUP, PM_STATUS_READY, PM_WAIT_BACKENDS, pmState, PostmasterStateMachine(), ReachedNormalRunning, Shutdown, signal_child(), SignalChildren, SIGUSR2, SlotSyncWorkerPID, SmartShutdown, StartChildProcess(), STARTUP_CRASHED, STARTUP_NOT_RUNNING, STARTUP_SIGNALED, StartupPID, StartupStatus, SysLogger_Start(), SysLoggerPID, TerminateChildren(), WalReceiverPID, WalSummarizerPID, and WalWriterPID.
Referenced by ServerLoop().
|
static |
Definition at line 3702 of file postmaster.c.
References AbortStartTime, AddToDataDirLockFile(), Assert(), B_ARCHIVER, BackgroundWorkerStateChange(), CheckLogrotateSignal(), CheckPostmasterSignal(), CheckPromoteSignal(), connsAllowed, DEBUG2, EnableHotStandby, ereport, errmsg(), errmsg_internal(), FatalError, HaveCrashedWorker, LOCK_FILE_LINE_PM_STATUS, LOG, maybe_start_bgworkers(), MaybeStartWalReceiver(), NoShutdown, pending_pm_pmsignal, PgArchPID, PM_HOT_STANDBY, PM_RECOVERY, PM_STARTUP, PM_STATUS_READY, PM_STATUS_STANDBY, PM_STOP_BACKENDS, PMSIGNAL_ADVANCE_STATE_MACHINE, PMSIGNAL_BACKGROUND_WORKER_CHANGE, PMSIGNAL_BEGIN_HOT_STANDBY, PMSIGNAL_RECOVERY_STARTED, PMSIGNAL_ROTATE_LOGFILE, PMSIGNAL_START_AUTOVAC_LAUNCHER, PMSIGNAL_START_AUTOVAC_WORKER, PMSIGNAL_START_WALRECEIVER, pmState, PostmasterStateMachine(), RemoveLogrotateSignalFiles(), Shutdown, signal_child(), SIGUSR1, SIGUSR2, SmartShutdown, start_autovac_launcher, StartAutovacuumWorker(), StartChildProcess(), StartupPID, StartWorkerNeeded, SysLoggerPID, WalReceiverRequested, and XLogArchivingAlways.
Referenced by ServerLoop().
|
static |
Definition at line 2095 of file postmaster.c.
References AutoVacPID, BgWriterPID, CheckpointerPID, DEBUG2, EnableSSL, ereport, errmsg(), errmsg_internal(), HbaFileName, IdentFileName, load_hba(), load_ident(), LoadedSSL, LOG, pending_pm_reload_request, PgArchPID, PGC_SIGHUP, ProcessConfigFile(), secure_destroy(), secure_initialize(), Shutdown, SIGHUP, signal_child(), SignalChildren, SlotSyncWorkerPID, SmartShutdown, StartupPID, SysLoggerPID, WalReceiverPID, WalSummarizerPID, and WalWriterPID.
Referenced by ServerLoop().
|
static |
Definition at line 2192 of file postmaster.c.
References AbortStartTime, AddToDataDirLockFile(), connsAllowed, DEBUG2, ereport, errmsg(), errmsg_internal(), FastShutdown, ImmediateShutdown, LOCK_FILE_LINE_PM_STATUS, LOG, mode, pending_pm_fast_shutdown_request, pending_pm_immediate_shutdown_request, pending_pm_shutdown_request, PM_HOT_STANDBY, PM_RECOVERY, PM_RUN, PM_STARTUP, PM_STATUS_STOPPING, PM_STOP_BACKENDS, PM_WAIT_BACKENDS, PMQUIT_FOR_STOP, pmState, PostmasterStateMachine(), SetQuitSignalReason(), Shutdown, SIGQUIT, SmartShutdown, and TerminateChildren().
Referenced by ServerLoop().
void processCancelRequest | ( | int | backendPID, |
int32 | cancelAuthCode | ||
) |
Definition at line 1835 of file postmaster.c.
References BackendList, bkend::cancel_key, dlist_iter::cur, DEBUG2, dlist_container, dlist_foreach, ereport, errmsg(), errmsg_internal(), i, LOG, MaxLivePostmasterChildren(), bkend::pid, and signal_child().
Referenced by ProcessStartupPacket().
Definition at line 3868 of file postmaster.c.
References pg_strong_random().
Referenced by assign_backendlist_entry(), BackendStartup(), and StartAutovacuumWorker().
|
static |
Definition at line 3641 of file postmaster.c.
References _, EINTR, pg_set_noblock(), send, snprintf, ClientSocket::sock, and strerror.
Referenced by BackendStartup().
|
static |
Definition at line 1624 of file postmaster.c.
References AbortStartTime, AcceptConnection(), Assert(), AutoVacPID, AutoVacuumingActive(), avlauncher_needs_signal, B_ARCHIVER, B_AUTOVAC_LAUNCHER, B_BG_WRITER, B_CHECKPOINTER, B_WAL_WRITER, BackendStartup(), BgWriterPID, CheckpointerPID, closesocket, ConfigurePostmasterWaitSet(), DetermineSleepTime(), elog, ereport, errmsg(), FatalError, fd(), HaveCrashedWorker, i, ImmediateShutdown, IsBinaryUpgrade, kill, lengthof, LOG, Logging_collector, MAXLISTEN, maybe_start_bgworkers(), MaybeStartSlotSyncWorker(), MaybeStartWalReceiver(), MaybeStartWalSummarizer(), MyLatch, MyProcPid, now(), pending_pm_child_exit, pending_pm_pmsignal, pending_pm_reload_request, pending_pm_shutdown_request, PgArchPID, PgArchStartupAllowed, PGINVALID_SOCKET, PM_HOT_STANDBY, PM_RECOVERY, PM_RUN, PM_STARTUP, pm_wait_set, pmState, process_pm_child_exit(), process_pm_pmsignal(), process_pm_reload_request(), process_pm_shutdown_request(), RecheckDataDirLockFile(), ResetLatch(), SECS_PER_MINUTE, send_abort_for_kill, Shutdown, SIGABRT, SIGKILL, SIGKILL_CHILDREN_AFTER_SECS, SIGQUIT, SIGUSR2, ClientSocket::sock, start_autovac_launcher, StartChildProcess(), StartWorkerNeeded, STATUS_OK, SysLogger_Start(), SysLoggerPID, TerminateChildren(), TouchSocketFiles(), TouchSocketLockFiles(), WaitEventSetWait(), WalReceiverRequested, WalWriterPID, WL_LATCH_SET, and WL_SOCKET_ACCEPT.
Referenced by PostmasterMain().
|
static |
Definition at line 3421 of file postmaster.c.
References DEBUG3, elog, kill, SIGABRT, SIGKILL, and SIGQUIT.
Referenced by PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), process_pm_reload_request(), processCancelRequest(), SignalSomeChildren(), sigquit_child(), and TerminateChildren().
|
static |
Definition at line 3465 of file postmaster.c.
References BACKEND_TYPE_ALL, BACKEND_TYPE_NORMAL, BACKEND_TYPE_WALSND, BackendList, bkend::bkend_type, bkend::child_slot, dlist_iter::cur, bkend::dead_end, DEBUG4, dlist_container, dlist_foreach, ereport, errmsg_internal(), IsPostmasterChildWalSender(), bkend::pid, and signal_child().
Referenced by PostmasterStateMachine().
|
static |
Definition at line 3451 of file postmaster.c.
References DEBUG2, ereport, errmsg_internal(), send_abort_for_crash, SIGABRT, signal_child(), and SIGQUIT.
Referenced by HandleChildCrash().
|
static |
Definition at line 3960 of file postmaster.c.
References AssignPostmasterChildSlot(), AutoVacPID, AutoVacWorkerFailed(), avlauncher_needs_signal, B_AUTOVAC_WORKER, BACKEND_TYPE_AUTOVAC, BackendList, bkend::bgworker_notify, bkend::bkend_type, CAC_OK, canAcceptConnections(), bkend::cancel_key, bkend::child_slot, bkend::dead_end, dlist_push_head(), bkend::elem, ereport, errcode(), errmsg(), LOG, MCXT_ALLOC_NO_OOM, MyCancelKey, MyPMChildSlot, palloc_extended(), pfree(), bkend::pid, RandomCancelKey(), ReleasePostmasterChildSlot(), and StartChildProcess().
Referenced by process_pm_pmsignal().
|
static |
Definition at line 3924 of file postmaster.c.
References B_STARTUP, ereport, errmsg(), ExitPostmaster(), LOG, postmaster_child_launch(), PostmasterChildName(), and type.
Referenced by MaybeStartSlotSyncWorker(), MaybeStartWalReceiver(), MaybeStartWalSummarizer(), PostmasterMain(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), ServerLoop(), and StartAutovacuumWorker().
|
static |
Definition at line 3509 of file postmaster.c.
References AutoVacPID, BgWriterPID, CheckpointerPID, PgArchPID, SIGABRT, SIGKILL, signal_child(), SignalChildren, SIGQUIT, SlotSyncWorkerPID, STARTUP_SIGNALED, StartupPID, StartupStatus, WalReceiverPID, WalSummarizerPID, and WalWriterPID.
Referenced by process_pm_child_exit(), process_pm_shutdown_request(), and ServerLoop().
|
static |
Definition at line 1421 of file postmaster.c.
References external_pid_file.
Referenced by PostmasterMain().
|
static |
Definition at line 343 of file postmaster.c.
Referenced by DetermineSleepTime(), HandleChildCrash(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), process_pm_shutdown_request(), and ServerLoop().
int AuthenticationTimeout = 60 |
Definition at line 228 of file postmaster.c.
Referenced by BackendInitialize(), and PerformAuthentication().
|
static |
Definition at line 247 of file postmaster.c.
Referenced by HandleChildCrash(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_reload_request(), ServerLoop(), StartAutovacuumWorker(), and TerminateChildren().
Definition at line 359 of file postmaster.c.
Referenced by ServerLoop(), and StartAutovacuumWorker().
|
static |
Definition at line 179 of file postmaster.c.
Referenced by BackendStartup(), CleanupBackend(), CountChildren(), do_start_bgworker(), HandleChildCrash(), PostmasterMarkPIDForWorkerNotify(), PostmasterStateMachine(), processCancelRequest(), SignalSomeChildren(), and StartAutovacuumWorker().
|
static |
Definition at line 242 of file postmaster.c.
Referenced by HandleChildCrash(), PostmasterMain(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_reload_request(), ServerLoop(), and TerminateChildren().
char* bonjour_name |
Definition at line 234 of file postmaster.c.
Referenced by PostmasterMain().
|
static |
Definition at line 243 of file postmaster.c.
Referenced by HandleChildCrash(), PostmasterMain(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_reload_request(), ServerLoop(), and TerminateChildren().
Definition at line 350 of file postmaster.c.
Referenced by BackendInitialize(), PerformAuthentication(), ProcessInterrupts(), quickdie(), should_output_to_client(), and StatementTimeoutHandler().
Definition at line 339 of file postmaster.c.
Referenced by canAcceptConnections(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), and process_pm_shutdown_request().
Definition at line 233 of file postmaster.c.
Referenced by PostmasterMain().
Definition at line 225 of file postmaster.c.
Referenced by BackendMain(), parse_hba_line(), PostmasterMain(), and process_pm_reload_request().
Definition at line 271 of file postmaster.c.
Referenced by canAcceptConnections(), HandleChildCrash(), maybe_start_bgworkers(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), and ServerLoop().
Definition at line 366 of file postmaster.c.
Referenced by DetermineSleepTime(), maybe_start_bgworkers(), process_pm_child_exit(), process_pm_pmsignal(), and ServerLoop().
char* ListenAddresses |
Definition at line 196 of file postmaster.c.
Referenced by PostmasterMain().
|
static |
Definition at line 222 of file postmaster.c.
Referenced by ClosePostmasterPorts(), CloseServerPorts(), ConfigurePostmasterWaitSet(), ListenServerPort(), and PostmasterMain().
Definition at line 231 of file postmaster.c.
Referenced by BackendInitialize(), ClientAuthentication(), PerformAuthentication(), and set_authn_id().
bool log_hostname |
Definition at line 230 of file postmaster.c.
Referenced by BackendInitialize().
BackgroundWorker* MyBgworkerEntry = NULL |
Definition at line 185 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().
|
static |
Definition at line 221 of file postmaster.c.
Referenced by ClosePostmasterPorts(), CloseServerPorts(), ConfigurePostmasterWaitSet(), ListenServerPort(), and PostmasterMain().
|
static |
Definition at line 370 of file postmaster.c.
Referenced by handle_pm_child_exit_signal(), process_pm_child_exit(), and ServerLoop().
|
static |
Definition at line 373 of file postmaster.c.
Referenced by handle_pm_shutdown_request_signal(), and process_pm_shutdown_request().
|
static |
Definition at line 374 of file postmaster.c.
Referenced by handle_pm_shutdown_request_signal(), and process_pm_shutdown_request().
|
static |
Definition at line 369 of file postmaster.c.
Referenced by handle_pm_pmsignal_signal(), process_pm_pmsignal(), and ServerLoop().
|
static |
Definition at line 371 of file postmaster.c.
Referenced by handle_pm_reload_request_signal(), process_pm_reload_request(), and ServerLoop().
|
static |
Definition at line 372 of file postmaster.c.
Referenced by handle_pm_shutdown_request_signal(), process_pm_shutdown_request(), and ServerLoop().
|
static |
Definition at line 248 of file postmaster.c.
Referenced by HandleChildCrash(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), process_pm_reload_request(), ServerLoop(), and TerminateChildren().
|
static |
Definition at line 377 of file postmaster.c.
Referenced by ClosePostmasterPorts(), ConfigurePostmasterWaitSet(), and ServerLoop().
Definition at line 331 of file postmaster.c.
Referenced by bgworker_should_start_now(), canAcceptConnections(), HandleChildCrash(), MaybeStartSlotSyncWorker(), MaybeStartWalReceiver(), MaybeStartWalSummarizer(), PostmasterMain(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), process_pm_shutdown_request(), and ServerLoop().
int postmaster_alive_fds[2] = {-1, -1} |
Definition at line 479 of file postmaster.c.
Referenced by AddWaitEventToSet(), ClosePostmasterPorts(), InitPostmasterChild(), InitPostmasterDeathWatchHandle(), and PostmasterIsAliveInternal().
int PostPortNumber = DEF_PGPORT |
Definition at line 190 of file postmaster.c.
Referenced by CreateLockFile(), and PostmasterMain().
int PreAuthDelay = 0 |
Definition at line 227 of file postmaster.c.
Referenced by BackendInitialize().
Definition at line 348 of file postmaster.c.
Referenced by process_pm_child_exit().
Definition at line 353 of file postmaster.c.
Referenced by send_message_to_server_log(), SysLogger_Start(), SysLoggerMain(), and write_console().
Definition at line 236 of file postmaster.c.
Referenced by PostmasterStateMachine().
int ReservedConnections |
Definition at line 217 of file postmaster.c.
Referenced by InitPostgres(), and PostmasterMain().
Definition at line 235 of file postmaster.c.
Referenced by PostmasterStateMachine().
Definition at line 237 of file postmaster.c.
Referenced by sigquit_child().
Definition at line 238 of file postmaster.c.
Referenced by ServerLoop().
|
static |
Definition at line 269 of file postmaster.c.
Referenced by canAcceptConnections(), DetermineSleepTime(), HandleChildCrash(), MaybeStartSlotSyncWorker(), MaybeStartWalReceiver(), MaybeStartWalSummarizer(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), process_pm_reload_request(), process_pm_shutdown_request(), and ServerLoop().
|
static |
Definition at line 250 of file postmaster.c.
Referenced by HandleChildCrash(), MaybeStartSlotSyncWorker(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_reload_request(), and TerminateChildren().
Definition at line 356 of file postmaster.c.
Referenced by process_pm_pmsignal(), and ServerLoop().
|
static |
Definition at line 241 of file postmaster.c.
Referenced by HandleChildCrash(), PostmasterMain(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_pmsignal(), process_pm_reload_request(), and TerminateChildren().
|
static |
Definition at line 261 of file postmaster.c.
Referenced by HandleChildCrash(), PostmasterMain(), PostmasterStateMachine(), process_pm_child_exit(), and TerminateChildren().
Definition at line 365 of file postmaster.c.
Referenced by DetermineSleepTime(), maybe_start_bgworkers(), process_pm_pmsignal(), and ServerLoop().
int SuperuserReservedConnections |
Definition at line 216 of file postmaster.c.
Referenced by InitPostgres(), and PostmasterMain().
|
static |
Definition at line 249 of file postmaster.c.
Referenced by PostmasterMain(), process_pm_child_exit(), process_pm_pmsignal(), process_pm_reload_request(), and ServerLoop().
char* Unix_socket_directories |
Definition at line 193 of file postmaster.c.
Referenced by PostmasterMain().
|
static |
Definition at line 245 of file postmaster.c.
Referenced by HandleChildCrash(), MaybeStartWalReceiver(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_reload_request(), and TerminateChildren().
Definition at line 362 of file postmaster.c.
Referenced by MaybeStartWalReceiver(), process_pm_pmsignal(), and ServerLoop().
|
static |
Definition at line 246 of file postmaster.c.
Referenced by HandleChildCrash(), MaybeStartWalSummarizer(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_reload_request(), and TerminateChildren().
|
static |
Definition at line 244 of file postmaster.c.
Referenced by HandleChildCrash(), PostmasterStateMachine(), process_pm_child_exit(), process_pm_reload_request(), ServerLoop(), and TerminateChildren().