pgsql: Initialize the minimum frozen Xid in vac_update_datfrozenxid

From: alvherre(at)postgresql(dot)org (Alvaro Herrera)
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Initialize the minimum frozen Xid in vac_update_datfrozenxid
Date: 2008-09-11 14:01:36
Message-ID: 20080911140136.1A9A67545A3@cvs.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Log Message:
-----------
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(dot)1221061979(at)sss(dot)pgh(dot)pa(dot)us

Tags:
----
REL8_3_STABLE

Modified Files:
--------------
pgsql/src/backend/access/heap:
heapam.c (r1.249.2.2 -> r1.249.2.3)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/heap/heapam.c?r1=1.249.2.2&r2=1.249.2.3)
pgsql/src/backend/access/index:
indexam.c (r1.101 -> r1.101.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/access/index/indexam.c?r1=1.101&r2=1.101.2.1)
pgsql/src/backend/commands:
vacuum.c (r1.364.2.1 -> r1.364.2.2)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/commands/vacuum.c?r1=1.364.2.1&r2=1.364.2.2)
pgsql/src/backend/executor:
nodeBitmapHeapscan.c (r1.22 -> r1.22.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/executor/nodeBitmapHeapscan.c?r1=1.22&r2=1.22.2.1)
pgsql/src/backend/utils/init:
postinit.c (r1.180 -> r1.180.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/init/postinit.c?r1=1.180&r2=1.180.2.1)
pgsql/src/backend/utils/time:
tqual.c (r1.109 -> r1.109.2.1)
(http://anoncvs.postgresql.org/cvsweb.cgi/pgsql/src/backend/utils/time/tqual.c?r1=1.109&r2=1.109.2.1)

Browse pgsql-committers by date

  From Date Subject
Next Message User Mkz 2008-09-11 14:44:51 plproxy - plproxy: more serious encoding test
Previous Message Alvaro Herrera 2008-09-11 14:01:16 pgsql: Initialize the minimum frozen Xid in vac_update_datfrozenxid