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/transam.h"
#include "access/xlog.h"
#include "bootstrap/bootstrap.h"
#include "catalog/pg_control.h"
#include "common/file_perm.h"
#include "common/ip.h"
#include "common/string.h"
#include "lib/ilist.h"
#include "libpq/auth.h"
#include "libpq/libpq.h"
#include "libpq/pqformat.h"
#include "libpq/pqsignal.h"
#include "pg_getopt.h"
#include "pgstat.h"
#include "port/pg_bswap.h"
#include "postmaster/autovacuum.h"
#include "postmaster/bgworker_internals.h"
#include "postmaster/fork_process.h"
#include "postmaster/interrupt.h"
#include "postmaster/pgarch.h"
#include "postmaster/postmaster.h"
#include "postmaster/syslogger.h"
#include "replication/logicallauncher.h"
#include "replication/walsender.h"
#include "storage/fd.h"
#include "storage/ipc.h"
#include "storage/pg_shmem.h"
#include "storage/pmsignal.h"
#include "storage/proc.h"
#include "tcop/tcopprot.h"
#include "utils/builtins.h"
#include "utils/datetime.h"
#include "utils/memutils.h"
#include "utils/pidfile.h"
#include "utils/ps_status.h"
#include "utils/timeout.h"
#include "utils/timestamp.h"
#include "utils/varlena.h"
Go to the source code of this file.
Data Structures | |
struct | bkend |
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 } |
enum | ConnsAllowedState { ALLOW_ALL_CONNS, ALLOW_SUPERUSER_CONNS, ALLOW_NO_CONNS } |
#define BACKEND_TYPE_ALL 0x000F /* OR of all the above */ |
Definition at line 149 of file postmaster.c.
Referenced by canAcceptConnections(), CountChildren(), PostmasterStateMachine(), and SignalSomeChildren().
#define BACKEND_TYPE_AUTOVAC 0x0002 /* autovacuum worker process */ |
Definition at line 146 of file postmaster.c.
Referenced by StartAutovacuumWorker().
#define BACKEND_TYPE_BGWORKER 0x0008 /* bgworker process */ |
Definition at line 148 of file postmaster.c.
Referenced by assign_backendlist_entry(), canAcceptConnections(), and HandleChildCrash().
#define BACKEND_TYPE_NORMAL 0x0001 /* normal backend */ |
Definition at line 145 of file postmaster.c.
Referenced by BackendStartup(), canAcceptConnections(), CountChildren(), PostmasterStateMachine(), and SignalSomeChildren().
#define BACKEND_TYPE_WALSND 0x0004 /* walsender process */ |
Definition at line 147 of file postmaster.c.
Referenced by CountChildren(), PostmasterStateMachine(), and SignalSomeChildren().
#define EXIT_STATUS_0 | ( | st | ) | ((st) == 0) |
Definition at line 557 of file postmaster.c.
Referenced by CleanupBackend(), CleanupBackgroundWorker(), LogChildExit(), and reaper().
#define EXIT_STATUS_1 | ( | st | ) | (WIFEXITED(st) && WEXITSTATUS(st) == 1) |
Definition at line 558 of file postmaster.c.
Referenced by CleanupBackend(), CleanupBackgroundWorker(), and reaper().
#define EXIT_STATUS_3 | ( | st | ) | (WIFEXITED(st) && WEXITSTATUS(st) == 3) |
Definition at line 559 of file postmaster.c.
Referenced by reaper().
#define FastShutdown 2 |
Definition at line 271 of file postmaster.c.
Referenced by pmdie().
#define ImmediateShutdown 3 |
Definition at line 272 of file postmaster.c.
Referenced by HandleChildCrash(), pmdie(), PostmasterStateMachine(), and ServerLoop().
#define MAX_BGWORKERS_TO_LAUNCH 100 |
Referenced by maybe_start_bgworkers().
#define MAXLISTEN 64 |
Definition at line 219 of file postmaster.c.
Referenced by ClosePostmasterPorts(), CloseServerPorts(), initMasks(), PostmasterMain(), and ServerLoop().
#define NoShutdown 0 |
Definition at line 269 of file postmaster.c.
Referenced by canAcceptConnections(), DetermineSleepTime(), PostmasterStateMachine(), reaper(), and sigusr1_handler().
#define OPTS_FILE "postmaster.opts" |
Referenced by CreateOptsFile().
#define PgArchStartupAllowed | ( | ) |
Definition at line 445 of file postmaster.c.
Referenced by reaper(), and ServerLoop().
#define SIGKILL_CHILDREN_AFTER_SECS 5 |
Definition at line 358 of file postmaster.c.
Referenced by DetermineSleepTime(), and ServerLoop().
#define SignalChildren | ( | sig | ) | SignalSomeChildren(sig, BACKEND_TYPE_ALL) |
Definition at line 428 of file postmaster.c.
Referenced by PostmasterStateMachine(), reaper(), SIGHUP_handler(), and TerminateChildren().
#define SmartShutdown 1 |
Definition at line 270 of file postmaster.c.
Referenced by MaybeStartWalReceiver(), pmdie(), reaper(), SIGHUP_handler(), and sigusr1_handler().
#define StartBackgroundWriter | ( | ) | StartChildProcess(BgWriterProcess) |
Definition at line 551 of file postmaster.c.
Referenced by reaper(), ServerLoop(), and sigusr1_handler().
#define StartCheckpointer | ( | ) | StartChildProcess(CheckpointerProcess) |
Definition at line 552 of file postmaster.c.
Referenced by PostmasterStateMachine(), reaper(), ServerLoop(), and sigusr1_handler().
#define StartupDataBase | ( | ) | StartChildProcess(StartupProcess) |
Definition at line 550 of file postmaster.c.
Referenced by PostmasterMain(), and PostmasterStateMachine().
#define StartWalReceiver | ( | ) | StartChildProcess(WalReceiverProcess) |
Definition at line 554 of file postmaster.c.
Referenced by MaybeStartWalReceiver().
#define StartWalWriter | ( | ) | StartChildProcess(WalWriterProcess) |
Definition at line 553 of file postmaster.c.
Referenced by reaper(), and ServerLoop().
enum ConnsAllowedState |
Enumerator | |
---|---|
ALLOW_ALL_CONNS | |
ALLOW_SUPERUSER_CONNS | |
ALLOW_NO_CONNS |
Definition at line 344 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 319 of file postmaster.c.
enum StartupStatusEnum |
Enumerator | |
---|---|
STARTUP_NOT_RUNNING | |
STARTUP_RUNNING | |
STARTUP_SIGNALED | |
STARTUP_CRASHED |
Definition at line 258 of file postmaster.c.
|
static |
Definition at line 5882 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, malloc, MyCancelKey, MyPMChildSlot, RandomCancelKey(), RegisteredBgWorker::rw_backend, and RegisteredBgWorker::rw_child_slot.
Referenced by do_start_bgworker().
|
static |
Definition at line 4270 of file postmaster.c.
References SockAddr::addr, am_walsender, appendStringInfo(), AuthenticationTimeout, B_WAL_SENDER, BlockSig, check_on_shmem_exit_lists_are_empty(), ClientAuthInProgress, StringInfoData::data, Port::database_name, DestRemote, disable_timeout(), enable_timeout_after(), ereport, errmsg(), errmsg_internal(), gai_strerror, GetBackendTypeDesc(), init_ps_display(), InitializeTimeouts(), initStringInfo(), LOG, Log_connections, log_hostname, MyProcPort, NI_MAXHOST, NI_MAXSERV, NI_NUMERICHOST, NI_NUMERICSERV, pfree(), pg_getnameinfo_all(), PG_SETMASK, pg_usleep(), port, pq_init(), pqsignal(), PreAuthDelay, proc_exit(), process_startup_packet_die(), ProcessStartupPacket(), Port::raddr, RegisterTimeout(), Port::remote_host, Port::remote_hostname, Port::remote_port, ReserveExternalFD(), SockAddr::salen, set_ps_display(), STARTUP_PACKET_TIMEOUT, StartupBlockSig, StartupPacketTimeoutHandler(), status(), STATUS_OK, Port::user_name, WARNING, and whereToSendOutput.
Referenced by BackendRun(), and BackendStartup().
|
static |
Definition at line 4450 of file postmaster.c.
References AllocateFile(), Assert, AutoVacLauncherMain(), AutoVacWorkerMain(), AuxiliaryProcessMain(), av, BackendInitialize(), checkDataDir(), ClosePostmasterPorts(), CreateSharedMemoryAndSemaphores(), Port::database_name, DestNone, elog, EnableSSL, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), errmsg_internal(), FATAL, fork_process(), FreeFile(), i, InitAuxiliaryProcess(), InitializeGUCOptions(), InitPostmasterChild(), InitProcess(), InitShmemAccess(), IsBackgroundWorker, IsPostmasterEnvironment, lengthof, LocalProcessControlFile(), LOG, MakePGDirectory(), malloc, MAXPGPATH, MemoryContextSwitchTo(), MyProcPid, PG_BINARY_W, PG_TEMP_FILE_PREFIX, PG_TEMP_FILES_DIR, PgArchiverMain(), PGSharedMemoryNoReAttach(), PGSharedMemoryReAttach(), PgstatCollectorMain(), pgwin32_ReserveSharedMemoryRegion(), pgwin32_signal_initialize(), bkend::pid, port, PostgresMain(), process_shared_preload_libraries(), secure_initialize(), snprintf, sprintf, StartBackgroundWorker(), SysLoggerMain(), TopMemoryContext, UsedShmemSegAddr, Port::user_name, and whereToSendOutput.
Referenced by BackendStartup().
|
static |
Definition at line 4118 of file postmaster.c.
References AssignPostmasterChildSlot(), BACKEND_TYPE_NORMAL, BackendInitialize(), BackendRun(), bkend::bgworker_notify, bkend::bkend_type, CAC_OK, CAC_SUPERUSER, Port::canAcceptConnections, canAcceptConnections(), bkend::cancel_key, bkend::child_slot, ClosePostmasterPorts(), bkend::dead_end, DEBUG2, dlist_push_head(), bkend::elem, ereport, errcode(), errmsg(), errmsg_internal(), fork_process(), free, InitPostmasterChild(), LOG, malloc, MyCancelKey, MyPMChildSlot, bkend::pid, RandomCancelKey(), ReleasePostmasterChildSlot(), report_fork_failure_to_client(), Port::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 5659 of file postmaster.c.
References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_BYPASS_ALLOWCONN, ereport, errcode(), errmsg(), ERROR, FATAL, InitPostgres(), InvalidOid, IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, and SetProcessingMode.
Referenced by ApplyLauncherMain(), and initialize_worker_spi().
Definition at line 5682 of file postmaster.c.
References BackgroundWorker::bgw_flags, BGWORKER_BACKEND_DATABASE_CONNECTION, BGWORKER_BYPASS_ALLOWCONN, ereport, errcode(), errmsg(), ERROR, FATAL, InitPostgres(), IsInitProcessingMode, MyBgworkerEntry, NormalProcessing, and SetProcessingMode.
Referenced by ApplyWorkerMain(), autoprewarm_database_main(), and ParallelWorkerMain().
void BackgroundWorkerUnblockSignals | ( | void | ) |
Definition at line 5711 of file postmaster.c.
References Assert, av, lengthof, MAXPGPATH, PG_SETMASK, snprintf, and UnBlockSig.
Referenced by ApplyLauncherMain(), ApplyWorkerMain(), autoprewarm_database_main(), autoprewarm_main(), initialize_worker_spi(), ParallelWorkerMain(), StartBackgroundWorker(), and test_shm_mq_main().
|
static |
Definition at line 5839 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, and pmState.
Referenced by maybe_start_bgworkers().
|
static |
Definition at line 2420 of file postmaster.c.
References ALLOW_ALL_CONNS, ALLOW_SUPERUSER_CONNS, BACKEND_TYPE_ALL, BACKEND_TYPE_BGWORKER, BACKEND_TYPE_NORMAL, CAC_OK, CAC_RECOVERY, CAC_SHUTDOWN, CAC_STARTUP, CAC_SUPERUSER, 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 1523 of file postmaster.c.
References AllocateFile(), DataDir, ExitPostmaster(), FreeFile(), MAXPGPATH, PG_BINARY_R, progname, snprintf, strerror, and write_stderr.
Referenced by PostmasterMain().
|
static |
Definition at line 3328 of file postmaster.c.
References _, BackgroundWorkerStopNotifications(), bkend::bgworker_notify, bkend::child_slot, dlist_mutable_iter::cur, bkend::dead_end, DEBUG2, dlist_container, dlist_delete(), dlist_foreach_modify, bkend::elem, EXIT_STATUS_0, EXIT_STATUS_1, free, HandleChildCrash(), LOG, LogChildExit(), bkend::pid, and ReleasePostmasterChildSlot().
Referenced by reaper().
|
static |
Definition at line 3228 of file postmaster.c.
References _, BackgroundWorkerList, BackgroundWorkerStopNotifications(), BackgroundWorker::bgw_flags, BackgroundWorker::bgw_type, bkend::bgworker_notify, BGWORKER_SHMEM_ACCESS, slist_mutable_iter::cur, DEBUG1, dlist_delete(), bkend::elem, EXIT_STATUS_0, EXIT_STATUS_1, free, GetCurrentTimestamp(), HandleChildCrash(), LOG, LogChildExit(), MAXPGPATH, 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 reaper().
void ClosePostmasterPorts | ( | bool | am_syslogger | ) |
Definition at line 2532 of file postmaster.c.
References close, ereport, errcode_for_file_access(), errmsg_internal(), FATAL, i, ListenSocket, MAXLISTEN, PGINVALID_SOCKET, postmaster_alive_fds, POSTMASTER_FD_OWN, ReleaseExternalFD(), StreamClose(), and syslogPipe.
Referenced by BackendRun(), BackendStartup(), do_start_bgworker(), pgarch_start(), pgstat_start(), StartAutoVacWorker(), StartChildProcess(), and SysLogger_Start().
|
static |
Definition at line 1421 of file postmaster.c.
References i, ListenSocket, MAXLISTEN, PGINVALID_SOCKET, RemoveSocketFiles(), and StreamClose().
Referenced by PostmasterMain().
|
static |
Definition at line 2484 of file postmaster.c.
References calloc, ConnFree(), ereport, errcode(), errmsg(), ExitPostmaster(), LOG, PGINVALID_SOCKET, port, Port::sock, STATUS_OK, StreamClose(), and StreamConnection().
Referenced by ServerLoop().
|
static |
Definition at line 2515 of file postmaster.c.
References free.
Referenced by ConnCreate(), and ServerLoop().
|
static |
Definition at line 5345 of file postmaster.c.
References BACKEND_TYPE_ALL, BACKEND_TYPE_NORMAL, BACKEND_TYPE_WALSND, bkend::bkend_type, bkend::child_slot, dlist_iter::cur, bkend::dead_end, dlist_container, dlist_foreach, bkend::elem, and IsPostmasterChildWalSender().
Referenced by canAcceptConnections(), and PostmasterStateMachine().
|
static |
Definition at line 5605 of file postmaster.c.
References ereport, errcode_for_file_access(), errmsg(), fprintf, i, LOG, and OPTS_FILE.
Referenced by PostmasterMain().
|
static |
Definition at line 1552 of file postmaster.c.
References AbortStartTime, BackgroundWorkerList, BGW_NEVER_RESTART, BackgroundWorker::bgw_restart_time, slist_mutable_iter::cur, ForgetBackgroundWorker(), GetCurrentTimestamp(), HaveCrashedWorker, Max, NoShutdown, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_terminate, RegisteredBgWorker::rw_worker, Shutdown, SIGKILL_CHILDREN_AFTER_SECS, slist_container, slist_foreach_modify, StartWorkerNeeded, TimestampDifference(), and TimestampTzPlusMilliseconds.
Referenced by ServerLoop().
|
static |
Definition at line 5747 of file postmaster.c.
References Assert, assign_backendlist_entry(), BackgroundWorker::bgw_name, ClosePostmasterPorts(), DEBUG1, dlist_push_head(), bkend::elem, ereport, errmsg(), errmsg_internal(), fork_process(), free, GetCurrentTimestamp(), InitPostmasterChild(), LOG, MemoryContextAlloc(), MemoryContextDelete(), MemoryContextSwitchTo(), bkend::pid, PostmasterContext, ReleasePostmasterChildSlot(), ReportBackgroundWorkerPID(), RegisteredBgWorker::rw_backend, RegisteredBgWorker::rw_child_slot, RegisteredBgWorker::rw_crashed_at, RegisteredBgWorker::rw_pid, RegisteredBgWorker::rw_shmem_slot, RegisteredBgWorker::rw_worker, StartBackgroundWorker(), and TopMemoryContext.
Referenced by maybe_start_bgworkers().
|
static |
|
static |
Definition at line 5070 of file postmaster.c.
References ereport, errcode(), errdetail(), errmsg_internal(), LOG, and proc_exit().
Referenced by checkControlFile(), ConnCreate(), PostmasterMain(), PostmasterStateMachine(), reaper(), and StartChildProcess().
|
static |
Definition at line 1469 of file postmaster.c.
References AllocateDir(), 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 3412 of file postmaster.c.
References AbortStartTime, allow_immediate_pgstat_restart(), AutoVacPID, BACKEND_TYPE_BGWORKER, BackgroundWorkerList, BgWriterPID, bkend::bkend_type, CheckpointerPID, bkend::child_slot, dlist_mutable_iter::cur, slist_iter::cur, bkend::dead_end, DEBUG2, dlist_container, dlist_delete(), dlist_foreach_modify, bkend::elem, ereport, errmsg(), errmsg_internal(), FatalError, free, ImmediateShutdown, LOG, LogChildExit(), PgArchPID, PgStatPID, 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, SendStop, SetQuitSignalReason(), Shutdown, signal_child(), SIGQUIT, SIGSTOP, slist_container, slist_foreach, STARTUP_SIGNALED, StartupPID, StartupStatus, WalReceiverPID, and WalWriterPID.
Referenced by CleanupBackend(), CleanupBackgroundWorker(), and reaper().
|
static |
Definition at line 1892 of file postmaster.c.
References fd(), i, ListenSocket, MAXLISTEN, and PGINVALID_SOCKET.
Referenced by ServerLoop().
|
static |
Definition at line 6545 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 2596 of file postmaster.c.
References GetCurrentTimestamp(), MyProcPid, MyStartTime, MyStartTimestamp, pg_strong_random(), srandom(), and timestamptz_to_time_t().
Referenced by InitPostmasterChild(), InitStandaloneProcess(), and PostmasterMain().
|
static |
Definition at line 3668 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 reaper().
int MaxLivePostmasterChildren | ( | void | ) |
Definition at line 5649 of file postmaster.c.
References autovacuum_max_workers, max_wal_senders, max_worker_processes, and MaxConnections.
Referenced by canAcceptConnections(), PMSignalShmemInit(), PMSignalShmemSize(), PostmasterMarkPIDForWorkerNotify(), and processCancelRequest().
|
static |
Definition at line 5946 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(), reaper(), ServerLoop(), and sigusr1_handler().
|
static |
Definition at line 5586 of file postmaster.c.
References PM_HOT_STANDBY, PM_RECOVERY, PM_STARTUP, pmState, Shutdown, SmartShutdown, StartWalReceiver, WalReceiverPID, and WalReceiverRequested.
Referenced by ServerLoop(), and sigusr1_handler().
|
static |
Definition at line 2729 of file postmaster.c.
References AbortStartTime, AddToDataDirLockFile(), ALLOW_NO_CONNS, ALLOW_SUPERUSER_CONNS, BlockSig, connsAllowed, DEBUG2, ereport, errmsg(), errmsg_internal(), FastShutdown, ImmediateShutdown, LOCK_FILE_LINE_PM_STATUS, LOG, PG_SETMASK, 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, TerminateChildren(), and UnBlockSig.
Referenced by PostmasterMain().
void PostmasterMain | ( | int | argc, |
char * | argv[] | ||
) |
Definition at line 576 of file postmaster.c.
References AddToDataDirLockFile(), ALLOCSET_DEFAULT_SIZES, AllocSetContextCreate, ApplyLauncherRegister(), ARCHIVE_MODE_OFF, Assert, autovac_init(), BlockSig, bonjour_name, ChangeToDataDir(), checkControlFile(), checkDataDir(), CheckDateTokenTables(), CloseServerPorts(), CreateDataDirLockFile(), CreateOptsFile(), DEBUG3, DestNone, dummy_handler(), enable_bonjour, EnableSSL, environ, ereport, errcode(), errcode_for_file_access(), errhint(), errmsg(), errmsg_internal(), ERROR, ExitPostmaster(), external_pid_file, FATAL, fprintf, free, get_stats_option_name(), GetConfigOption(), GetCurrentTimestamp(), getInstallationPaths(), getopt(), i, InitializeGUCOptions(), InitializeMaxBackends(), InitPostmasterDeathWatchHandle(), InitProcessGlobals(), IsBinaryUpgrade, IsPostmasterEnvironment, lfirst, list_free(), list_free_deep(), ListenAddresses, ListenSocket, load_hba(), load_ident(), 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, on_proc_exit(), optarg, opterr, optind, ParseLongOption(), pfree(), pg_hton16, PG_MODE_MASK_OWNER, PG_SETMASK, PG_TEMP_FILES_DIR, PGC_POSTMASTER, PGC_S_ARGV, PGINVALID_SOCKET, PgStartTime, pgstat_init(), PM_STARTUP, PM_STATUS_STARTING, pmdie(), pmState, PostmasterContext, PostmasterPid, PostPortNumber, pqinitmask(), pqsignal_pm(), process_shared_preload_libraries(), progname, pstrdup(), reaper(), Reinit, RemoveLogrotateSignalFiles(), RemovePgTempFiles(), RemovePgTempFilesInDir(), RemovePromoteSignalFiles(), ReservedBackends, reset_shared(), S_IRGRP, S_IROTH, S_IRUSR, S_IWUSR, secure_initialize(), SelectConfigFiles(), SendStop, ServerLoop(), set_debug_options(), set_max_safe_fds(), set_plan_disabling_options(), set_stack_base(), SetConfigOption(), SIG_IGN, SIGALRM, SIGCHLD, SIGHUP, SIGHUP_handler(), SIGPIPE, SIGQUIT, SIGUSR1, sigusr1_handler(), SIGUSR2, SplitDirectoriesString(), SplitGUCList(), STARTUP_RUNNING, StartupDataBase, StartupPID, StartupStatus, status(), STATUS_OK, StreamServerPort(), strerror, success, SysLogger_Start(), SysLoggerPID, TopMemoryContext, 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 6065 of file postmaster.c.
References AllocateFile(), Assert, AuxiliaryProcs, bkend::bgworker_notify, bkend::child_slot, closesocket, dlist_iter::cur, DataDir, generate_unaccent_rules::dest, dlist_container, dlist_foreach, bkend::elem, ereport, errmsg(), errmsg_internal(), first_syslogger_file_time, free, FreeFile(), i, IsBinaryUpgrade, sort-test::key, ListenSocket, LOG, MainLWLockArray, max_safe_fds, MaxBackends, MaxLivePostmasterChildren(), MAXPGPATH, mul_size(), my_exec_path, MyCancelKey, MyPMChildSlot, NamedLWLockTrancheArray, NamedLWLockTrancheRequests, PG_BINARY_R, pg_queue_signal(), PGINVALID_SOCKET, PgReloadTime, PgStartTime, pgStatSock, pgwin32_create_signal_listener(), pgwin32_initial_signal_pipe, bkend::pid, pkglib_path, PMSignalState, postmaster_alive_fds, PostmasterPid, PreparedXactProcs, ProcGlobal, ProcStructLock, redirection_done, ReserveExternalFD(), SetDataDir(), ShmemAlloc(), ShmemLock, ShmemProtectiveRegion, ShmemVariableCache, SIGCHLD, Port::sock, SpinlockSemaArray, strerror, strlcpy(), syslogPipe, UsedShmemSegAddr, UsedShmemSegID, and write_stderr.
Referenced by BackgroundWorkerStateChange().
|
static |
Definition at line 3733 of file postmaster.c.
References AbortStartTime, ALLOW_NO_CONNS, ALLOW_SUPERUSER_CONNS, Assert, AutoVacPID, BACKEND_TYPE_ALL, BACKEND_TYPE_NORMAL, BACKEND_TYPE_WALSND, BackupInProgress(), BgWriterPID, CancelBackup(), CheckpointerPID, connsAllowed, CountChildren(), dlist_is_empty(), ereport, errmsg(), ExitPostmaster(), FatalError, ForgetUnstartedBackgroundWorkers(), ImmediateShutdown, LocalProcessControlFile(), LOG, NoShutdown, PgArchPID, PgStatPID, 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, ReachedNormalRunning, reset_shared(), ResetBackgroundWorkerCrashTimes(), restart_after_crash, shmem_exit(), Shutdown, signal_child(), SignalChildren, SignalSomeChildren(), SIGQUIT, SIGUSR2, StartCheckpointer, STARTUP_CRASHED, STARTUP_RUNNING, StartupDataBase, StartupPID, StartupStatus, WalReceiverPID, and WalWriterPID.
Referenced by pmdie(), reaper(), and sigusr1_handler().
|
static |
Definition at line 5301 of file postmaster.c.
Referenced by BackendInitialize().
|
static |
Definition at line 2354 of file postmaster.c.
References CancelRequestPacket::backendPID, bkend::cancel_key, CancelRequestPacket::cancelAuthCode, dlist_iter::cur, DEBUG2, dlist_container, dlist_foreach, bkend::elem, ereport, errmsg(), errmsg_internal(), i, LOG, MaxLivePostmasterChildren(), pg_ntoh32, bkend::pid, and signal_child().
Referenced by ProcessStartupPacket().
Definition at line 1934 of file postmaster.c.
References SockAddr::addr, am_db_walsender, am_walsender, Port::application_name, B_BACKEND, B_WAL_SENDER, buf, CAC_OK, CAC_RECOVERY, CAC_SHUTDOWN, CAC_STARTUP, CAC_SUPERUSER, CAC_TOOMANY, Port::canAcceptConnections, CANCEL_REQUEST_CODE, Port::cmdline_options, COMMERROR, Port::database_name, Db_user_namespace, EINTR, ereport, errcode(), ERRCODE_CANNOT_CONNECT_NOW, errcode_for_socket_access(), errhint(), errmsg(), FATAL, FrontendProtocol, Port::guc_options, IS_AF_UNIX, Port::laddr, lappend(), MAX_STARTUP_PACKET_LENGTH, MemoryContextSwitchTo(), MyBackendType, NAMEDATALEN, NEGOTIATE_GSS_CODE, NEGOTIATE_SSL_CODE, NIL, palloc(), parse_bool(), pg_clean_ascii(), pg_ntoh32, PG_PROTOCOL_EARLIEST, PG_PROTOCOL_LATEST, PG_PROTOCOL_MAJOR, PG_PROTOCOL_MINOR, pq_endmsgread(), pq_getbytes(), pq_startmsgread(), processCancelRequest(), Port::proto, psprintf(), pstrdup(), secure_open_gssapi(), secure_open_server(), send, SendNegotiateProtocolVersion(), Port::sock, STATUS_ERROR, STATUS_OK, TopMemoryContext, and Port::user_name.
Referenced by BackendInitialize().