mirror of
https://github.com/postgres/postgres.git
synced 2025-07-02 09:02:37 +03:00
Initialize the minimum frozen Xid in vac_update_datfrozenxid using
GetOldestXmin() instead of RecentGlobalXmin; this is safer because we do not depend on the latter being correctly set elsewhere, and while it is more expensive, this code path is not performance-critical. This is a real risk for autovacuum, because it can execute whole cycles without doing a single vacuum, which would mean that RecentGlobalXmin would stay at its initialization value, FirstNormalTransactionId, causing a bogus value to be inserted in pg_database. This bug could explain some recent reports of failure to truncate pg_clog. At the same time, change the initialization of RecentGlobalXmin to InvalidTransactionId, and ensure that it's set to something else whenever it's going to be used. Using it as FirstNormalTransactionId in HOT page pruning could incur in data loss. InitPostgres takes care of setting it to a valid value, but the extra checks are there to prevent "special" backends from behaving in unusual ways. Per Tom Lane's detailed problem dissection in 29544.1221061979@sss.pgh.pa.us
This commit is contained in:
@ -22,7 +22,7 @@
|
||||
* Portions Copyright (c) 1994, Regents of the University of California
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.4 2008/07/11 02:10:14 alvherre Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/utils/time/snapmgr.c,v 1.5 2008/09/11 14:01:10 alvherre Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -59,10 +59,14 @@ static Snapshot SecondarySnapshot = NULL;
|
||||
* These are updated by GetSnapshotData. We initialize them this way
|
||||
* for the convenience of TransactionIdIsInProgress: even in bootstrap
|
||||
* mode, we don't want it to say that BootstrapTransactionId is in progress.
|
||||
*
|
||||
* RecentGlobalXmin is initialized to InvalidTransactionId, to ensure that no
|
||||
* one tries to use a stale value. Readers should ensure that it has been set
|
||||
* to something else before using it.
|
||||
*/
|
||||
TransactionId TransactionXmin = FirstNormalTransactionId;
|
||||
TransactionId RecentXmin = FirstNormalTransactionId;
|
||||
TransactionId RecentGlobalXmin = FirstNormalTransactionId;
|
||||
TransactionId RecentGlobalXmin = InvalidTransactionId;
|
||||
|
||||
/*
|
||||
* Elements of the list of registered snapshots.
|
||||
|
Reference in New Issue
Block a user