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

Commit2cd72ba

Browse files
committed
Fix lastReplayedEndRecPtr calculation when starting from shutdown checkpoint.
When entering crash recovery followed by archive recovery, and the latestcheckpoint is a shutdown checkpoint, and there are no more WAL records toreplay before transitioning from crash to archive recovery, we would notimmediately allow read-only connections in hot standby mode even if wecould. That's because when starting from a shutdown checkpoint, we setlastReplayedEndRecPtr incorrectly to the record before the checkpointrecord, instead of the checkpoint record itself. We don't run the redoroutine of the shutdown checkpoint record, but starting recovery from itgoes through the same motions, so it should be considered as replayed.Reported by Kyotaro HORIGUCHI. All versions with hot standby are affected,so backpatch to 9.0.
1 parent38587d7 commit2cd72ba

File tree

1 file changed

+8
-4
lines changed
  • src/backend/access/transam

1 file changed

+8
-4
lines changed

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

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5457,13 +5457,17 @@ StartupXLOG(void)
54575457

54585458
/*
54595459
* Initialize shared variables for tracking progress of WAL replay,
5460-
* as if we had just replayed the record before the REDO location.
5460+
* as if we had just replayed the record before the REDO location
5461+
* (or the checkpoint record itself, if it's a shutdown checkpoint).
54615462
*/
54625463
SpinLockAcquire(&xlogctl->info_lck);
5463-
xlogctl->replayEndRecPtr=checkPoint.redo;
5464+
if (checkPoint.redo<RecPtr)
5465+
xlogctl->replayEndRecPtr=checkPoint.redo;
5466+
else
5467+
xlogctl->replayEndRecPtr=EndRecPtr;
54645468
xlogctl->replayEndTLI=ThisTimeLineID;
5465-
xlogctl->lastReplayedEndRecPtr=checkPoint.redo;
5466-
xlogctl->lastReplayedTLI=ThisTimeLineID;
5469+
xlogctl->lastReplayedEndRecPtr=xlogctl->replayEndRecPtr;
5470+
xlogctl->lastReplayedTLI=xlogctl->replayEndTLI;
54675471
xlogctl->recoveryLastXTime=0;
54685472
xlogctl->currentChunkStartTime=0;
54695473
xlogctl->recoveryPause= false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp