mirror of
https://github.com/postgres/postgres.git
synced 2025-07-15 19:21:59 +03:00
Fix incorrect initialization of ProcGlobal->startupBufferPinWaitBufId.
It was initialized in the wrong place and to the wrong value. With bad luck this could result in incorrect query-cancellation failures in hot standby sessions, should a HS backend be holding pin on buffer number 1 while trying to acquire a lock.
This commit is contained in:
@ -171,6 +171,9 @@ InitProcGlobal(void)
|
||||
ProcGlobal->spins_per_delay = DEFAULT_SPINS_PER_DELAY;
|
||||
ProcGlobal->freeProcs = NULL;
|
||||
ProcGlobal->autovacFreeProcs = NULL;
|
||||
ProcGlobal->startupProc = NULL;
|
||||
ProcGlobal->startupProcPid = 0;
|
||||
ProcGlobal->startupBufferPinWaitBufId = -1;
|
||||
|
||||
/*
|
||||
* Create and initialize all the PGPROC structures we'll need (except for
|
||||
@ -493,7 +496,6 @@ PublishStartupProcessInformation(void)
|
||||
|
||||
procglobal->startupProc = MyProc;
|
||||
procglobal->startupProcPid = MyProcPid;
|
||||
procglobal->startupBufferPinWaitBufId = 0;
|
||||
|
||||
SpinLockRelease(ProcStructLock);
|
||||
}
|
||||
@ -520,14 +522,10 @@ SetStartupBufferPinWaitBufId(int bufid)
|
||||
int
|
||||
GetStartupBufferPinWaitBufId(void)
|
||||
{
|
||||
int bufid;
|
||||
|
||||
/* use volatile pointer to prevent code rearrangement */
|
||||
volatile PROC_HDR *procglobal = ProcGlobal;
|
||||
|
||||
bufid = procglobal->startupBufferPinWaitBufId;
|
||||
|
||||
return bufid;
|
||||
return procglobal->startupBufferPinWaitBufId;
|
||||
}
|
||||
|
||||
/*
|
||||
|
Reference in New Issue
Block a user