mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +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:
@ -67,7 +67,6 @@ static HeapTuple GetDatabaseTuple(const char *dbname);
|
||||
static HeapTuple GetDatabaseTupleByOid(Oid dboid);
|
||||
static void PerformAuthentication(Port *port);
|
||||
static void CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connections);
|
||||
static void InitCommunication(void);
|
||||
static void ShutdownPostgres(int code, Datum arg);
|
||||
static void StatementTimeoutHandler(void);
|
||||
static void LockTimeoutHandler(void);
|
||||
@ -417,31 +416,6 @@ CheckMyDatabase(const char *name, bool am_superuser, bool override_allow_connect
|
||||
}
|
||||
|
||||
|
||||
|
||||
/* --------------------------------
|
||||
* InitCommunication
|
||||
*
|
||||
* This routine initializes stuff needed for ipc, locking, etc.
|
||||
* it should be called something more informative.
|
||||
* --------------------------------
|
||||
*/
|
||||
static void
|
||||
InitCommunication(void)
|
||||
{
|
||||
/*
|
||||
* initialize shared memory and semaphores appropriately.
|
||||
*/
|
||||
if (!IsUnderPostmaster) /* postmaster already did this */
|
||||
{
|
||||
/*
|
||||
* We're running a postgres bootstrap process or a standalone backend,
|
||||
* so we need to set up shmem.
|
||||
*/
|
||||
CreateSharedMemoryAndSemaphores();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*
|
||||
* pg_split_opts -- split a string of options and append it to an argv array
|
||||
*
|
||||
@ -536,11 +510,11 @@ InitializeMaxBackends(void)
|
||||
void
|
||||
BaseInit(void)
|
||||
{
|
||||
Assert(MyProc != NULL);
|
||||
|
||||
/*
|
||||
* Attach to shared memory and semaphores, and initialize our
|
||||
* input/output/debugging file descriptors.
|
||||
* Initialize our input/output/debugging file descriptors.
|
||||
*/
|
||||
InitCommunication();
|
||||
DebugFileOpen();
|
||||
|
||||
/* Do local initialization of file, storage and buffer managers */
|
||||
@ -624,11 +598,6 @@ InitPostgres(const char *in_dbname, Oid dboid, const char *username,
|
||||
RegisterTimeout(CLIENT_CONNECTION_CHECK_TIMEOUT, ClientCheckTimeoutHandler);
|
||||
}
|
||||
|
||||
/*
|
||||
* bufmgr needs another initialization call too
|
||||
*/
|
||||
InitBufferPoolBackend();
|
||||
|
||||
/*
|
||||
* Initialize local process's access to XLOG.
|
||||
*/
|
||||
|
Reference in New Issue
Block a user