Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit343ee00

Browse files
committed
Fix recycling of WAL segments after switching timeline during recovery.
This was broken before, we would recycle old WAL segments on wrong timelineafter the recovery target timeline had changed, but my recent commit tonot initialize ThisTimeLineID at all in a standby's checkpointer processbroke this completely.The problem is that when installing a recycled WAL segment as a future one,ThisTimeLineID is used to construct the filename. To fix, always updateThisTimeLineID to the current timeline being recovered, before recyclingWAL segments at a restartpoint.This still leaves a small window where we might install WAL segments underwrong timeline ID, if the timeline is changed just as we're about to startrecycling. Also, even if we're replaying timeline X at the momnent, there'sno guarantee that we'll need as many WAL segments on that timeline as werecycle. We might be just about to reach the point where we switch to nexttimeline, so might only need one more WAL segment on the current timeline.We'll live with the waste in that situation.Bug pointed out by Fujii Masao. 9.1 and 9.2 had the same issue, whenrecovery target timeline was changed, but I committed a slightly differentversion of this patch on those branches.
1 parentdc9896a commit343ee00

File tree

1 file changed

+13
-0
lines changed
  • src/backend/access/transam

1 file changed

+13
-0
lines changed

‎src/backend/access/transam/xlog.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7637,6 +7637,19 @@ CreateRestartPoint(int flags)
76377637

76387638
KeepLogSeg(endptr,&_logSegNo);
76397639
_logSegNo--;
7640+
7641+
/*
7642+
* Update ThisTimeLineID to the timeline we're currently replaying,
7643+
* so that we install any recycled segments on that timeline.
7644+
*
7645+
* There is no guarantee that the WAL segments will be useful on the
7646+
* current timeline; if recovery proceeds to a new timeline right
7647+
* after this, the pre-allocated WAL segments on this timeline will
7648+
* not be used, and will go wasted until recycled on the next
7649+
* restartpoint. We'll live with that.
7650+
*/
7651+
(void)GetXLogReplayRecPtr(&ThisTimeLineID);
7652+
76407653
RemoveOldXlogFiles(_logSegNo,endptr);
76417654

76427655
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp