postgresql/src/backend
Heikki Linnakangas 970fb12de1 Consistency check should compare last record replayed, not last record read.
EndRecPtr is the last record that we've read, but not necessarily yet
replayed. CheckRecoveryConsistency should compare minRecoveryPoint with the
last replayed record instead. This caused recovery to think it's reached
consistency too early.

Now that we do the check in CheckRecoveryConsistency correctly, we have to
move the call of that function to after redoing a record. The current place,
after reading a record but before replaying it, is wrong. In particular, if
there are no more records after the one ending at minRecoveryPoint, we don't
enter hot standby until one extra record is generated and read by the
standby, and CheckRecoveryConsistency is called. These two bugs conspired
to make the code appear to work correctly, except for the small window
between reading the last record that reaches minRecoveryPoint, and
replaying it.

In the passing, rename recoveryLastRecPtr, which is the last record
replayed, to lastReplayedEndRecPtr. This makes it slightly less confusing
with replayEndRecPtr, which is the last record read that we're about to
replay.

Original report from Kyotaro HORIGUCHI, further diagnosis by Fujii Masao.
Backpatch to 9.0, where Hot Standby subtly changed the test from
"minRecoveryPoint < EndRecPtr" to "minRecoveryPoint <= EndRecPtr". The
former works because where the test is performed, we have always read one
more record than we've replayed.
2012-12-11 18:54:02 +02:00
..
access Consistency check should compare last record replayed, not last record read. 2012-12-11 18:54:02 +02:00
bootstrap Add context info to OAT_POST_CREATE security hook 2012-10-23 18:24:24 -03:00
catalog Update minimum recovery point on truncation. 2012-12-10 16:57:16 +02:00
commands Optimize COPY FREEZE with CREATE TABLE also. 2012-12-07 13:26:52 +00:00
executor Support automatically-updatable views. 2012-12-08 18:26:21 -05:00
foreign Split tuple struct defs from htup.h to htup_details.h 2012-08-30 16:52:35 -04:00
lib Basic binary heap implementation. 2012-11-29 11:16:59 -05:00
libpq Attempt to un-break Windows builds with USE_LDAP. 2012-12-04 17:25:51 -05:00
main Unify calling conventions for postgres/postmaster sub-main functions 2012-06-25 21:30:12 +03:00
nodes Fix planning of non-strict equivalence clauses above outer joins. 2012-10-18 12:30:10 -04:00
optimizer Fix assorted bugs in CREATE/DROP INDEX CONCURRENTLY. 2012-11-28 21:26:01 -05:00
parser COPY FREEZE and mark committed on fresh tables. 2012-12-01 12:54:20 +00:00
po Translation updates 2011-08-17 14:07:46 +03:00
port Change test ExceptionalCondition to return void 2012-11-30 19:24:21 -03:00
postmaster Background worker processes 2012-12-06 17:47:30 -03:00
regex Prevent corner-case core dump in rfree(). 2012-07-15 13:27:54 -04:00
replication Make the streaming replication protocol messages architecture-independent. 2012-11-07 19:09:13 +02:00
rewrite Support automatically-updatable views. 2012-12-08 18:26:21 -05:00
snowball Remove configure flag --disable-shared, as it is no longer used by any 2012-08-30 16:26:53 -04:00
storage Background worker processes 2012-12-06 17:47:30 -03:00
tcop Allow adding values to an enum type created in the current transaction. 2012-12-01 14:27:30 -05:00
tsearch Fix logical errors in tsquery selectivity estimation for prefix queries. 2012-09-11 21:23:20 -04:00
utils Support automatically-updatable views. 2012-12-08 18:26:21 -05:00
.gitignore Add gitignore for mingw/cygwin build outputs 2011-06-09 18:11:47 +02:00
common.mk Call check_keywords.pl in maintainer-check 2012-02-27 13:53:12 +02:00
Makefile Fix PGXS support for building loadable modules on AIX. 2012-10-09 21:04:06 -04:00
nls.mk Sort file list when creating gettext-files 2011-12-27 20:20:56 +02:00