PostgreSQL Source Code  git master
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros
startup.h File Reference
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Functions

void HandleStartupProcInterrupts (void)
 
void StartupProcessMain (void) pg_attribute_noreturn()
 
void PreRestoreCommand (void)
 
void PostRestoreCommand (void)
 
bool IsPromoteTriggered (void)
 
void ResetPromoteTriggered (void)
 

Function Documentation

void HandleStartupProcInterrupts ( void  )

Definition at line 147 of file startup.c.

References got_SIGHUP, IsUnderPostmaster, PGC_SIGHUP, PostmasterIsAlive(), proc_exit(), ProcessConfigFile(), and shutdown_requested.

Referenced by recoveryApplyDelay(), recoveryPausesHere(), ShutdownWalRcv(), StartupXLOG(), and WaitForWALToBecomeAvailable().

148 {
149  /*
150  * Check if we were requested to re-read config file.
151  */
152  if (got_SIGHUP)
153  {
154  got_SIGHUP = false;
156  }
157 
158  /*
159  * Check if we were requested to exit without finishing recovery.
160  */
161  if (shutdown_requested)
162  proc_exit(1);
163 
164  /*
165  * Emergency bailout if postmaster has died. This is to avoid the
166  * necessity for manual cleanup of all postmaster children.
167  */
169  exit(1);
170 }
void ProcessConfigFile(GucContext context)
static volatile sig_atomic_t shutdown_requested
Definition: startup.c:41
void proc_exit(int code)
Definition: ipc.c:99
static volatile sig_atomic_t got_SIGHUP
Definition: startup.c:40
bool IsUnderPostmaster
Definition: globals.c:100
bool PostmasterIsAlive(void)
Definition: pmsignal.c:272
Definition: guc.h:72
bool IsPromoteTriggered ( void  )

Definition at line 246 of file startup.c.

References promote_triggered.

Referenced by CheckForStandbyTrigger().

247 {
248  return promote_triggered;
249 }
static volatile sig_atomic_t promote_triggered
Definition: startup.c:42
void PostRestoreCommand ( void  )

Definition at line 240 of file startup.c.

References in_restore_command.

Referenced by RestoreArchivedFile().

241 {
242  in_restore_command = false;
243 }
static volatile sig_atomic_t in_restore_command
Definition: startup.c:48
void PreRestoreCommand ( void  )

Definition at line 226 of file startup.c.

References in_restore_command, proc_exit(), and shutdown_requested.

Referenced by RestoreArchivedFile().

227 {
228  /*
229  * Set in_restore_command to tell the signal handler that we should exit
230  * right away on SIGTERM. We know that we're at a safe point to do that.
231  * Check if we had already received the signal, so that we don't miss a
232  * shutdown request received just before this.
233  */
234  in_restore_command = true;
235  if (shutdown_requested)
236  proc_exit(1);
237 }
static volatile sig_atomic_t shutdown_requested
Definition: startup.c:41
void proc_exit(int code)
Definition: ipc.c:99
static volatile sig_atomic_t in_restore_command
Definition: startup.c:48
void ResetPromoteTriggered ( void  )

Definition at line 252 of file startup.c.

References promote_triggered.

Referenced by CheckForStandbyTrigger().

253 {
254  promote_triggered = false;
255 }
static volatile sig_atomic_t promote_triggered
Definition: startup.c:42
void StartupProcessMain ( void  )

Definition at line 178 of file startup.c.

References InitializeTimeouts(), PG_SETMASK, pqsignal(), proc_exit(), RegisterTimeout(), SIG_DFL, SIG_IGN, SIGCHLD, SIGCONT, SIGHUP, SIGPIPE, SIGQUIT, SIGTTIN, SIGTTOU, SIGUSR1, SIGUSR2, SIGWINCH, STANDBY_DEADLOCK_TIMEOUT, STANDBY_LOCK_TIMEOUT, STANDBY_TIMEOUT, StandbyDeadLockHandler(), StandbyLockTimeoutHandler(), StandbyTimeoutHandler(), startupproc_quickdie(), StartupProcShutdownHandler(), StartupProcSigHupHandler(), StartupProcSigUsr1Handler(), StartupProcTriggerHandler(), StartupXLOG(), and UnBlockSig.

Referenced by AuxiliaryProcessMain().

179 {
180  /*
181  * Properly accept or ignore signals the postmaster might send us.
182  */
183  pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
184  pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
185  pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
186  pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
187  InitializeTimeouts(); /* establishes SIGALRM handler */
191 
192  /*
193  * Reset some signals that are accepted by postmaster but not here
194  */
200 
201  /*
202  * Register timeouts needed for standby mode
203  */
207 
208  /*
209  * Unblock signals (they were blocked when the postmaster forked us)
210  */
212 
213  /*
214  * Do what we came for.
215  */
216  StartupXLOG();
217 
218  /*
219  * Exit normally. Exit code 0 tells postmaster that we completed recovery
220  * successfully.
221  */
222  proc_exit(0);
223 }
void InitializeTimeouts(void)
Definition: timeout.c:340
#define SIGUSR1
Definition: win32.h:211
void StandbyTimeoutHandler(void)
Definition: standby.c:558
static void startupproc_quickdie(SIGNAL_ARGS)
Definition: startup.c:69
#define SIGCONT
Definition: win32.h:205
#define SIGWINCH
Definition: win32.h:209
#define SIGTTIN
Definition: win32.h:207
void proc_exit(int code)
Definition: ipc.c:99
#define SIGQUIT
Definition: win32.h:197
#define PG_SETMASK(mask)
Definition: pqsignal.h:19
#define SIG_IGN
Definition: win32.h:193
static void StartupProcSigHupHandler(SIGNAL_ARGS)
Definition: startup.c:120
void StandbyLockTimeoutHandler(void)
Definition: standby.c:571
void StandbyDeadLockHandler(void)
Definition: standby.c:547
sigset_t UnBlockSig
Definition: pqsignal.c:22
static void StartupProcSigUsr1Handler(SIGNAL_ARGS)
Definition: startup.c:97
void StartupXLOG(void)
Definition: xlog.c:6132
#define SIGPIPE
Definition: win32.h:201
#define SIGHUP
Definition: win32.h:196
#define SIG_DFL
Definition: win32.h:191
pqsigfunc pqsignal(int signum, pqsigfunc handler)
Definition: signal.c:168
TimeoutId RegisterTimeout(TimeoutId id, timeout_handler_proc handler)
Definition: timeout.c:373
static void StartupProcTriggerHandler(SIGNAL_ARGS)
Definition: startup.c:108
static void StartupProcShutdownHandler(SIGNAL_ARGS)
Definition: startup.c:132
#define SIGTTOU
Definition: win32.h:208
#define SIGCHLD
Definition: win32.h:206
#define SIGUSR2
Definition: win32.h:212