Remove Start* macros in postmaster.c.
These macros are just shorthands for calling StartChildProcess() with the appropriate process type, and they arguably make the code harder to understand. Suggested-by: Andres Freund Author: Reid Thompson Reviewed-by: Bharath Rupireddy Discussion: https://postgr.es/m/e88934c02a5c66f5e8caab2025f85da6b9026d0b.camel%40crunchydata.com
This commit is contained in:
parent
a39f1a365a
commit
1e285a5e13
@ -561,14 +561,6 @@ static void ShmemBackendArrayAdd(Backend *bn);
|
|||||||
static void ShmemBackendArrayRemove(Backend *bn);
|
static void ShmemBackendArrayRemove(Backend *bn);
|
||||||
#endif /* EXEC_BACKEND */
|
#endif /* EXEC_BACKEND */
|
||||||
|
|
||||||
#define StartupDataBase() StartChildProcess(StartupProcess)
|
|
||||||
#define StartArchiver() StartChildProcess(ArchiverProcess)
|
|
||||||
#define StartBackgroundWriter() StartChildProcess(BgWriterProcess)
|
|
||||||
#define StartCheckpointer() StartChildProcess(CheckpointerProcess)
|
|
||||||
#define StartWalWriter() StartChildProcess(WalWriterProcess)
|
|
||||||
#define StartWalReceiver() StartChildProcess(WalReceiverProcess)
|
|
||||||
#define StartWalSummarizer() StartChildProcess(WalSummarizerProcess)
|
|
||||||
|
|
||||||
/* Macros to check exit status of a child process */
|
/* Macros to check exit status of a child process */
|
||||||
#define EXIT_STATUS_0(st) ((st) == 0)
|
#define EXIT_STATUS_0(st) ((st) == 0)
|
||||||
#define EXIT_STATUS_1(st) (WIFEXITED(st) && WEXITSTATUS(st) == 1)
|
#define EXIT_STATUS_1(st) (WIFEXITED(st) && WEXITSTATUS(st) == 1)
|
||||||
@ -1457,14 +1449,14 @@ PostmasterMain(int argc, char *argv[])
|
|||||||
|
|
||||||
/* Start bgwriter and checkpointer so they can help with recovery */
|
/* Start bgwriter and checkpointer so they can help with recovery */
|
||||||
if (CheckpointerPID == 0)
|
if (CheckpointerPID == 0)
|
||||||
CheckpointerPID = StartCheckpointer();
|
CheckpointerPID = StartChildProcess(CheckpointerProcess);
|
||||||
if (BgWriterPID == 0)
|
if (BgWriterPID == 0)
|
||||||
BgWriterPID = StartBackgroundWriter();
|
BgWriterPID = StartChildProcess(BgWriterProcess);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* We're ready to rock and roll...
|
* We're ready to rock and roll...
|
||||||
*/
|
*/
|
||||||
StartupPID = StartupDataBase();
|
StartupPID = StartChildProcess(StartupProcess);
|
||||||
Assert(StartupPID != 0);
|
Assert(StartupPID != 0);
|
||||||
StartupStatus = STARTUP_RUNNING;
|
StartupStatus = STARTUP_RUNNING;
|
||||||
pmState = PM_STARTUP;
|
pmState = PM_STARTUP;
|
||||||
@ -1798,9 +1790,9 @@ ServerLoop(void)
|
|||||||
pmState == PM_HOT_STANDBY || pmState == PM_STARTUP)
|
pmState == PM_HOT_STANDBY || pmState == PM_STARTUP)
|
||||||
{
|
{
|
||||||
if (CheckpointerPID == 0)
|
if (CheckpointerPID == 0)
|
||||||
CheckpointerPID = StartCheckpointer();
|
CheckpointerPID = StartChildProcess(CheckpointerProcess);
|
||||||
if (BgWriterPID == 0)
|
if (BgWriterPID == 0)
|
||||||
BgWriterPID = StartBackgroundWriter();
|
BgWriterPID = StartChildProcess(BgWriterProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -1809,7 +1801,7 @@ ServerLoop(void)
|
|||||||
* be writing any new WAL).
|
* be writing any new WAL).
|
||||||
*/
|
*/
|
||||||
if (WalWriterPID == 0 && pmState == PM_RUN)
|
if (WalWriterPID == 0 && pmState == PM_RUN)
|
||||||
WalWriterPID = StartWalWriter();
|
WalWriterPID = StartChildProcess(WalWriterProcess);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we have lost the autovacuum launcher, try to start a new one. We
|
* If we have lost the autovacuum launcher, try to start a new one. We
|
||||||
@ -1828,7 +1820,7 @@ ServerLoop(void)
|
|||||||
|
|
||||||
/* If we have lost the archiver, try to start a new one. */
|
/* If we have lost the archiver, try to start a new one. */
|
||||||
if (PgArchPID == 0 && PgArchStartupAllowed())
|
if (PgArchPID == 0 && PgArchStartupAllowed())
|
||||||
PgArchPID = StartArchiver();
|
PgArchPID = StartChildProcess(ArchiverProcess);
|
||||||
|
|
||||||
/* If we need to signal the autovacuum launcher, do so now */
|
/* If we need to signal the autovacuum launcher, do so now */
|
||||||
if (avlauncher_needs_signal)
|
if (avlauncher_needs_signal)
|
||||||
@ -3019,11 +3011,11 @@ process_pm_child_exit(void)
|
|||||||
* if this fails, we'll just try again later.
|
* if this fails, we'll just try again later.
|
||||||
*/
|
*/
|
||||||
if (CheckpointerPID == 0)
|
if (CheckpointerPID == 0)
|
||||||
CheckpointerPID = StartCheckpointer();
|
CheckpointerPID = StartChildProcess(CheckpointerProcess);
|
||||||
if (BgWriterPID == 0)
|
if (BgWriterPID == 0)
|
||||||
BgWriterPID = StartBackgroundWriter();
|
BgWriterPID = StartChildProcess(BgWriterProcess);
|
||||||
if (WalWriterPID == 0)
|
if (WalWriterPID == 0)
|
||||||
WalWriterPID = StartWalWriter();
|
WalWriterPID = StartChildProcess(WalWriterProcess);
|
||||||
MaybeStartWalSummarizer();
|
MaybeStartWalSummarizer();
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@ -3033,7 +3025,7 @@ process_pm_child_exit(void)
|
|||||||
if (!IsBinaryUpgrade && AutoVacuumingActive() && AutoVacPID == 0)
|
if (!IsBinaryUpgrade && AutoVacuumingActive() && AutoVacPID == 0)
|
||||||
AutoVacPID = StartAutoVacLauncher();
|
AutoVacPID = StartAutoVacLauncher();
|
||||||
if (PgArchStartupAllowed() && PgArchPID == 0)
|
if (PgArchStartupAllowed() && PgArchPID == 0)
|
||||||
PgArchPID = StartArchiver();
|
PgArchPID = StartChildProcess(ArchiverProcess);
|
||||||
|
|
||||||
/* workers may be scheduled to start now */
|
/* workers may be scheduled to start now */
|
||||||
maybe_start_bgworkers();
|
maybe_start_bgworkers();
|
||||||
@ -3188,7 +3180,7 @@ process_pm_child_exit(void)
|
|||||||
HandleChildCrash(pid, exitstatus,
|
HandleChildCrash(pid, exitstatus,
|
||||||
_("archiver process"));
|
_("archiver process"));
|
||||||
if (PgArchStartupAllowed())
|
if (PgArchStartupAllowed())
|
||||||
PgArchPID = StartArchiver();
|
PgArchPID = StartChildProcess(ArchiverProcess);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3767,7 +3759,7 @@ PostmasterStateMachine(void)
|
|||||||
Assert(Shutdown > NoShutdown);
|
Assert(Shutdown > NoShutdown);
|
||||||
/* Start the checkpointer if not running */
|
/* Start the checkpointer if not running */
|
||||||
if (CheckpointerPID == 0)
|
if (CheckpointerPID == 0)
|
||||||
CheckpointerPID = StartCheckpointer();
|
CheckpointerPID = StartChildProcess(CheckpointerProcess);
|
||||||
/* And tell it to shut down */
|
/* And tell it to shut down */
|
||||||
if (CheckpointerPID != 0)
|
if (CheckpointerPID != 0)
|
||||||
{
|
{
|
||||||
@ -3899,7 +3891,7 @@ PostmasterStateMachine(void)
|
|||||||
|
|
||||||
/*
|
/*
|
||||||
* If we need to recover from a crash, wait for all non-syslogger children
|
* If we need to recover from a crash, wait for all non-syslogger children
|
||||||
* to exit, then reset shmem and StartupDataBase.
|
* to exit, then reset shmem and start the startup process.
|
||||||
*/
|
*/
|
||||||
if (FatalError && pmState == PM_NO_CHILDREN)
|
if (FatalError && pmState == PM_NO_CHILDREN)
|
||||||
{
|
{
|
||||||
@ -3921,7 +3913,7 @@ PostmasterStateMachine(void)
|
|||||||
/* re-create shared memory and semaphores */
|
/* re-create shared memory and semaphores */
|
||||||
CreateSharedMemoryAndSemaphores();
|
CreateSharedMemoryAndSemaphores();
|
||||||
|
|
||||||
StartupPID = StartupDataBase();
|
StartupPID = StartChildProcess(StartupProcess);
|
||||||
Assert(StartupPID != 0);
|
Assert(StartupPID != 0);
|
||||||
StartupStatus = STARTUP_RUNNING;
|
StartupStatus = STARTUP_RUNNING;
|
||||||
pmState = PM_STARTUP;
|
pmState = PM_STARTUP;
|
||||||
@ -5066,7 +5058,7 @@ process_pm_pmsignal(void)
|
|||||||
*/
|
*/
|
||||||
Assert(PgArchPID == 0);
|
Assert(PgArchPID == 0);
|
||||||
if (XLogArchivingAlways())
|
if (XLogArchivingAlways())
|
||||||
PgArchPID = StartArchiver();
|
PgArchPID = StartChildProcess(ArchiverProcess);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If we aren't planning to enter hot standby mode later, treat
|
* If we aren't planning to enter hot standby mode later, treat
|
||||||
@ -5501,7 +5493,7 @@ MaybeStartWalReceiver(void)
|
|||||||
pmState == PM_HOT_STANDBY) &&
|
pmState == PM_HOT_STANDBY) &&
|
||||||
Shutdown <= SmartShutdown)
|
Shutdown <= SmartShutdown)
|
||||||
{
|
{
|
||||||
WalReceiverPID = StartWalReceiver();
|
WalReceiverPID = StartChildProcess(WalReceiverProcess);
|
||||||
if (WalReceiverPID != 0)
|
if (WalReceiverPID != 0)
|
||||||
WalReceiverRequested = false;
|
WalReceiverRequested = false;
|
||||||
/* else leave the flag set, so we'll try again later */
|
/* else leave the flag set, so we'll try again later */
|
||||||
@ -5518,7 +5510,7 @@ MaybeStartWalSummarizer(void)
|
|||||||
if (summarize_wal && WalSummarizerPID == 0 &&
|
if (summarize_wal && WalSummarizerPID == 0 &&
|
||||||
(pmState == PM_RUN || pmState == PM_HOT_STANDBY) &&
|
(pmState == PM_RUN || pmState == PM_HOT_STANDBY) &&
|
||||||
Shutdown <= SmartShutdown)
|
Shutdown <= SmartShutdown)
|
||||||
WalSummarizerPID = StartWalSummarizer();
|
WalSummarizerPID = StartChildProcess(WalSummarizerProcess);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user