Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0dd6a09

Browse files
committed
Fix incorrect initialization of ProcGlobal->startupBufferPinWaitBufId.
It was initialized in the wrong place and to the wrong value. With badluck this could result in incorrect query-cancellation failures in hotstandby sessions, should a HS backend be holding pin on buffer number 1while trying to acquire a lock.
1 parentbc6616a commit0dd6a09

File tree

3 files changed

+7
-8
lines changed

3 files changed

+7
-8
lines changed

‎src/backend/storage/buffer/bufmgr.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2449,10 +2449,11 @@ LockBufferForCleanup(Buffer buffer)
24492449
/* Wait to be signaled by UnpinBuffer() */
24502450
if (InHotStandby)
24512451
{
2452-
/*Share the bufid that Startup process waits on */
2452+
/*Publish the bufid that Startup process waits on */
24532453
SetStartupBufferPinWaitBufId(buffer-1);
24542454
/* Set alarm and then wait to be signaled by UnpinBuffer() */
24552455
ResolveRecoveryConflictWithBufferPin();
2456+
/* Reset the published bufid */
24562457
SetStartupBufferPinWaitBufId(-1);
24572458
}
24582459
else

‎src/backend/storage/lmgr/proc.c

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -180,6 +180,9 @@ InitProcGlobal(void)
180180
*/
181181
ProcGlobal->freeProcs=NULL;
182182
ProcGlobal->autovacFreeProcs=NULL;
183+
ProcGlobal->startupProc=NULL;
184+
ProcGlobal->startupProcPid=0;
185+
ProcGlobal->startupBufferPinWaitBufId=-1;
183186

184187
ProcGlobal->spins_per_delay=DEFAULT_SPINS_PER_DELAY;
185188

@@ -499,7 +502,6 @@ PublishStartupProcessInformation(void)
499502

500503
procglobal->startupProc=MyProc;
501504
procglobal->startupProcPid=MyProcPid;
502-
procglobal->startupBufferPinWaitBufId=0;
503505

504506
SpinLockRelease(ProcStructLock);
505507
}
@@ -526,14 +528,10 @@ SetStartupBufferPinWaitBufId(int bufid)
526528
int
527529
GetStartupBufferPinWaitBufId(void)
528530
{
529-
intbufid;
530-
531531
/* use volatile pointer to prevent code rearrangement */
532532
volatilePROC_HDR*procglobal=ProcGlobal;
533533

534-
bufid=procglobal->startupBufferPinWaitBufId;
535-
536-
returnbufid;
534+
returnprocglobal->startupBufferPinWaitBufId;
537535
}
538536

539537
/*

‎src/include/storage/proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,7 @@ typedef struct PROC_HDR
159159
/* The proc of the Startup process, since not in ProcArray */
160160
PGPROC*startupProc;
161161
intstartupProcPid;
162-
/* Buffer id of the buffer that Startup process waits for pin on */
162+
/* Buffer id of the buffer that Startup process waits for pin on, or -1 */
163163
intstartupBufferPinWaitBufId;
164164
}PROC_HDR;
165165

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp