Skip to content

Commit 424cc31

Browse files
committed
Install recycled WAL segments with current timeline ID during recovery.
This is a follow-up to the earlier fix, which changed the recycling logic to recycle WAL segments under the current recovery target timeline. That turns out to be a bad idea, because installing a recycled segment with a TLI higher than what we're recovering at the moment means that the recovery logic will find the recycled WAL segment and try to replay it. It will fail, but but the mere presence of such a WAL segment will mask any other, real, file with the same log/seg, but smaller TLI. Per report from Mitsumasa Kondo. Apply to 9.1 and 9.2, like the previous fix. Master was already doing this differently; this patch makes 9.1 and 9.2 to do the same thing as master.
1 parent 9364134 commit 424cc31

File tree

1 file changed

+11
-3
lines changed
  • src/backend/access/transam

1 file changed

+11
-3
lines changed

src/backend/access/transam/xlog.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8261,10 +8261,18 @@ CreateRestartPoint(int flags)
82618261
PrevLogSeg(_logId, _logSeg);
82628262

82638263
/*
8264-
* Update ThisTimeLineID to the recovery target timeline, so that
8265-
* we install any recycled segments on the correct timeline.
8264+
* Update ThisTimeLineID to the timeline we're currently replaying,
8265+
* so that we install any recycled segments on that timeline.
8266+
*
8267+
* There is no guarantee that the WAL segments will be useful on the
8268+
* current timeline; if recovery proceeds to a new timeline right
8269+
* after this, the pre-allocated WAL segments on this timeline will
8270+
* not be used, and will go wasted until recycled on the next
8271+
* restartpoint. We'll live with that.
82668272
*/
8267-
ThisTimeLineID = GetRecoveryTargetTLI();
8273+
SpinLockAcquire(&xlogctl->info_lck);
8274+
ThisTimeLineID = XLogCtl->lastCheckPoint.ThisTimeLineID;
8275+
SpinLockRelease(&xlogctl->info_lck);
82688276

82698277
RemoveOldXlogFiles(_logId, _logSeg, endptr);
82708278

0 commit comments

Comments
 (0)