diff options
author | Robert Haas | 2015-05-08 16:09:14 +0000 |
---|---|---|
committer | Robert Haas | 2015-05-08 16:53:00 +0000 |
commit | 53bb309d2d5a9432d2602c93ed18e58bd2924e15 (patch) | |
tree | eb9d0ab30c1d3822831a79c87cde04d549ddcaeb /src/backend/commands | |
parent | 195fbd40123b85ba8a44ca273b17d699e30ec6a8 (diff) |
Teach autovacuum about multixact member wraparound.
The logic introduced in commit b69bf30b9bfacafc733a9ba77c9587cf54d06c0c
and repaired in commits 669c7d20e6374850593cb430d332e11a3992bbcf and
7be47c56af3d3013955c91c2877c08f2a0e3e6a2 helps to ensure that we don't
overwrite old multixact member information while it is still needed,
but a user who creates many large multixacts can still exhaust the
member space (and thus start getting errors) while autovacuum stands
idly by.
To fix this, progressively ramp down the effective value (but not the
actual contents) of autovacuum_multixact_freeze_max_age as member space
utilization increases. This makes autovacuum more aggressive and also
reduces the threshold for a manual VACUUM to perform a full-table scan.
This patch leaves unsolved the problem of ensuring that emergency
autovacuums are triggered even when autovacuum=off. We'll need to fix
that via a separate patch.
Thomas Munro and Robert Haas
Diffstat (limited to 'src/backend/commands')
-rw-r--r-- | src/backend/commands/vacuum.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 7ead1617603..34ca325a9b6 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -471,6 +471,7 @@ vacuum_set_xid_limits(Relation rel, { int freezemin; int mxid_freezemin; + int effective_multixact_freeze_max_age; TransactionId limit; TransactionId safeLimit; MultiXactId mxactLimit; @@ -528,16 +529,23 @@ vacuum_set_xid_limits(Relation rel, *freezeLimit = limit; /* + * Compute the multixact age for which freezing is urgent. This is + * normally autovacuum_multixact_freeze_max_age, but may be less if we + * are short of multixact member space. + */ + effective_multixact_freeze_max_age = MultiXactMemberFreezeThreshold(); + + /* * Determine the minimum multixact freeze age to use: as specified by * caller, or vacuum_multixact_freeze_min_age, but in any case not more - * than half autovacuum_multixact_freeze_max_age, so that autovacuums to + * than half effective_multixact_freeze_max_age, so that autovacuums to * prevent MultiXact wraparound won't occur too frequently. */ mxid_freezemin = multixact_freeze_min_age; if (mxid_freezemin < 0) mxid_freezemin = vacuum_multixact_freeze_min_age; mxid_freezemin = Min(mxid_freezemin, - autovacuum_multixact_freeze_max_age / 2); + effective_multixact_freeze_max_age / 2); Assert(mxid_freezemin >= 0); /* compute the cutoff multi, being careful to generate a valid value */ @@ -546,7 +554,7 @@ vacuum_set_xid_limits(Relation rel, mxactLimit = FirstMultiXactId; safeMxactLimit = - ReadNextMultiXactId() - autovacuum_multixact_freeze_max_age; + ReadNextMultiXactId() - effective_multixact_freeze_max_age; if (safeMxactLimit < FirstMultiXactId) safeMxactLimit = FirstMultiXactId; @@ -601,7 +609,7 @@ vacuum_set_xid_limits(Relation rel, if (freezetable < 0) freezetable = vacuum_multixact_freeze_table_age; freezetable = Min(freezetable, - autovacuum_multixact_freeze_max_age * 0.95); + effective_multixact_freeze_max_age * 0.95); Assert(freezetable >= 0); /* |