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

Commit0f904c9

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 parentf00fbad commit0f904c9

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
@@ -2422,10 +2422,11 @@ LockBufferForCleanup(Buffer buffer)
24222422
/* Wait to be signaled by UnpinBuffer() */
24232423
if (InHotStandby)
24242424
{
2425-
/*Share the bufid that Startup process waits on */
2425+
/*Publish the bufid that Startup process waits on */
24262426
SetStartupBufferPinWaitBufId(buffer-1);
24272427
/* Set alarm and then wait to be signaled by UnpinBuffer() */
24282428
ResolveRecoveryConflictWithBufferPin();
2429+
/* Reset the published bufid */
24292430
SetStartupBufferPinWaitBufId(-1);
24302431
}
24312432
else

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

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

183186
ProcGlobal->spins_per_delay=DEFAULT_SPINS_PER_DELAY;
184187

@@ -487,7 +490,6 @@ PublishStartupProcessInformation(void)
487490

488491
procglobal->startupProc=MyProc;
489492
procglobal->startupProcPid=MyProcPid;
490-
procglobal->startupBufferPinWaitBufId=0;
491493

492494
SpinLockRelease(ProcStructLock);
493495
}
@@ -514,14 +516,10 @@ SetStartupBufferPinWaitBufId(int bufid)
514516
int
515517
GetStartupBufferPinWaitBufId(void)
516518
{
517-
intbufid;
518-
519519
/* use volatile pointer to prevent code rearrangement */
520520
volatilePROC_HDR*procglobal=ProcGlobal;
521521

522-
bufid=procglobal->startupBufferPinWaitBufId;
523-
524-
returnbufid;
522+
returnprocglobal->startupBufferPinWaitBufId;
525523
}
526524

527525
/*

‎src/include/storage/proc.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ typedef struct PROC_HDR
145145
/* The proc of the Startup process, since not in ProcArray */
146146
PGPROC*startupProc;
147147
intstartupProcPid;
148-
/* Buffer id of the buffer that Startup process waits for pin on */
148+
/* Buffer id of the buffer that Startup process waits for pin on, or -1 */
149149
intstartupBufferPinWaitBufId;
150150
}PROC_HDR;
151151

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp