aboutsummaryrefslogtreecommitdiff
path: root/src/backend/commands/vacuumlazy.c
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2013-11-28 16:52:54 -0300
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2013-11-29 21:48:11 -0300
commitf5f92bdc44ffdf577244e0d055825cacd0cdea10 (patch)
treee2314619870700916729b33348a33d94f394b22c /src/backend/commands/vacuumlazy.c
parentd9484ab5f3cbcfea64536fec333723f9aa4c0b2c (diff)
downloadpostgresql-f5f92bdc44ffdf577244e0d055825cacd0cdea10.tar.gz
postgresql-f5f92bdc44ffdf577244e0d055825cacd0cdea10.zip
Fix full-table-vacuum request mechanism for MultiXactIds
While autovacuum dutifully launched anti-multixact-wraparound vacuums when the multixact "age" was reached, the vacuum code was not aware that it needed to make them be full table vacuums. As the resulting partial-table vacuums aren't capable of actually increasing relminmxid, autovacuum continued to launch anti-wraparound vacuums that didn't have the intended effect, until age of relfrozenxid caused the vacuum to finally be a full table one via vacuum_freeze_table_age. To fix, introduce logic for multixacts similar to that for plain TransactionIds, using the same GUCs. Backpatch to 9.3, where permanent MultiXactIds were introduced. Andres Freund, some cleanup by Álvaro
Diffstat (limited to 'src/backend/commands/vacuumlazy.c')
-rw-r--r--src/backend/commands/vacuumlazy.c18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/backend/commands/vacuumlazy.c b/src/backend/commands/vacuumlazy.c
index 93ea0851242..ff6bd8e5b06 100644
--- a/src/backend/commands/vacuumlazy.c
+++ b/src/backend/commands/vacuumlazy.c
@@ -180,7 +180,8 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
write_rate;
bool scan_all; /* should we scan all pages? */
bool scanned_all; /* did we actually scan all pages? */
- TransactionId freezeTableLimit;
+ TransactionId xidFullScanLimit;
+ MultiXactId mxactFullScanLimit;
BlockNumber new_rel_pages;
double new_rel_tuples;
BlockNumber new_rel_allvisible;
@@ -203,10 +204,19 @@ lazy_vacuum_rel(Relation onerel, VacuumStmt *vacstmt,
vacuum_set_xid_limits(vacstmt->freeze_min_age, vacstmt->freeze_table_age,
onerel->rd_rel->relisshared,
- &OldestXmin, &FreezeLimit, &freezeTableLimit,
- &MultiXactCutoff);
+ &OldestXmin, &FreezeLimit, &xidFullScanLimit,
+ &MultiXactCutoff, &mxactFullScanLimit);
+
+ /*
+ * We request a full scan if either the table's frozen Xid is now older
+ * than or equal to the requested Xid full-table scan limit; or if the
+ * table's minimum MultiXactId is older than or equal to the requested mxid
+ * full-table scan limit.
+ */
scan_all = TransactionIdPrecedesOrEquals(onerel->rd_rel->relfrozenxid,
- freezeTableLimit);
+ xidFullScanLimit);
+ scan_all |= MultiXactIdPrecedesOrEquals(onerel->rd_rel->relminmxid,
+ mxactFullScanLimit);
vacrelstats = (LVRelStats *) palloc0(sizeof(LVRelStats));