You signed in with another tab or window.Reload to refresh your session.You signed out in another tab or window.Reload to refresh your session.You switched accounts on another tab or window.Reload to refresh your session.Dismiss alert
Defend against bad relfrozenxid/relminmxid/datfrozenxid/datminmxid values.
In commita61daa1, we fixed pg_upgrade sothat it would install sane relminmxid and datminmxid values, but that doesnot cure the problem for installations that were already pg_upgraded to9.3; they'll initially have "1" in those fields. This is not a big problemso long as 1 is "in the past" compared to the current nextMultiXactcounter. But if an installation were more than halfway to the MXID wrappoint at the time of upgrade, 1 would appear to be "in the future" andthat would effectively disable tracking of oldest MXIDs in thosetables/databases, until such time as the counter wrapped around.While in itself this isn't worse than the situation pre-9.3, where we didnot manage MXID wraparound risk at all, the consequences of prematuretruncation of pg_multixact are worse now; so we ought to make some effortto cope with this. We discussed advising users to fix the tracking valuesmanually, but that seems both very tedious and very error-prone.Instead, this patch adopts two amelioration rules. First, a relminmxidvalue that is "in the future" is allowed to be overwritten with afull-table VACUUM's actual freeze cutoff, ignoring the normal rule thatrelminmxid should never go backwards. (This essentially assumes that wehave enough defenses in place that wraparound can never occur anymore,and thus that a value "in the future" must be corrupt.) Second, if we seeany "in the future" values then we refrain from truncating pg_clog andpg_multixact. This prevents loss of clog data until we have cleaned upall the broken tracking data. In the worst case that could result inconsiderable clog bloat, but in practice we expect that relfrozenxid-drivenfreezing will happen soon enough to fix the problem before clog bloatbecomes intolerable. (Users could do manual VACUUM FREEZEs if not.)Note that this mechanism cannot save us if there are already-wrapped oralready-truncated-away MXIDs in the table; it's only capable of dealingwith corrupt tracking values. But that's the situation we have with thepg_upgrade bug.For consistency, apply the same rules to relfrozenxid/datfrozenxid. Thereare not known mechanisms for these to get messed up, but if they were, thesame tactics seem appropriate for fixing them.