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

Commite1e2bb3

Browse files
committed
Code review of recycling WAL segments in a restartpoint.
Seems cleaner to get the currently-replayed TLI in the same call toGetXLogReplayRecPtr that we get the WAL position. Make it more clear in thecomment what the code does when recovery has already ended(RecoveryInProgress() will set ThisTimeLineID in that case). Finally, makeresetting ThisTimeLineID afterwards more explicit.
1 parent2c92eda commite1e2bb3

File tree

1 file changed

+15
-15
lines changed
  • src/backend/access/transam

1 file changed

+15
-15
lines changed

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -7463,39 +7463,35 @@ CreateRestartPoint(int flags)
74637463
{
74647464
XLogRecPtrreceivePtr;
74657465
XLogRecPtrreplayPtr;
7466+
TimeLineIDreplayTLI;
74667467
XLogRecPtrendptr;
74677468

74687469
/*
74697470
* Get the current end of xlog replayed or received, whichever is
74707471
* later.
74717472
*/
74727473
receivePtr=GetWalRcvWriteRecPtr(NULL,NULL);
7473-
replayPtr=GetXLogReplayRecPtr(NULL);
7474+
replayPtr=GetXLogReplayRecPtr(&replayTLI);
74747475
endptr= (receivePtr<replayPtr) ?replayPtr :receivePtr;
74757476

74767477
KeepLogSeg(endptr,&_logSegNo);
74777478
_logSegNo--;
74787479

74797480
/*
7480-
* Update ThisTimeLineID to the timeline we're currently replaying, so
7481-
* that we install any recycled segments on that timeline.
7481+
* Try to recycle segments on a useful timeline. If we've been promoted
7482+
* since the beginning of this restartpoint, use the new timeline
7483+
* chosen at end of recovery (RecoveryInProgress() sets ThisTimeLineID
7484+
* in that case). If we're still in recovery, use the timeline we're
7485+
* currently replaying.
74827486
*
74837487
* There is no guarantee that the WAL segments will be useful on the
74847488
* current timeline; if recovery proceeds to a new timeline right
74857489
* after this, the pre-allocated WAL segments on this timeline will
74867490
* not be used, and will go wasted until recycled on the next
74877491
* restartpoint. We'll live with that.
7488-
*
7489-
* It's possible or perhaps even likely that we finish recovery while
7490-
* a restartpoint is in progress. That means we may get to this point
7491-
* some minutes afterwards. Setting ThisTimeLineID at that time would
7492-
* actually set it backwards, so we don't want that to persist; if we
7493-
* do reset it here, make sure to reset it back afterwards. This
7494-
* doesn't look very clean or principled, but its the best of about
7495-
* five different ways of handling this edge case.
74967492
*/
74977493
if (RecoveryInProgress())
7498-
(void)GetXLogReplayRecPtr(&ThisTimeLineID);
7494+
ThisTimeLineID=replayTLI;
74997495

75007496
RemoveOldXlogFiles(_logSegNo,endptr);
75017497

@@ -7506,10 +7502,14 @@ CreateRestartPoint(int flags)
75067502
PreallocXlogFiles(endptr);
75077503

75087504
/*
7509-
* Reset this always, in case we set ThisTimeLineID backwards above.
7510-
* Requires no locking; see InitXLOGAccess()
7505+
* ThisTimeLineID is normally not set when we're still in recovery.
7506+
* However, recycling/preallocating segments above needed
7507+
* ThisTimeLineID to determine which timeline to install the segments
7508+
* on. Reset it now, to restore the normal state of affairs for
7509+
* debugging purposes.
75117510
*/
7512-
ThisTimeLineID=XLogCtl->ThisTimeLineID;
7511+
if (RecoveryInProgress())
7512+
ThisTimeLineID=0;
75137513
}
75147514

75157515
/*

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp