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

Commit2e53bd5

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 parent89df948 commit2e53bd5

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
@@ -171,6 +171,9 @@ InitProcGlobal(void)
171171
ProcGlobal->spins_per_delay=DEFAULT_SPINS_PER_DELAY;
172172
ProcGlobal->freeProcs=NULL;
173173
ProcGlobal->autovacFreeProcs=NULL;
174+
ProcGlobal->startupProc=NULL;
175+
ProcGlobal->startupProcPid=0;
176+
ProcGlobal->startupBufferPinWaitBufId=-1;
174177

175178
/*
176179
* Create and initialize all the PGPROC structures we'll need (except for
@@ -493,7 +496,6 @@ PublishStartupProcessInformation(void)
493496

494497
procglobal->startupProc=MyProc;
495498
procglobal->startupProcPid=MyProcPid;
496-
procglobal->startupBufferPinWaitBufId=0;
497499

498500
SpinLockRelease(ProcStructLock);
499501
}
@@ -520,14 +522,10 @@ SetStartupBufferPinWaitBufId(int bufid)
520522
int
521523
GetStartupBufferPinWaitBufId(void)
522524
{
523-
intbufid;
524-
525525
/* use volatile pointer to prevent code rearrangement */
526526
volatilePROC_HDR*procglobal=ProcGlobal;
527527

528-
bufid=procglobal->startupBufferPinWaitBufId;
529-
530-
returnbufid;
528+
returnprocglobal->startupBufferPinWaitBufId;
531529
}
532530

533531
/*

‎src/include/storage/proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,7 @@ typedef struct PROC_HDR
178178
/* The proc of the Startup process, since not in ProcArray */
179179
PGPROC*startupProc;
180180
intstartupProcPid;
181-
/* Buffer id of the buffer that Startup process waits for pin on */
181+
/* Buffer id of the buffer that Startup process waits for pin on, or -1 */
182182
intstartupBufferPinWaitBufId;
183183
}PROC_HDR;
184184

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp