postgresql/src
Heikki Linnakangas f22624cea5 Fix Hot-Standby initialization of clog and subtrans.
These bugs can cause data loss on standbys started with hot_standby=on at
the moment they start to accept read only queries, by marking committed
transactions as uncommited. The likelihood of such corruptions is small
unless the primary has a high transaction rate.

5a031a5556 fixed bugs in HS's startup logic
by maintaining less state until at least STANDBY_SNAPSHOT_PENDING state
was reached, missing the fact that both clog and subtrans are written to
before that. This only failed to fail in common cases because the usage
of ExtendCLOG in procarray.c was superflous since clog extensions are
actually WAL logged.

f44eedc3f0f347a856eea8590730769125964597/I then tried to fix the missing
extensions of pg_subtrans due to the former commit's changes - which are
not WAL logged - by performing the extensions when switching to a state
> STANDBY_INITIALIZED and not performing xid assignments before that -
again missing the fact that ExtendCLOG is unneccessary - but screwed up
twice: Once because latestObservedXid wasn't updated anymore in that
state due to the earlier commit and once by having an off-by-one error in
the loop performing extensions. This means that whenever a
CLOG_XACTS_PER_PAGE (32768 with default settings) boundary was crossed
between the start of the checkpoint recovery started from and the first
xl_running_xact record old transactions commit bits in pg_clog could be
overwritten if they started and committed in that window.

Fix this mess by not performing ExtendCLOG() in HS at all anymore since
it's unneeded and evidently dangerous and by performing subtrans
extensions even before reaching STANDBY_SNAPSHOT_PENDING.

Analysis and patch by Andres Freund. Reported by Christophe Pettus.
Backpatch down to 9.0, like the previous commit that caused this.
2013-11-22 14:48:43 +02:00
..
backend Fix Hot-Standby initialization of clog and subtrans. 2013-11-22 14:48:43 +02:00
bin Don't abort pg_basebackup when receiving empty WAL block 2013-11-11 14:34:06 +01:00
include Compute correct em_nullable_relids in get_eclass_for_sort_expr(). 2013-11-15 16:46:25 -05:00
interfaces Changed test case slightly so it doesn't have an unused typedef. 2013-11-03 15:40:08 +01:00
makefiles Revert "Backpatch pgxs vpath build and installation fixes (v2)" 2013-10-07 22:37:26 -04:00
pl Translation updates 2013-10-07 16:17:51 -04:00
port Stamp 9.2.5. 2013-10-07 23:16:13 -04:00
template Remove BSD/OS (BSDi) port. There are no known users upgrading to 2012-05-03 10:58:44 -04:00
test Compute correct em_nullable_relids in get_eclass_for_sort_expr(). 2013-11-15 16:46:25 -05:00
timezone Fix some odd behaviors when using a SQL-style simple GMT offset timezone. 2013-11-01 12:13:26 -04:00
tools Avoid renaming data directory during MSVC upgrade testing. 2013-03-23 16:31:01 -04:00
tutorial Modernize string literal syntax in tutorial example. 2013-01-19 17:20:56 -05:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +02:00
bcc32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00
DEVELOPERS Replace a couple of references to files that no longer exist in the source 2009-05-04 08:08:47 +00:00
Makefile Fix some oversights in distprep and maintainer-clean targets. 2011-03-10 00:04:05 -05:00
Makefile.global.in Revert "Backpatch pgxs vpath build and installation fixes (v2)" 2013-10-07 22:37:26 -04:00
Makefile.shlib Remove BSD/OS (BSDi) port. There are no known users upgrading to 2012-05-03 10:58:44 -04:00
nls-global.mk Lots of doc corrections. 2012-04-23 22:43:09 -04:00
win32.mak Remove useless whitespace at end of lines 2010-11-23 22:34:55 +02:00