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

Commitaf246c3

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 parenteb93316 commitaf246c3

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
@@ -6846,13 +6846,17 @@ StartupXLOG(void)
68466846

68476847
/*
68486848
* Initialize shared variables for tracking progress of WAL replay,
6849-
* as if we had just replayed the record before the REDO location.
6849+
* as if we had just replayed the record before the REDO location
6850+
* (or the checkpoint record itself, if it's a shutdown checkpoint).
68506851
*/
68516852
SpinLockAcquire(&xlogctl->info_lck);
6852-
xlogctl->replayEndRecPtr=checkPoint.redo;
6853+
if (checkPoint.redo<RecPtr)
6854+
xlogctl->replayEndRecPtr=checkPoint.redo;
6855+
else
6856+
xlogctl->replayEndRecPtr=EndRecPtr;
68536857
xlogctl->replayEndTLI=ThisTimeLineID;
6854-
xlogctl->lastReplayedEndRecPtr=checkPoint.redo;
6855-
xlogctl->lastReplayedTLI=ThisTimeLineID;
6858+
xlogctl->lastReplayedEndRecPtr=xlogctl->replayEndRecPtr;
6859+
xlogctl->lastReplayedTLI=xlogctl->replayEndTLI;
68566860
xlogctl->recoveryLastXTime=0;
68576861
xlogctl->currentChunkStartTime=0;
68586862
xlogctl->recoveryPause= false;

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp