Skip to content

Commit 4aed94f

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 841c9b6 commit 4aed94f

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
@@ -8566,10 +8566,18 @@ CreateRestartPoint(int flags)
85668566
PrevLogSeg(_logId, _logSeg);
85678567

85688568
/*
8569-
* Update ThisTimeLineID to the recovery target timeline, so that
8570-
* we install any recycled segments on the correct timeline.
8569+
* Update ThisTimeLineID to the timeline we're currently replaying,
8570+
* so that we install any recycled segments on that timeline.
8571+
*
8572+
* There is no guarantee that the WAL segments will be useful on the
8573+
* current timeline; if recovery proceeds to a new timeline right
8574+
* after this, the pre-allocated WAL segments on this timeline will
8575+
* not be used, and will go wasted until recycled on the next
8576+
* restartpoint. We'll live with that.
85718577
*/
8572-
ThisTimeLineID = GetRecoveryTargetTLI();
8578+
SpinLockAcquire(&xlogctl->info_lck);
8579+
ThisTimeLineID = XLogCtl->lastCheckPoint.ThisTimeLineID;
8580+
SpinLockRelease(&xlogctl->info_lck);
85738581

85748582
RemoveOldXlogFiles(_logId, _logSeg, endptr);
85758583

0 commit comments

Comments
 (0)