aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2014-07-30 14:41:35 -0400
committerTom Lane <tgl@sss.pgh.pa.us>2014-07-30 14:41:58 -0400
commitf21afe42146371ee15d4364c0e9e3d64ac317ddf (patch)
treea8fa1433432528b446c2ea049057e1940b79a636 /src
parentde88ec6bf45477cd02905a8802e79868cb2ffdc3 (diff)
downloadpostgresql-f21afe42146371ee15d4364c0e9e3d64ac317ddf.tar.gz
postgresql-f21afe42146371ee15d4364c0e9e3d64ac317ddf.zip
Avoid wholesale autovacuuming when autovacuum is nominally off.
When autovacuum is nominally off, we will still launch autovac workers to vacuum tables that are at risk of XID wraparound. But after we'd done that, an autovac worker would proceed to autovacuum every table in the targeted database, if they meet the usual thresholds for autovacuuming. This is at best pretty unexpected; at worst it delays response to the wraparound threat. Fix it so that if autovacuum is nominally off, we *only* do forced vacuums and not any other work. Per gripe from Andrey Zhidenkov. This has been like this all along, so back-patch to all supported branches.
Diffstat (limited to 'src')
-rw-r--r--src/backend/postmaster/autovacuum.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 4ff5d877115..4f3bd711494 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -2656,14 +2656,21 @@ relation_needs_vacanalyze(Oid relid,
*wraparound = force_vacuum;
/* User disabled it in pg_class.reloptions? (But ignore if at risk) */
- if (!force_vacuum && !av_enabled)
+ if (!av_enabled && !force_vacuum)
{
*doanalyze = false;
*dovacuum = false;
return;
}
- if (PointerIsValid(tabentry))
+ /*
+ * If we found the table in the stats hash, and autovacuum is currently
+ * enabled, make a threshold-based decision whether to vacuum and/or
+ * analyze. If autovacuum is currently disabled, we must be here for
+ * anti-wraparound vacuuming only, so don't vacuum (or analyze) anything
+ * that's not being forced.
+ */
+ if (PointerIsValid(tabentry) && AutoVacuumingActive())
{
reltuples = classForm->reltuples;
vactuples = tabentry->n_dead_tuples;