postgresql/src/backend
Heikki Linnakangas d59ff6c110 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.
2014-01-08 15:03:09 +02:00
..
access Fix bug in determining when recovery has reached consistency. 2014-01-08 15:03:09 +02:00
bootstrap Update copyright for 2014 2014-01-07 16:05:30 -05:00
catalog Update copyright for 2014 2014-01-07 16:05:30 -05:00
commands Update copyright for 2014 2014-01-07 16:05:30 -05:00
executor Update copyright for 2014 2014-01-07 16:05:30 -05:00
foreign Update copyright for 2014 2014-01-07 16:05:30 -05:00
lib Update copyright for 2014 2014-01-07 16:05:30 -05:00
libpq Update copyright for 2014 2014-01-07 16:05:30 -05:00
main Update copyright for 2014 2014-01-07 16:05:30 -05:00
nodes Update copyright for 2014 2014-01-07 16:05:30 -05:00
optimizer Update copyright for 2014 2014-01-07 16:05:30 -05:00
parser Update copyright for 2014 2014-01-07 16:05:30 -05:00
po Translation updates 2013-12-02 00:17:07 -05:00
port Update copyright for 2014 2014-01-07 16:05:30 -05:00
postmaster Update copyright for 2014 2014-01-07 16:05:30 -05:00
regex Update copyright for 2014 2014-01-07 16:05:30 -05:00
replication Update copyright for 2014 2014-01-07 16:05:30 -05:00
rewrite Update copyright for 2014 2014-01-07 16:05:30 -05:00
snowball Update copyright for 2014 2014-01-07 16:05:30 -05:00
storage Update copyright for 2014 2014-01-07 16:05:30 -05:00
tcop Update copyright for 2014 2014-01-07 16:05:30 -05:00
tsearch Update copyright for 2014 2014-01-07 16:05:30 -05:00
utils Update copyright for 2014 2014-01-07 16:05:30 -05:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
common.mk Remove maintainer-check target, fold into normal build 2013-10-10 20:11:56 -04:00
Makefile Update copyright for 2014 2014-01-07 16:05:30 -05:00
nls.mk Add libpgcommon to backend gettext source files 2013-10-19 13:49:05 -04:00