agora inbox for [email protected]  
help / color / mirror / Atom feed
From: Nathan Bossart <[email protected]>
Subject: [PATCH v1 3/4] autovac: combine reloptions correctly
Date: Mon, 23 Jun 2025 15:16:38 -0500

---
 src/backend/postmaster/autovacuum.c | 85 +++++++++++++++++++++++++++++
 1 file changed, 85 insertions(+)

diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c
index 3bedca971ff..0d1f4e38b58 100644
--- a/src/backend/postmaster/autovacuum.c
+++ b/src/backend/postmaster/autovacuum.c
@@ -1873,6 +1873,73 @@ get_database_list(void)
 	return dblist;
 }
 
+static void
+combine_relopts(StdRdOptions *toast_opts, const StdRdOptions *main_opts)
+{
+	AutoVacOpts *toast_avopts = &toast_opts->autovacuum;
+	const AutoVacOpts *main_avopts = &main_opts->autovacuum;
+
+	/* XXX: need isset_offset to combine "enabled" */
+
+	if (toast_avopts->vacuum_threshold == -1)
+		toast_avopts->vacuum_threshold = main_avopts->vacuum_threshold;
+
+	if (toast_avopts->vacuum_max_threshold == -2)
+		toast_avopts->vacuum_max_threshold = main_avopts->vacuum_max_threshold;
+
+	if (toast_avopts->vacuum_ins_threshold == -2)
+		toast_avopts->vacuum_ins_threshold = main_avopts->vacuum_ins_threshold;
+
+	if (toast_avopts->analyze_threshold == -1)
+		toast_avopts->analyze_threshold = main_avopts->analyze_threshold;
+
+	if (toast_avopts->vacuum_cost_limit == -1)
+		toast_avopts->vacuum_cost_limit = main_avopts->vacuum_cost_limit;
+
+	if (toast_avopts->freeze_min_age == -1)
+		toast_avopts->freeze_min_age = main_avopts->freeze_min_age;
+
+	if (toast_avopts->freeze_max_age == -1)
+		toast_avopts->freeze_max_age = main_avopts->freeze_max_age;
+
+	if (toast_avopts->freeze_table_age == -1)
+		toast_avopts->freeze_table_age = main_avopts->freeze_table_age;
+
+	if (toast_avopts->multixact_freeze_min_age == -1)
+		toast_avopts->multixact_freeze_min_age = main_avopts->multixact_freeze_min_age;
+
+	if (toast_avopts->multixact_freeze_max_age == -1)
+		toast_avopts->multixact_freeze_max_age = main_avopts->multixact_freeze_max_age;
+
+	if (toast_avopts->multixact_freeze_table_age == -1)
+		toast_avopts->multixact_freeze_table_age = main_avopts->multixact_freeze_table_age;
+
+	/* XXX: need isset_offset for log_min_duration */
+
+	if (toast_avopts->vacuum_cost_delay == -1)
+		toast_avopts->vacuum_cost_delay = main_avopts->vacuum_cost_delay;
+
+	if (toast_avopts->vacuum_scale_factor == -1)
+		toast_avopts->vacuum_scale_factor = main_avopts->vacuum_scale_factor;
+
+	if (toast_avopts->vacuum_ins_scale_factor == -1)
+		toast_avopts->vacuum_ins_scale_factor = main_avopts->vacuum_ins_scale_factor;
+
+	if (toast_avopts->analyze_scale_factor == -1)
+		toast_avopts->analyze_scale_factor = main_avopts->analyze_scale_factor;
+
+	/* XXX: need isset_offset for vacuum_index_cleanup */
+
+	if (!toast_opts->vacuum_truncate_set && main_opts->vacuum_truncate_set)
+	{
+		toast_opts->vacuum_truncate = main_opts->vacuum_truncate;
+		toast_opts->vacuum_truncate_set = true;
+	}
+
+	if (toast_opts->vacuum_max_eager_freeze_failure_rate == -1)
+		toast_opts->vacuum_max_eager_freeze_failure_rate = main_opts->vacuum_max_eager_freeze_failure_rate;
+}
+
 /*
  * Process a database table-by-table
  *
@@ -2113,7 +2180,16 @@ do_autovacuum(void)
 		 */
 		relopts = (StdRdOptions *) extractRelOptions(tuple, pg_class_desc, NULL);
 		if (relopts)
+		{
+			av_relation *hentry;
+			bool		found;
+
 			free_relopts = true;
+
+			hentry = hash_search(table_toast_map, &relid, HASH_FIND, &found);
+			if (found && hentry->ar_hasrelopts)
+				combine_relopts(relopts, &hentry->ar_reloptions);
+		}
 		else
 		{
 			av_relation *hentry;
@@ -2733,7 +2809,16 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map,
 	 */
 	relopts = (StdRdOptions *) extractRelOptions(classTup, pg_class_desc, NULL);
 	if (relopts)
+	{
+		av_relation *hentry;
+		bool		found;
+
 		free_relopts = true;
+
+		hentry = hash_search(table_toast_map, &relid, HASH_FIND, &found);
+		if (found && hentry->ar_hasrelopts)
+			combine_relopts(relopts, &hentry->ar_reloptions);
+	}
 	else if (classForm->relkind == RELKIND_TOASTVALUE &&
 			 table_toast_map != NULL)
 	{
-- 
2.39.5 (Apple Git-154)


--QWBYbd5Ar5k8NvSv
Content-Type: text/plain; charset=us-ascii
Content-Disposition: attachment;
	filename=v1-0004-combine-relopts-correctly-for-VACUUM-commands.patch



view thread (794+ 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 3/4] autovac: combine reloptions correctly
  In-Reply-To: <no-message-id-219867@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