diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 61ba6b852e..b5a426c535 100644 *** a/src/backend/access/transam/xlog.c --- b/src/backend/access/transam/xlog.c *************** *** 5989,5994 **** recoveryApplyDelay(XLogReaderState *record) --- 5989,5998 ---- if (!reachedConsistency) return false; + /* nothing to do if standby mode is not requested */ + if (!StandbyModeRequested) + return false; + /* * Is it a COMMIT record? * *************** *** 11869,11874 **** WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, --- 11873,11884 ---- * hope... */ + /* + * We should be able to move to XLOG_FROM_STREAM + * only in standby mode. + */ + Assert(StandbyMode); + /* * Before we leave XLOG_FROM_STREAM state, make sure that * walreceiver is not active, so that it won't overwrite *************** *** 11982,11987 **** WaitForWALToBecomeAvailable(XLogRecPtr RecPtr, bool randAccess, --- 11992,12003 ---- { bool havedata; + /* + * We should be able to move to XLOG_FROM_STREAM + * only in standby mode. + */ + Assert(StandbyMode); + /* * Check if WAL receiver is still active. */