diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 686e65482cc..d3755f63313 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -9405,6 +9405,7 @@ xlog_redo(XLogReaderState *record) { CheckPoint checkPoint; TimeLineID replayTLI; + TransactionId replayedOldestXid = InvalidTransactionId; memcpy(&checkPoint, XLogRecGetData(record), sizeof(CheckPoint)); /* In a SHUTDOWN checkpoint, believe the counters exactly */ @@ -9453,6 +9454,7 @@ xlog_redo(XLogReaderState *record) RunningTransactionsData running; oldestActiveXID = PrescanPreparedTransactions(&xids, &nxids); + replayedOldestXid = oldestActiveXID; /* Update pg_subtrans entries for any prepared transactions */ StandbyRecoverPreparedTransactions(); @@ -9503,7 +9505,16 @@ xlog_redo(XLogReaderState *record) (errmsg("unexpected timeline ID %u (should be %u) in shutdown checkpoint record", checkPoint.ThisTimeLineID, replayTLI))); - RememberReplayedCheckPoint(&checkPoint); + /* + * A shutdown checkpoint has no oldestActiveXid, but only prepared + * transactions can still be running, so use the value from above. + */ + { + CheckPoint remembered = checkPoint; + + remembered.oldestActiveXid = replayedOldestXid; + RememberReplayedCheckPoint(&remembered); + } RecoveryRestartPoint(&checkPoint, record); /* diff --git a/src/backend/storage/buffer/bufmgr.c b/src/backend/storage/buffer/bufmgr.c index 966c7de0e97..90281f70573 100644 --- a/src/backend/storage/buffer/bufmgr.c +++ b/src/backend/storage/buffer/bufmgr.c @@ -5923,8 +5923,6 @@ MarkSharedBufferDirtyHint(Buffer buffer, BufferDesc *bufHdr, uint64 lockstate, * 3. This function does not guarantee that the buffer is always marked dirty * (it e.g. can't always on a hot standby), so it cannot be used for * important changes. - * 4. If the buffer is already dirty, a WAL record may still be needed until - * the first checkpoint after recovery has completed. */ inline void MarkBufferDirtyHint(Buffer buffer, bool buffer_std) @@ -5944,9 +5942,7 @@ MarkBufferDirtyHint(Buffer buffer, bool buffer_std) bufHdr = GetBufferDescriptor(buffer - 1); buf_state = pg_atomic_read_u64(&bufHdr->state); - MarkSharedBufferDirtyHint(buffer, bufHdr, buf_state, buffer_std, - RecoveryHintRestricted(buffer, buf_state) && - !RecoveryInProgress()); + MarkSharedBufferDirtyHint(buffer, bufHdr, buf_state, buffer_std, false); } /*