Skip to content

Commit 2fc3107

Browse files
committed
Add assertions checking for the startup process in WAL replay routines
These assertions may prove to become useful to make sure that no process other than the startup process calls the routines where these checks are added, as we expect that these do not interfere with a WAL receiver switched to a "stopping" state by a startup process. The assumption that only the startup process can use this code has existed for many years, without a check enforcing it. Reviewed-by: Xuneng Zhou <[email protected]> Discussion: https://postgr.es/m/[email protected]
1 parent dae00f3 commit 2fc3107

File tree

2 files changed

+6
-0
lines changed

2 files changed

+6
-0
lines changed

src/backend/access/transam/xlog.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9518,6 +9518,8 @@ GetOldestRestartPoint(XLogRecPtr *oldrecptr, TimeLineID *oldtli)
95189518
void
95199519
XLogShutdownWalRcv(void)
95209520
{
9521+
Assert(AmStartupProcess() || !IsUnderPostmaster);
9522+
95219523
ShutdownWalRcv();
95229524
ResetInstallXLogFileSegmentActive();
95239525
}

src/backend/access/transam/xlogrecovery.c

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3148,6 +3148,8 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
31483148
XLogReaderState *xlogreader = XLogPrefetcherGetReader(xlogprefetcher);
31493149
XLogPageReadPrivate *private = (XLogPageReadPrivate *) xlogreader->private_data;
31503150

3151+
Assert(AmStartupProcess() || !IsUnderPostmaster);
3152+
31513153
/* Pass through parameters to XLogPageRead */
31523154
private->fetching_ckpt = fetching_ckpt;
31533155
private->emode = emode;
@@ -3319,6 +3321,8 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
33193321
int r;
33203322
instr_time io_start;
33213323

3324+
Assert(AmStartupProcess() || !IsUnderPostmaster);
3325+
33223326
XLByteToSeg(targetPagePtr, targetSegNo, wal_segment_size);
33233327
targetPageOff = XLogSegmentOffset(targetPagePtr, wal_segment_size);
33243328

0 commit comments

Comments
 (0)