agora inbox for [email protected]
help / color / mirror / Atom feedFrom: Nathan Bossart <[email protected]>
Subject: [PATCH v1 2/4] autovac: resolve relopts before vacuuming
Date: Mon, 23 Jun 2025 14:42:39 -0500
---
src/backend/commands/vacuum.c | 7 ++--
src/backend/postmaster/autovacuum.c | 52 +++++++++++++++++++++--------
2 files changed, 44 insertions(+), 15 deletions(-)
diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c
index 33a33bf6b1c..0015b9ef4b0 100644
--- a/src/backend/commands/vacuum.c
+++ b/src/backend/commands/vacuum.c
@@ -421,7 +421,7 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel)
/*
* Later, in vacuum_rel(), we check if a reloption override was specified.
*/
- params.max_eager_freeze_failure_rate = vacuum_max_eager_freeze_failure_rate;
+ params.max_eager_freeze_failure_rate = -1.0;
/*
* Create special memory context for cross-transaction storage.
@@ -2195,10 +2195,13 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params,
* Check if the vacuum_max_eager_freeze_failure_rate table storage
* parameter was specified. This overrides the GUC value.
*/
- if (rel->rd_options != NULL &&
+ if (params->max_eager_freeze_failure_rate < 0 &&
+ rel->rd_options != NULL &&
((StdRdOptions *) rel->rd_options)->vacuum_max_eager_freeze_failure_rate >= 0)
params->max_eager_freeze_failure_rate =
((StdRdOptions *) rel->rd_options)->vacuum_max_eager_freeze_failure_rate;
+ else
+ params->max_eager_freeze_failure_rate = vacuum_max_eager_freeze_failure_rate;
/*
* Set truncate option based on truncate reloption or GUC if it wasn't
diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index f86c9fed853..3bedca971ff 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -2758,6 +2758,9 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
int multixact_freeze_table_age;
int log_min_duration;
AutoVacOpts *avopts = (relopts ? &relopts->autovacuum : NULL);
+ VacOptValue index_cleanup;
+ VacOptValue truncate;
+ double max_eager_freeze_failure_rate;
/*
* Calculate the vacuum cost parameters and the freeze ages. If there
@@ -2790,6 +2793,39 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
? avopts->multixact_freeze_table_age
: default_multixact_freeze_table_age;
+ if (relopts)
+ {
+ switch (relopts->vacuum_index_cleanup)
+ {
+ case STDRD_OPTION_VACUUM_INDEX_CLEANUP_AUTO:
+ index_cleanup = VACOPTVALUE_AUTO;
+ break;
+ case STDRD_OPTION_VACUUM_INDEX_CLEANUP_ON:
+ index_cleanup = VACOPTVALUE_ENABLED;
+ break;
+ case STDRD_OPTION_VACUUM_INDEX_CLEANUP_OFF:
+ index_cleanup = VACOPTVALUE_DISABLED;
+ break;
+ }
+ }
+ else
+ index_cleanup = VACOPTVALUE_UNSPECIFIED;
+
+ if (relopts && relopts->vacuum_truncate_set)
+ {
+ if (relopts->vacuum_truncate)
+ truncate = VACOPTVALUE_ENABLED;
+ else
+ truncate = VACOPTVALUE_DISABLED;
+ }
+ else
+ truncate = VACOPTVALUE_UNSPECIFIED;
+
+ if (relopts && relopts->vacuum_max_eager_freeze_failure_rate >= 0)
+ max_eager_freeze_failure_rate = relopts->vacuum_max_eager_freeze_failure_rate;
+ else
+ max_eager_freeze_failure_rate = -1.0;
+
tab = palloc(sizeof(autovac_table));
tab->at_relid = relid;
tab->at_sharedrel = classForm->relisshared;
@@ -2806,13 +2842,8 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
(doanalyze ? VACOPT_ANALYZE : 0) |
(!wraparound ? VACOPT_SKIP_LOCKED : 0);
- /*
- * index_cleanup and truncate are unspecified at first in autovacuum.
- * They will be filled in with usable values using their reloptions
- * (or reloption defaults) later.
- */
- tab->at_params.index_cleanup = VACOPTVALUE_UNSPECIFIED;
- tab->at_params.truncate = VACOPTVALUE_UNSPECIFIED;
+ tab->at_params.index_cleanup = index_cleanup;
+ tab->at_params.truncate = truncate;
/* As of now, we don't support parallel vacuum for autovacuum */
tab->at_params.nworkers = -1;
tab->at_params.freeze_min_age = freeze_min_age;
@@ -2822,12 +2853,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
tab->at_params.is_wraparound = wraparound;
tab->at_params.log_min_duration = log_min_duration;
tab->at_params.toast_parent = InvalidOid;
-
- /*
- * Later, in vacuum_rel(), we check reloptions for any
- * vacuum_max_eager_freeze_failure_rate override.
- */
- tab->at_params.max_eager_freeze_failure_rate = vacuum_max_eager_freeze_failure_rate;
+ tab->at_params.max_eager_freeze_failure_rate = max_eager_freeze_failure_rate;
tab->at_storage_param_vac_cost_limit = avopts ?
avopts->vacuum_cost_limit : 0;
tab->at_storage_param_vac_cost_delay = avopts ?
--
2.39.5 (Apple Git-154)
--QWBYbd5Ar5k8NvSv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
filename=v1-0003-autovac-combine-reloptions-correctly.patch
view thread (795+ messages) latest in thread
reply
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: [email protected]
Cc: [email protected]
Subject: Re: [PATCH v1 2/4] autovac: resolve relopts before vacuuming
In-Reply-To: <no-message-id-1185857@localhost>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by agora; see mirroring instructions
for how to clone and mirror all data and code used for this inbox