1
0
mirror of https://github.com/postgres/postgres.git synced 2025-07-26 01:22:12 +03:00

process startup: Always call Init[Auxiliary]Process() before BaseInit().

For EXEC_BACKEND InitProcess()/InitAuxiliaryProcess() needs to have been
called well before we call BaseInit(), as SubPostmasterMain() needs LWLocks to
work. Having the order of initialization differ between platforms makes it
unnecessarily hard to understand the system and to add initialization points
for new subsystems without a lot of duplication.

To be able to change the order, BaseInit() cannot trigger
CreateSharedMemoryAndSemaphores() anymore - obviously that needs to have
happened before we can call InitProcess(). It seems cleaner to create shared
memory explicitly in single user/bootstrap mode anyway.

After this change the separation of bufmgr initialization into
InitBufferPoolAccess() / InitBufferPoolBackend() is not meaningful anymore so
the latter is removed.

Author: Andres Freund <andres@anarazel.de>
Reviewed-By: Kyotaro Horiguchi <horikyota.ntt@gmail.com>
Discussion: https://postgr.es/m/20210802164124.ufo5buo4apl6yuvs@alap3.anarazel.de
This commit is contained in:
Andres Freund
2021-08-05 14:37:09 -07:00
parent 0de13bbc47
commit b406478b87
8 changed files with 39 additions and 83 deletions

View File

@ -178,8 +178,8 @@ static IndexList *ILHead = NULL;
/*
* In shared memory checker mode, all we really want to do is create shared
* memory and semaphores (just to prove we can do it with the current GUC
* settings). Since, in fact, that was already done by BaseInit(),
* we have nothing more to do here.
* settings). Since, in fact, that was already done by
* CreateSharedMemoryAndSemaphores(), we have nothing more to do here.
*/
static void
CheckerModeMain(void)
@ -324,7 +324,7 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
InitializeMaxBackends();
BaseInit();
CreateSharedMemoryAndSemaphores();
/*
* XXX: It might make sense to move this into its own function at some
@ -338,6 +338,13 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
abort();
}
/*
* Do backend-like initialization for bootstrap mode
*/
InitProcess();
BaseInit();
bootstrap_signals();
BootStrapXLOG();
@ -348,11 +355,6 @@ BootstrapModeMain(int argc, char *argv[], bool check_only)
if (pg_link_canary_is_frontend())
elog(ERROR, "backend is incorrectly linked to frontend functions");
/*
* Do backend-like initialization for bootstrap mode
*/
InitProcess();
InitPostgres(NULL, InvalidOid, NULL, InvalidOid, NULL, false);
/* Initialize stuff for bootstrap-file processing */