aboutsummaryrefslogtreecommitdiff
path: root/src/backend/access/transam/xlog.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/access/transam/xlog.c')
-rw-r--r--src/backend/access/transam/xlog.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/backend/access/transam/xlog.c b/src/backend/access/transam/xlog.c
index 690077ce821..26c9ef3d410 100644
--- a/src/backend/access/transam/xlog.c
+++ b/src/backend/access/transam/xlog.c
@@ -8566,10 +8566,18 @@ CreateRestartPoint(int flags)
PrevLogSeg(_logId, _logSeg);
/*
- * Update ThisTimeLineID to the recovery target timeline, so that
- * we install any recycled segments on the correct timeline.
+ * Update ThisTimeLineID to the timeline we're currently replaying,
+ * so that we install any recycled segments on that timeline.
+ *
+ * There is no guarantee that the WAL segments will be useful on the
+ * current timeline; if recovery proceeds to a new timeline right
+ * after this, the pre-allocated WAL segments on this timeline will
+ * not be used, and will go wasted until recycled on the next
+ * restartpoint. We'll live with that.
*/
- ThisTimeLineID = GetRecoveryTargetTLI();
+ SpinLockAcquire(&xlogctl->info_lck);
+ ThisTimeLineID = XLogCtl->lastCheckPoint.ThisTimeLineID;
+ SpinLockRelease(&xlogctl->info_lck);
RemoveOldXlogFiles(_logId, _logSeg, endptr);