From 0dd6a09e3d127e728b9f43cfaf19e5351f60a096 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Tue, 2 Aug 2011 13:24:00 -0400 Subject: 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. --- src/backend/storage/lmgr/proc.c | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) (limited to 'src/backend/storage/lmgr/proc.c') diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index 44399d822c6..78d1fd29343 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -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; } /* -- cgit v1.2.3