aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/flatfiles.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2009-08-31 02:23:23 +0000
committerTom Lane <tgl@sss.pgh.pa.us>2009-08-31 02:23:23 +0000
commit25ec228ef760eb91c094cc3b6dea7257cc22ffb5 (patch)
tree59d9d82fa2a61c1c27174d9b2f462536a7db39ee /src/backend/utils/init/flatfiles.c
parente1cc64197bd3a8d6fd5e4ca6830d514130f2737f (diff)
downloadpostgresql-25ec228ef760eb91c094cc3b6dea7257cc22ffb5.tar.gz
postgresql-25ec228ef760eb91c094cc3b6dea7257cc22ffb5.zip
Track the current XID wrap limit (or more accurately, the oldest unfrozen
XID) in checkpoint records. This eliminates the need to recompute the value from scratch during database startup, which is one of the two remaining reasons for the flatfile code to exist. It should also simplify life for hot-standby operation. To avoid bloating the checkpoint records unreasonably, I switched from tracking the oldest database by name to tracking it by OID. This turns out to save cycles in general (everywhere but the warning-generating paths, which we hardly care about) and also helps us deal with the case that the oldest database got dropped instead of being vacuumed. The prior coding might go for a long time without updating the wrap limit in that case, which is bad because it might result in a lot of useless autovacuum activity.
Diffstat (limited to 'src/backend/utils/init/flatfiles.c')
-rw-r--r--src/backend/utils/init/flatfiles.c27
1 files changed, 1 insertions, 26 deletions
diff --git a/src/backend/utils/init/flatfiles.c b/src/backend/utils/init/flatfiles.c
index fbbd372b141..38271653f6d 100644
--- a/src/backend/utils/init/flatfiles.c
+++ b/src/backend/utils/init/flatfiles.c
@@ -23,7 +23,7 @@
* Portions Copyright (c) 1996-2009, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
- * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.38 2009/08/29 19:26:51 tgl Exp $
+ * $PostgreSQL: pgsql/src/backend/utils/init/flatfiles.c,v 1.39 2009/08/31 02:23:22 tgl Exp $
*
*-------------------------------------------------------------------------
*/
@@ -166,9 +166,6 @@ name_okay(const char *str)
/*
* write_database_file: update the flat database file
- *
- * A side effect is to determine the oldest database's datfrozenxid
- * so we can set or update the XID wrap limit.
*/
static void
write_database_file(Relation drel)
@@ -180,8 +177,6 @@ write_database_file(Relation drel)
mode_t oumask;
HeapScanDesc scan;
HeapTuple tuple;
- NameData oldest_datname;
- TransactionId oldest_datfrozenxid = InvalidTransactionId;
/*
* Create a temporary filename to be renamed later. This prevents the
@@ -220,20 +215,6 @@ write_database_file(Relation drel)
datfrozenxid = dbform->datfrozenxid;
/*
- * Identify the oldest datfrozenxid. This must match the logic in
- * vac_truncate_clog() in vacuum.c.
- */
- if (TransactionIdIsNormal(datfrozenxid))
- {
- if (oldest_datfrozenxid == InvalidTransactionId ||
- TransactionIdPrecedes(datfrozenxid, oldest_datfrozenxid))
- {
- oldest_datfrozenxid = datfrozenxid;
- namestrcpy(&oldest_datname, datname);
- }
- }
-
- /*
* Check for illegal characters in the database name.
*/
if (!name_okay(datname))
@@ -270,12 +251,6 @@ write_database_file(Relation drel)
(errcode_for_file_access(),
errmsg("could not rename file \"%s\" to \"%s\": %m",
tempname, filename)));
-
- /*
- * Set the transaction ID wrap limit using the oldest datfrozenxid
- */
- if (oldest_datfrozenxid != InvalidTransactionId)
- SetTransactionIdLimit(oldest_datfrozenxid, &oldest_datname);
}