summaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlogrecovery.c
diff options
context:
space:
mode:
authorMichael Paquier2025-11-04 04:14:46 +0000
committerMichael Paquier2025-11-04 04:14:46 +0000
commit65f4976189b6cbe9aa93fc5f4b1eb7a2040b6301 (patch)
tree90cfa925ec6d586e12d3afb6ceb0404084cecf7b /src/backend/access/transam/xlogrecovery.c
parente0ca61e7c4d55c34d67a3cc6fa0bdea2f41d2cf2 (diff)
Add assertion check for WAL receiver state during stream-archive transition
When the startup process switches from streaming to archive as WAL source, we avoid calling ShutdownWalRcv() if the WAL receiver is not streaming, based on WalRcvStreaming(). WALRCV_STOPPING is a state set by ShutdownWalRcv(), called only by the startup process, meaning that it should not be possible to reach this state while in WaitForWALToBecomeAvailable(). This commit adds an assertion to make sure that a WAL receiver is never in a WALRCV_STOPPING state should the startup process attempt to reset InstallXLogFileSegmentActive. Idea suggested by Noah Misch. Author: 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.c8
1 files changed, 8 insertions, 0 deletions
diff --git a/src/backend/access/transam/xlogrecovery.c b/src/backend/access/transam/xlogrecovery.c
index cb62d43077d..0a5ae5050c4 100644
--- a/src/backend/access/transam/xlogrecovery.c
+++ b/src/backend/access/transam/xlogrecovery.c
@@ -3698,6 +3698,14 @@ WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess,
XLogShutdownWalRcv();
else
{
+ /*
+ * WALRCV_STOPPING state is a transient state while
+ * the startup process is in ShutdownWalRcv(). It
+ * should never appear here since we would be waiting
+ * for the walreceiver to reach WALRCV_STOPPED in that
+ * case.
+ */
+ Assert(WalRcvGetState() != WALRCV_STOPPING);
ResetInstallXLogFileSegmentActive();
}