mirror of
https://github.com/postgres/postgres.git
synced 2025-06-26 12:21: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:
@ -2582,11 +2582,6 @@ AtEOXact_Buffers(bool isCommit)
|
||||
* This is called during backend startup (whether standalone or under the
|
||||
* postmaster). It sets up for this backend's access to the already-existing
|
||||
* buffer pool.
|
||||
*
|
||||
* NB: this is called before InitProcess(), so we do not have a PGPROC and
|
||||
* cannot do LWLockAcquire; hence we can't actually access stuff in
|
||||
* shared memory yet. We are only initializing local data here.
|
||||
* (See also InitBufferPoolBackend)
|
||||
*/
|
||||
void
|
||||
InitBufferPoolAccess(void)
|
||||
@ -2600,20 +2595,12 @@ InitBufferPoolAccess(void)
|
||||
|
||||
PrivateRefCountHash = hash_create("PrivateRefCount", 100, &hash_ctl,
|
||||
HASH_ELEM | HASH_BLOBS);
|
||||
}
|
||||
|
||||
/*
|
||||
* InitBufferPoolBackend --- second-stage initialization of a new backend
|
||||
*
|
||||
* This is called after we have acquired a PGPROC and so can safely get
|
||||
* LWLocks. We don't currently need to do anything at this stage ...
|
||||
* except register a shmem-exit callback. AtProcExit_Buffers needs LWLock
|
||||
* access, and thereby has to be called at the corresponding phase of
|
||||
* backend shutdown.
|
||||
*/
|
||||
void
|
||||
InitBufferPoolBackend(void)
|
||||
{
|
||||
/*
|
||||
* AtProcExit_Buffers needs LWLock access, and thereby has to be called at
|
||||
* the corresponding phase of backend shutdown.
|
||||
*/
|
||||
Assert(MyProc != NULL);
|
||||
on_shmem_exit(AtProcExit_Buffers, 0);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user