summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogrecovery.c
diff options
context:
space:
mode:
authorMichael Paquier2025-11-05 01:41:50 +0000
committerMichael Paquier2025-11-05 01:41:50 +0000
commit2fc31079624e16d6b1a8508958dbf81e8edce057 (patch)
tree2763780df01d064b83f0ad1dc355ad60f6f9780e /src/backend/access/transam/xlogrecovery.c
parentdae00f333bdd98d094275080dba248cc80d4ca04 (diff)
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]
Diffstat (limited to 'src/backend/access/transam/xlogrecovery.c')
-rw-r--r--src/backend/access/transam/xlogrecovery.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index 0a5ae5050c4..93c50831b26 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -3148,6 +3148,8 @@ ReadRecord(XLogPrefetcher *xlogprefetcher, int emode,
XLogReaderState *xlogreader = XLogPrefetcherGetReader(xlogprefetcher);
XLogPageReadPrivate *private = (XLogPageReadPrivate *) xlogreader->private_data;
+ Assert(AmStartupProcess() || !IsUnderPostmaster);
+
/* Pass through parameters to XLogPageRead */
private->fetching_ckpt = fetching_ckpt;
private->emode = emode;
@@ -3319,6 +3321,8 @@ XLogPageRead(XLogReaderState *xlogreader, XLogRecPtr targetPagePtr, int reqLen,
int r;
instr_time io_start;
+ Assert(AmStartupProcess() || !IsUnderPostmaster);
+
XLByteToSeg(targetPagePtr, targetSegNo, wal_segment_size);
targetPageOff = XLogSegmentOffset(targetPagePtr, wal_segment_size);