diff options
-rw-r--r-- | src/backend/access/transam/xlog.c | 20 |
1 files changed, 12 insertions, 8 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c index 054241403c..b6f30382eb 100644 --- a/src/backend/access/transam/xlog.c +++ b/src/backend/access/transam/xlog.c @@ -10349,6 +10349,10 @@ xlog_redo(XLogReaderState *record) { uint8 info = XLogRecGetInfo(record) & ~XLR_INFO_MASK; XLogRecPtr lsn = record->EndRecPtr; + TimeLineID replayTLI; + + /* No other process can change this, so we can read it without a lock. */ + replayTLI = XLogCtl->replayEndTLI; /* * In XLOG rmgr, backup blocks are only used by XLOG_FPI and @@ -10462,10 +10466,10 @@ xlog_redo(XLogReaderState *record) * We should've already switched to the new TLI before replaying this * record. */ - if (checkPoint.ThisTimeLineID != ThisTimeLineID) + if (checkPoint.ThisTimeLineID != replayTLI) ereport(PANIC, (errmsg("unexpected timeline ID %u (should be %u) in checkpoint record", - checkPoint.ThisTimeLineID, ThisTimeLineID))); + checkPoint.ThisTimeLineID, replayTLI))); RecoveryRestartPoint(&checkPoint); } @@ -10518,10 +10522,10 @@ xlog_redo(XLogReaderState *record) SpinLockRelease(&XLogCtl->info_lck); /* TLI should not change in an on-line checkpoint */ - if (checkPoint.ThisTimeLineID != ThisTimeLineID) + if (checkPoint.ThisTimeLineID != replayTLI) ereport(PANIC, (errmsg("unexpected timeline ID %u (should be %u) in checkpoint record", - checkPoint.ThisTimeLineID, ThisTimeLineID))); + checkPoint.ThisTimeLineID, replayTLI))); RecoveryRestartPoint(&checkPoint); } @@ -10548,10 +10552,10 @@ xlog_redo(XLogReaderState *record) * We should've already switched to the new TLI before replaying this * record. */ - if (xlrec.ThisTimeLineID != ThisTimeLineID) + if (xlrec.ThisTimeLineID != replayTLI) ereport(PANIC, (errmsg("unexpected timeline ID %u (should be %u) in checkpoint record", - xlrec.ThisTimeLineID, ThisTimeLineID))); + xlrec.ThisTimeLineID, replayTLI))); } else if (info == XLOG_NOOP) { @@ -10621,7 +10625,7 @@ xlog_redo(XLogReaderState *record) if (ControlFile->minRecoveryPoint < lsn) { ControlFile->minRecoveryPoint = lsn; - ControlFile->minRecoveryPointTLI = ThisTimeLineID; + ControlFile->minRecoveryPointTLI = replayTLI; } ControlFile->backupStartPoint = InvalidXLogRecPtr; ControlFile->backupEndRequired = false; @@ -10662,7 +10666,7 @@ xlog_redo(XLogReaderState *record) if (minRecoveryPoint != InvalidXLogRecPtr && minRecoveryPoint < lsn) { ControlFile->minRecoveryPoint = lsn; - ControlFile->minRecoveryPointTLI = ThisTimeLineID; + ControlFile->minRecoveryPointTLI = replayTLI; } CommitTsParameterChange(xlrec.track_commit_timestamp, |