postgresql/src
Tom Lane 78db307bb2 Defend against bad relfrozenxid/relminmxid/datfrozenxid/datminmxid values.
In commit a61daa14d5, we fixed pg_upgrade so
that it would install sane relminmxid and datminmxid values, but that does
not cure the problem for installations that were already pg_upgraded to
9.3; they'll initially have "1" in those fields.  This is not a big problem
so long as 1 is "in the past" compared to the current nextMultiXact
counter.  But if an installation were more than halfway to the MXID wrap
point at the time of upgrade, 1 would appear to be "in the future" and
that would effectively disable tracking of oldest MXIDs in those
tables/databases, until such time as the counter wrapped around.

While in itself this isn't worse than the situation pre-9.3, where we did
not manage MXID wraparound risk at all, the consequences of premature
truncation of pg_multixact are worse now; so we ought to make some effort
to cope with this.  We discussed advising users to fix the tracking values
manually, but that seems both very tedious and very error-prone.

Instead, this patch adopts two amelioration rules.  First, a relminmxid
value that is "in the future" is allowed to be overwritten with a
full-table VACUUM's actual freeze cutoff, ignoring the normal rule that
relminmxid should never go backwards.  (This essentially assumes that we
have enough defenses in place that wraparound can never occur anymore,
and thus that a value "in the future" must be corrupt.)  Second, if we see
any "in the future" values then we refrain from truncating pg_clog and
pg_multixact.  This prevents loss of clog data until we have cleaned up
all the broken tracking data.  In the worst case that could result in
considerable clog bloat, but in practice we expect that relfrozenxid-driven
freezing will happen soon enough to fix the problem before clog bloat
becomes intolerable.  (Users could do manual VACUUM FREEZEs if not.)

Note that this mechanism cannot save us if there are already-wrapped or
already-truncated-away MXIDs in the table; it's only capable of dealing
with corrupt tracking values.  But that's the situation we have with the
pg_upgrade bug.

For consistency, apply the same rules to relfrozenxid/datfrozenxid.  There
are not known mechanisms for these to get messed up, but if they were, the
same tactics seem appropriate for fixing them.
2014-07-21 11:41:53 -04:00
..
backend Defend against bad relfrozenxid/relminmxid/datfrozenxid/datminmxid values. 2014-07-21 11:41:53 -04:00
bin Properly use DEFAULT_EVENT_SOURCE in pgevent.c 2014-07-21 12:24:00 +02:00
common pgindent run for 9.4 2014-05-06 12:12:18 -04:00
include Add option to pg_ctl to choose event source for logging 2014-07-17 12:42:08 +02:00
interfaces Translation updates 2014-07-21 01:08:04 -04:00
makefiles Add file version information to most installed Windows binaries. 2014-07-14 14:07:52 -04:00
pl Translation updates 2014-07-21 01:08:04 -04:00
port Add mkdtemp() to libpgport. 2014-06-14 09:41:13 -04:00
template Remove Alpha and Tru64 support. 2014-06-28 21:46:15 +02:00
test Partial fix for dropped columns in functions returning composite. 2014-07-19 14:28:52 -04:00
timezone Update time zone data files to tzdata release 2014e. 2014-07-19 15:00:50 -04:00
tools Remove dependency on wsock32.lib in favor of ws2_32 2014-07-15 14:18:39 +02:00
tutorial Adjust blank lines around PG_MODULE_MAGIC defines, for consistency 2014-07-10 14:02:08 -04:00
.gitignore Convert cvsignore to gitignore, and add .gitignore for build targets. 2010-09-22 12:57:04 +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 Create libpgcommon, and move pg_malloc et al to it 2013-02-12 11:21:05 -03:00
Makefile.global.in Support vpath builds in TAP tests 2014-07-02 21:47:07 -04:00
Makefile.shlib Remove Alpha and Tru64 support. 2014-06-28 21:46:15 +02:00
bcc32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00
nls-global.mk Setup error context callback for transaction lock waits 2014-03-19 15:10:36 -03:00
win32.mak Autoconfiscate selection of 64-bit int type for 64-bit large object API. 2012-10-07 21:52:43 -04:00