1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-02 04:21:28 +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:
Tom Lane
2011-08-02 13:24:00 -04:00
parent bc6616aaed
commit 0dd6a09e3d
3 changed files with 7 additions and 8 deletions

View File

@@ -2449,10 +2449,11 @@ LockBufferForCleanup(Buffer buffer)
/* Wait to be signaled by UnpinBuffer() */
if (InHotStandby)
{
/* Share the bufid that Startup process waits on */
/* Publish the bufid that Startup process waits on */
SetStartupBufferPinWaitBufId(buffer - 1);
/* Set alarm and then wait to be signaled by UnpinBuffer() */
ResolveRecoveryConflictWithBufferPin();
/* Reset the published bufid */
SetStartupBufferPinWaitBufId(-1);
}
else

View File

@@ -180,6 +180,9 @@ InitProcGlobal(void)
*/
ProcGlobal->freeProcs = NULL;
ProcGlobal->autovacFreeProcs = NULL;
ProcGlobal->startupProc = NULL;
ProcGlobal->startupProcPid = 0;
ProcGlobal->startupBufferPinWaitBufId = -1;
ProcGlobal->spins_per_delay = DEFAULT_SPINS_PER_DELAY;
@@ -499,7 +502,6 @@ PublishStartupProcessInformation(void)
procglobal->startupProc = MyProc;
procglobal->startupProcPid = MyProcPid;
procglobal->startupBufferPinWaitBufId = 0;
SpinLockRelease(ProcStructLock);
}
@@ -526,14 +528,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;
}
/*