]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix bug in determining when recovery has reached consistency.
authorHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Jan 2014 09:39:55 +0000 (11:39 +0200)
committerHeikki Linnakangas <heikki.linnakangas@iki.fi>
Wed, 8 Jan 2014 12:34:21 +0000 (14:34 +0200)
commit5301c839533203ec7020497bf7c06432f6adfb5b
treebcef31f1b64bbd9ce677f5eaf15ab6b4fcddc681
parenta44a0b9cb52629b3ce2756462deaa4d407ac6dd5
Fix bug in determining when recovery has reached consistency.

When starting WAL replay from an online checkpoint, the last replayed WAL
record variable was initialized using the checkpoint record's location, even
though the records between the REDO location and the checkpoint record had
not been replayed yet. That was noted as "slightly confusing" but harmless
in the comment, but in some cases, it fooled CheckRecoveryConsistency to
incorrectly conclude that we had already reached a consistent state
immediately at the beginning of WAL replay. That caused the system to accept
read-only connections in hot standby mode too early, and also PANICs with
message "WAL contains references to invalid pages".

Fix by initializing the variables to the REDO location instead.

In 9.2 and above, change CheckRecoveryConsistency() to use
lastReplayedEndRecPtr variable when checking if backup end location has
been reached. It was inconsistently using EndRecPtr for that check, but
lastReplayedEndRecPtr when checking min recovery point. It made no
difference before this patch, because in all the places where
CheckRecoveryConsistency was called the two variables were the same, but
it was always an accident waiting to happen, and would have been wrong
after this patch anyway.

Report and analysis by Tomonari Katsumata, bug #8686. Backpatch to 9.0,
where hot standby was introduced.
src/backend/access/transam/xlog.c