mirror of
https://github.com/postgres/postgres.git
synced 2026-07-11 18:45:31 -04:00
Fix advertising autovacuum launcher's ProcNumber
Autovacuum launcher is not an aux process, so it needs to be advertised in InitProcess() rather than InitAuxiliaryProcess() In the passing, also remove some now-unnecessary 'volatile' qualifiers left behind by the same commit. Reported-by: Thom Brown <thom@linux.com> Author: Fujii Masao <masao.fujii@gmail.com> Author: Nathan Bossart <nathandbossart@gmail.com> Discussion: https://www.postgresql.org/message-id/CAA-aLv6UHXubNxmAjNH8PnyKKkaXePO1ggB15=iidNW08T4hSg@mail.gmail.com
This commit is contained in:
parent
86ab7f4c72
commit
dff789e555
3 changed files with 14 additions and 12 deletions
|
|
@ -1114,8 +1114,7 @@ RequestCheckpoint(int flags)
|
|||
#define MAX_SIGNAL_TRIES 600 /* max wait 60.0 sec */
|
||||
for (ntries = 0;; ntries++)
|
||||
{
|
||||
volatile PROC_HDR *procglobal = ProcGlobal;
|
||||
ProcNumber checkpointerProc = pg_atomic_read_u32(&procglobal->checkpointerProc);
|
||||
ProcNumber checkpointerProc = pg_atomic_read_u32(&ProcGlobal->checkpointerProc);
|
||||
|
||||
if (checkpointerProc == INVALID_PROC_NUMBER)
|
||||
{
|
||||
|
|
@ -1536,8 +1535,7 @@ FirstCallSinceLastCheckpoint(void)
|
|||
void
|
||||
WakeupCheckpointer(void)
|
||||
{
|
||||
volatile PROC_HDR *procglobal = ProcGlobal;
|
||||
ProcNumber checkpointerProc = pg_atomic_read_u32(&procglobal->checkpointerProc);
|
||||
ProcNumber checkpointerProc = pg_atomic_read_u32(&ProcGlobal->checkpointerProc);
|
||||
|
||||
if (checkpointerProc != INVALID_PROC_NUMBER)
|
||||
SetLatch(&GetPGProcByNumber(checkpointerProc)->procLatch);
|
||||
|
|
|
|||
|
|
@ -550,6 +550,10 @@ InitProcess(void)
|
|||
*/
|
||||
PGSemaphoreReset(MyProc->sem);
|
||||
|
||||
/* autovacuum launcher is specially advertised in ProcGlobal */
|
||||
if (MyBackendType == B_AUTOVAC_LAUNCHER)
|
||||
pg_atomic_write_u32(&ProcGlobal->avLauncherProc, MyProcNumber);
|
||||
|
||||
/*
|
||||
* Arrange to clean up at backend exit.
|
||||
*/
|
||||
|
|
@ -726,8 +730,6 @@ InitAuxiliaryProcess(void)
|
|||
PGSemaphoreReset(MyProc->sem);
|
||||
|
||||
/* Some aux processes are also advertised in ProcGlobal */
|
||||
if (MyBackendType == B_AUTOVAC_LAUNCHER)
|
||||
pg_atomic_write_u32(&ProcGlobal->avLauncherProc, MyProcNumber);
|
||||
if (MyBackendType == B_WAL_WRITER)
|
||||
pg_atomic_write_u32(&ProcGlobal->walwriterProc, MyProcNumber);
|
||||
if (MyBackendType == B_CHECKPOINTER)
|
||||
|
|
@ -989,6 +991,12 @@ ProcKill(int code, Datum arg)
|
|||
SwitchBackToLocalLatch();
|
||||
DisownLatch(&MyProc->procLatch);
|
||||
|
||||
if (MyBackendType == B_AUTOVAC_LAUNCHER)
|
||||
{
|
||||
Assert(pg_atomic_read_u32(&ProcGlobal->avLauncherProc) == MyProcNumber);
|
||||
pg_atomic_write_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER);
|
||||
}
|
||||
|
||||
proc = MyProc;
|
||||
procgloballist = proc->procgloballist;
|
||||
|
||||
|
|
@ -1113,11 +1121,6 @@ AuxiliaryProcKill(int code, Datum arg)
|
|||
/*
|
||||
* If this was one of the aux processes advertised in ProcGlobal, clear it
|
||||
*/
|
||||
if (MyBackendType == B_AUTOVAC_LAUNCHER)
|
||||
{
|
||||
Assert(pg_atomic_read_u32(&ProcGlobal->avLauncherProc) == MyProcNumber);
|
||||
pg_atomic_write_u32(&ProcGlobal->avLauncherProc, INVALID_PROC_NUMBER);
|
||||
}
|
||||
if (MyBackendType == B_WAL_WRITER)
|
||||
{
|
||||
Assert(pg_atomic_read_u32(&ProcGlobal->walwriterProc) == MyProcNumber);
|
||||
|
|
|
|||
|
|
@ -491,9 +491,10 @@ typedef struct PROC_HDR
|
|||
* Current proc numbers of some auxiliary processes. There can be only one
|
||||
* of each of these running at a time.
|
||||
*/
|
||||
pg_atomic_uint32 avLauncherProc;
|
||||
pg_atomic_uint32 walwriterProc;
|
||||
pg_atomic_uint32 checkpointerProc;
|
||||
/* avlauncher is not an aux process, but it is advertised the same way */
|
||||
pg_atomic_uint32 avLauncherProc;
|
||||
|
||||
/* Current shared estimate of appropriate spins_per_delay value */
|
||||
int spins_per_delay;
|
||||
|
|
|
|||
Loading…
Reference in a new issue