summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRobert Haas2021-11-01 16:58:15 +0000
committerRobert Haas2021-11-01 16:58:15 +0000
commit17d9c1e75fb233ba64b135696f005a85d04ca814 (patch)
treed95ae01f40ecba71c51ae4dceaede8a8a19e1bec
parente5910978a754b3bfa9d2905584cc81a0cfb82cd8 (diff)
xlog.c: Make xlog_redo() not depend on ThisTimeLineID global variable.
The same value is available in shared memory as XLogCtl->replayEndTLI so use that instead.
-rw-r--r--src/backend/access/transam/xlog.c20
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,