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

Commite56430c

Browse files
committed
Fix bug in determining when recovery has reached consistency.
When starting WAL replay from an online checkpoint, the last replayed WALrecord variable was initialized using the checkpoint record's location, eventhough the records between the REDO location and the checkpoint record hadnot been replayed yet. That was noted as "slightly confusing" but harmlessin the comment, but in some cases, it fooled CheckRecoveryConsistency toincorrectly conclude that we had already reached a consistent stateimmediately at the beginning of WAL replay. That caused the system to acceptread-only connections in hot standby mode too early, and also PANICs withmessage "WAL contains references to invalid pages".Fix by initializing the variables to the REDO location instead.In 9.2 and above, change CheckRecoveryConsistency() to uselastReplayedEndRecPtr variable when checking if backup end location hasbeen reached. It was inconsistently using EndRecPtr for that check, butlastReplayedEndRecPtr when checking min recovery point. It made nodifference before this patch, because in all the places whereCheckRecoveryConsistency was called the two variables were the same, butit was always an accident waiting to happen, and would have been wrongafter this patch anyway.Report and analysis by Tomonari Katsumata, bug #8686. Backpatch to 9.0,where hot standby was introduced.
1 parent9402169 commite56430c

File tree

1 file changed

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

1 file changed

+4
-12
lines changed

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

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -6507,20 +6507,12 @@ StartupXLOG(void)
65076507
}
65086508

65096509
/*
6510-
* Initialize shared replayEndRecPtr, lastReplayedEndRecPtr, and
6511-
* recoveryLastXTime.
6512-
*
6513-
* This is slightly confusing if we're starting from an online
6514-
* checkpoint; we've just read and replayed the checkpoint record, but
6515-
* we're going to start replay from its redo pointer, which precedes
6516-
* the location of the checkpoint record itself. So even though the
6517-
* last record we've replayed is indeed ReadRecPtr, we haven't
6518-
* replayed all the preceding records yet. That's OK for the current
6519-
* use of these variables.
6510+
* Initialize shared variables for tracking progress of WAL replay,
6511+
* as if we had just replayed the record before the REDO location.
65206512
*/
65216513
SpinLockAcquire(&xlogctl->info_lck);
6522-
xlogctl->replayEndRecPtr=ReadRecPtr;
6523-
xlogctl->lastReplayedEndRecPtr=EndRecPtr;
6514+
xlogctl->replayEndRecPtr=checkPoint.redo;
6515+
xlogctl->lastReplayedEndRecPtr=checkPoint.redo;
65246516
xlogctl->recoveryLastXTime=0;
65256517
xlogctl->recoveryPause= false;
65266518
SpinLockRelease(&xlogctl->info_lck);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp