mirror of
https://github.com/postgres/postgres.git
synced 2025-11-21 00:42:43 +03:00
Refactor postmaster child process launching
Introduce new postmaster_child_launch() function that deals with the differences in EXEC_BACKEND mode. Refactor the mechanism of passing information from the parent to child process. Instead of using different command-line arguments when launching the child process in EXEC_BACKEND mode, pass a variable-length blob of startup data along with all the global variables. The contents of that blob depend on the kind of child process being launched. In !EXEC_BACKEND mode, we use the same blob, but it's simply inherited from the parent to child process. Reviewed-by: Tristan Partin, Andres Freund Discussion: https://www.postgresql.org/message-id/7a59b073-5b5b-151e-7ed3-8b01ff7ce9ef@iki.fi
This commit is contained in:
@@ -27,6 +27,7 @@
|
||||
#include "storage/ipc.h"
|
||||
#include "storage/proc.h"
|
||||
#include "storage/procsignal.h"
|
||||
#include "utils/memutils.h"
|
||||
#include "utils/ps_status.h"
|
||||
|
||||
|
||||
@@ -34,19 +35,22 @@ static void ShutdownAuxiliaryProcess(int code, Datum arg);
|
||||
|
||||
|
||||
/*
|
||||
* AuxiliaryProcessMain
|
||||
* AuxiliaryProcessMainCommon
|
||||
*
|
||||
* The main entry point for auxiliary processes, such as the bgwriter,
|
||||
* walwriter, walreceiver, bootstrapper and the shared memory checker code.
|
||||
*
|
||||
* This code is here just because of historical reasons.
|
||||
* Common initialization code for auxiliary processes, such as the bgwriter,
|
||||
* walwriter, walreceiver, and the startup process.
|
||||
*/
|
||||
void
|
||||
AuxiliaryProcessMain(BackendType auxtype)
|
||||
AuxiliaryProcessMainCommon(void)
|
||||
{
|
||||
Assert(IsUnderPostmaster);
|
||||
|
||||
MyBackendType = auxtype;
|
||||
/* Release postmaster's working memory context */
|
||||
if (PostmasterContext)
|
||||
{
|
||||
MemoryContextDelete(PostmasterContext);
|
||||
PostmasterContext = NULL;
|
||||
}
|
||||
|
||||
init_ps_display(NULL);
|
||||
|
||||
@@ -84,41 +88,6 @@ AuxiliaryProcessMain(BackendType auxtype)
|
||||
before_shmem_exit(ShutdownAuxiliaryProcess, 0);
|
||||
|
||||
SetProcessingMode(NormalProcessing);
|
||||
|
||||
switch (MyBackendType)
|
||||
{
|
||||
case B_STARTUP:
|
||||
StartupProcessMain();
|
||||
proc_exit(1);
|
||||
|
||||
case B_ARCHIVER:
|
||||
PgArchiverMain();
|
||||
proc_exit(1);
|
||||
|
||||
case B_BG_WRITER:
|
||||
BackgroundWriterMain();
|
||||
proc_exit(1);
|
||||
|
||||
case B_CHECKPOINTER:
|
||||
CheckpointerMain();
|
||||
proc_exit(1);
|
||||
|
||||
case B_WAL_WRITER:
|
||||
WalWriterMain();
|
||||
proc_exit(1);
|
||||
|
||||
case B_WAL_RECEIVER:
|
||||
WalReceiverMain();
|
||||
proc_exit(1);
|
||||
|
||||
case B_WAL_SUMMARIZER:
|
||||
WalSummarizerMain();
|
||||
proc_exit(1);
|
||||
|
||||
default:
|
||||
elog(PANIC, "unrecognized process type: %d", (int) MyBackendType);
|
||||
proc_exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user