From b406478b87e2234c0be4ca4105eee3bb466a646b Mon Sep 17 00:00:00 2001 From: Andres Freund Date: Thu, 5 Aug 2021 14:37:09 -0700 Subject: 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 Reviewed-By: Kyotaro Horiguchi Discussion: https://postgr.es/m/20210802164124.ufo5buo4apl6yuvs@alap3.anarazel.de --- src/backend/tcop/postgres.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) (limited to 'src/backend/tcop/postgres.c') diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 530caa520b8..58b5960e27d 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -4050,10 +4050,9 @@ PostgresMain(int argc, char *argv[], /* Initialize MaxBackends (if under postmaster, was done already) */ InitializeMaxBackends(); - } - /* Early initialization */ - BaseInit(); + CreateSharedMemoryAndSemaphores(); + } /* * Create a per-backend PGPROC struct in shared memory, except in the @@ -4068,6 +4067,9 @@ PostgresMain(int argc, char *argv[], InitProcess(); #endif + /* Early initialization */ + BaseInit(); + /* We need to allow SIGINT, etc during the initial transaction */ PG_SETMASK(&UnBlockSig); -- cgit v1.2.3