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 148 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().

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

Definition at line 247 of file startup.c.

References promote_triggered.

Referenced by CheckForStandbyTrigger().

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

Definition at line 241 of file startup.c.

References in_restore_command.

Referenced by RestoreArchivedFile().

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

Definition at line 227 of file startup.c.

References in_restore_command, proc_exit(), and shutdown_requested.

Referenced by RestoreArchivedFile().

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

Definition at line 253 of file startup.c.

References promote_triggered.

Referenced by CheckForStandbyTrigger().

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

Definition at line 179 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().

180 {
181  /*
182  * Properly accept or ignore signals the postmaster might send us.
183  */
184  pqsignal(SIGHUP, StartupProcSigHupHandler); /* reload config file */
185  pqsignal(SIGINT, SIG_IGN); /* ignore query cancel */
186  pqsignal(SIGTERM, StartupProcShutdownHandler); /* request shutdown */
187  pqsignal(SIGQUIT, startupproc_quickdie); /* hard crash time */
188  InitializeTimeouts(); /* establishes SIGALRM handler */
192 
193  /*
194  * Reset some signals that are accepted by postmaster but not here
195  */
201 
202  /*
203  * Register timeouts needed for standby mode
204  */
208 
209  /*
210  * Unblock signals (they were blocked when the postmaster forked us)
211  */
213 
214  /*
215  * Do what we came for.
216  */
217  StartupXLOG();
218 
219  /*
220  * Exit normally. Exit code 0 tells postmaster that we completed recovery
221  * successfully.
222  */
223  proc_exit(0);
224 }
void InitializeTimeouts(void)
Definition: timeout.c:340
#define SIGUSR1
Definition: win32.h:202
void StandbyTimeoutHandler(void)
Definition: standby.c:558
static void startupproc_quickdie(SIGNAL_ARGS)
Definition: startup.c:70
#define SIGCONT
Definition: win32.h:197
#define SIGWINCH
Definition: win32.h:201
#define SIGTTIN
Definition: win32.h:199
void proc_exit(int code)
Definition: ipc.c:99
#define SIGQUIT
Definition: win32.h:189
#define PG_SETMASK(mask)
Definition: pqsignal.h:19
#define SIG_IGN
Definition: win32.h:185
static void StartupProcSigHupHandler(SIGNAL_ARGS)
Definition: startup.c:121
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:98
void StartupXLOG(void)
Definition: xlog.c:6190
#define SIGPIPE
Definition: win32.h:193
#define SIGHUP
Definition: win32.h:188
#define SIG_DFL
Definition: win32.h:183
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:109
static void StartupProcShutdownHandler(SIGNAL_ARGS)
Definition: startup.c:133
#define SIGTTOU
Definition: win32.h:200
#define SIGCHLD
Definition: win32.h:198
#define SIGUSR2
Definition: win32.h:203