From 48188e1621bb6711e7d092bee48523b18cd80177 Mon Sep 17 00:00:00 2001 From: Tom Lane Date: Sun, 5 Nov 2006 22:42:10 +0000 Subject: Fix recently-understood problems with handling of XID freezing, particularly in PITR scenarios. We now WAL-log the replacement of old XIDs with FrozenTransactionId, so that such replacement is guaranteed to propagate to PITR slave databases. Also, rather than relying on hint-bit updates to be preserved, pg_clog is not truncated until all instances of an XID are known to have been replaced by FrozenTransactionId. Add new GUC variables and pg_autovacuum columns to allow management of the freezing policy, so that users can trade off the size of pg_clog against the amount of freezing work done. Revise the already-existing code that forces autovacuum of tables approaching the wraparound point to make it more bulletproof; also, revise the autovacuum logic so that anti-wraparound vacuuming is done per-table rather than per-database. initdb forced because of changes in pg_class, pg_database, and pg_autovacuum catalogs. Heikki Linnakangas, Simon Riggs, and Tom Lane. --- doc/src/sgml/catalogs.sgml | 83 ++++++++++++++++++++++++---------------------- 1 file changed, 43 insertions(+), 40 deletions(-) (limited to 'doc/src/sgml/catalogs.sgml') diff --git a/doc/src/sgml/catalogs.sgml b/doc/src/sgml/catalogs.sgml index af28a26b1a0..1ade58644e9 100644 --- a/doc/src/sgml/catalogs.sgml +++ b/doc/src/sgml/catalogs.sgml @@ -1,4 +1,4 @@ - + @@ -1241,6 +1241,20 @@ Custom vacuum_cost_limit parameter + + + freeze_min_age + integer + + Custom vacuum_freeze_min_age parameter + + + + freeze_max_age + integer + + Custom autovacuum_freeze_max_age parameter + @@ -1258,6 +1272,17 @@ live tuples currently estimated to be in the relation. + + Also, the autovacuum daemon will perform a VACUUM operation + to prevent transaction ID wraparound if the table's + pg_class.relfrozenxid field attains an age + of more than freeze_max_age transactions, whether the table + has been changed or not. The system will launch autovacuum to perform + such VACUUMs even if autovacuum is otherwise disabled. + See for more about wraparound + prevention. + + Any of the numerical fields can contain -1 (or indeed any negative value) to indicate that the system-wide default should @@ -1266,6 +1291,10 @@ autovacuum_vacuum_cost_delay configuration parameter, or from vacuum_cost_delay if the former is set to a negative value. The same applies to vac_cost_limit. + Also, autovacuum will ignore attempts to set a per-table + freeze_max_age larger than the system-wide setting (it can only be set + smaller), and the freeze_min_age value will be limited to half the + system-wide autovacuum_freeze_max_age setting. @@ -1633,26 +1662,15 @@ - relminxid + relfrozenxid xid - The minimum transaction ID present in all rows in this table. This - value is used to determine the database-global - pg_database.datminxid value. - - - - - relvacuumxid - xid - - - The transaction ID that was used as cleaning point as of the last vacuum - operation. All rows inserted, updated or deleted in this table by - transactions whose IDs are below this one have been marked as known good - or deleted. This is used to determine the database-global - pg_database.datvacuumxid value. + All transaction IDs before this one have been replaced with a permanent + (frozen) transaction ID in this table. This is used to track + whether the table needs to be vacuumed in order to prevent transaction + ID wraparound or to allow pg_clog to be shrunk. Zero + (InvalidTransactionId) if the relation is not a table. @@ -2035,31 +2053,16 @@ - datvacuumxid - xid - - - The transaction ID that was used as cleaning point as of the last vacuum - operation. All rows inserted or deleted by transaction IDs before this one - have been marked as known good or deleted. This - is used to determine when commit-log space can be recycled. - If InvalidTransactionId, then the minimum is unknown and can be - determined by scanning pg_class.relvacuumxid. - - - - - datminxid + datfrozenxid xid - The minimum transaction ID present in all tables in this database. - All rows inserted by transaction IDs before this one have been - relabeled with a permanent (frozen) transaction ID in this - database. This is useful to check whether a database must be - vacuumed soon to avoid transaction ID wrap-around problems. - If InvalidTransactionId, then the minimum is unknown and can be - determined by scanning pg_class.relminxid. + All transaction IDs before this one have been replaced with a permanent + (frozen) transaction ID in this database. This is used to + track whether the database needs to be vacuumed in order to prevent + transaction ID wraparound or to allow pg_clog to be shrunk. + It is the minimum of the per-table + pg_class.relfrozenxid values. -- cgit v1.2.3