From 176d511a9d9ef6d59751d1e57a8e0bab028e7140 Mon Sep 17 00:00:00 2001 From: Shinya Kato Date: Thu, 1 May 2025 18:42:28 +0900 Subject: [PATCH v1 1/2] Rename log_autovacuum_min_duration To introduce log_autovacuum_analyze_min_duration, first rename log_autovacuum_min_duration to log_autovacuum_vacuum_min_duration. --- doc/src/sgml/config.sgml | 24 +++++++++---------- doc/src/sgml/maintenance.sgml | 4 ++-- doc/src/sgml/ref/create_table.sgml | 8 +++---- src/backend/access/common/reloptions.c | 8 +++---- src/backend/access/heap/vacuumlazy.c | 6 ++--- src/backend/commands/analyze.c | 8 +++---- src/backend/commands/vacuum.c | 6 ++--- src/backend/postmaster/autovacuum.c | 14 +++++------ src/backend/utils/misc/guc_tables.c | 9 +++---- src/backend/utils/misc/postgresql.conf.sample | 10 ++++---- src/bin/psql/tab-complete.in.c | 4 ++-- src/include/commands/vacuum.h | 6 ++--- src/include/postmaster/autovacuum.h | 2 +- src/include/utils/rel.h | 2 +- .../xid_wraparound/t/001_emergency_vacuum.pl | 2 +- .../modules/xid_wraparound/t/002_limits.pl | 2 +- .../xid_wraparound/t/003_wraparounds.pl | 2 +- src/test/regress/pg_regress.c | 2 +- src/tools/ci/pg_ci_base.conf | 2 +- 19 files changed, 61 insertions(+), 60 deletions(-) diff --git a/doc/src/sgml/config.sgml b/doc/src/sgml/config.sgml index 021153b2a5f..1ae8dfd7137 100644 --- a/doc/src/sgml/config.sgml +++ b/doc/src/sgml/config.sgml @@ -7424,26 +7424,26 @@ local0.* /var/log/postgresql - - log_autovacuum_min_duration (integer) + + log_autovacuum_vacuum_min_duration (integer) - log_autovacuum_min_duration + log_autovacuum_vacuum_min_duration configuration parameter - Causes each action executed by autovacuum to be logged if it ran for at + Causes vacuum action executed by autovacuum to be logged if it ran for at least the specified amount of time. Setting this to zero logs - all autovacuum actions. -1 disables logging autovacuum - actions. If this value is specified without units, it is taken as milliseconds. - For example, if you set this to - 250ms then all automatic vacuums and analyzes that run + all vacuum actions by autovacuum. -1 disables logging + vacuum actions by autovacuum. If this value is specified without units, + it is taken as milliseconds. For example, if you set this to + 250ms then all automatic vacuums that run 250ms or longer will be logged. In addition, when this parameter is set to any value other than -1, a message will be - logged if an autovacuum action is skipped due to a conflicting lock or a + logged if a vacuum action by autovacuum is skipped due to a conflicting lock or a concurrently dropped relation. The default is 10min. - Enabling this parameter can be helpful in tracking autovacuum activity. + Enabling this parameter can be helpful in tracking vacuum activity by autovacuum. This parameter can only be set in the postgresql.conf file or on the server command line; but the setting can be overridden for individual tables by changing table storage parameters. @@ -8603,7 +8603,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; in the output of when the VERBOSE option is used, and by autovacuum for auto-vacuums and auto-analyzes when - is set. + is set. Only superusers and users with the appropriate SET privilege can change this setting. @@ -8636,7 +8636,7 @@ COPY postgres_log FROM '/full/path/to/logfile.csv' WITH csv; option is used, in the output of when the VERBOSE option is used, by autovacuum for auto-vacuums and auto-analyzes, when is set and by + linkend="guc-log-autovacuum-vacuum-min-duration"/> is set and by . Only superusers and users with the appropriate SET privilege can change this setting. diff --git a/doc/src/sgml/maintenance.sgml b/doc/src/sgml/maintenance.sgml index 600e4b3f2f3..84df5215580 100644 --- a/doc/src/sgml/maintenance.sgml +++ b/doc/src/sgml/maintenance.sgml @@ -636,7 +636,7 @@ SELECT datname, age(datfrozenxid) FROM pg_database; relminmxid advanced, and the number of newly frozen pages. The same details appear in the server log when autovacuum logging (controlled by ) reports on a + linkend="guc-log-autovacuum-vacuum-min-duration"/>) reports on a VACUUM operation executed by autovacuum. @@ -889,7 +889,7 @@ HINT: Execute a database-wide VACUUM in that database. the next database will be processed as soon as the first worker finishes. Each worker process will check each table within its database and execute VACUUM and/or ANALYZE as needed. - can be set to monitor + can be set to monitor autovacuum workers' activity. diff --git a/doc/src/sgml/ref/create_table.sgml b/doc/src/sgml/ref/create_table.sgml index 4a41b2f5530..66954c66ba6 100644 --- a/doc/src/sgml/ref/create_table.sgml +++ b/doc/src/sgml/ref/create_table.sgml @@ -1934,16 +1934,16 @@ WITH ( MODULUS numeric_literal, REM - - log_autovacuum_min_duration, toast.log_autovacuum_min_duration (integer) + + log_autovacuum_vacuum_min_duration, toast.log_autovacuum_vacuum_min_duration (integer) - log_autovacuum_min_duration + log_autovacuum_vacuum_min_duration storage parameter - Per-table value for + Per-table value for parameter. diff --git a/src/backend/access/common/reloptions.c b/src/backend/access/common/reloptions.c index 50747c16396..4bc618a34f0 100644 --- a/src/backend/access/common/reloptions.c +++ b/src/backend/access/common/reloptions.c @@ -321,8 +321,8 @@ static relopt_int intRelOpts[] = }, { { - "log_autovacuum_min_duration", - "Sets the minimum execution time above which autovacuum actions will be logged", + "log_autovacuum_vacuum_min_duration", + "Sets the minimum execution time above which vacuum actions by autovacuum will be logged", RELOPT_KIND_HEAP | RELOPT_KIND_TOAST, ShareUpdateExclusiveLock }, @@ -1894,8 +1894,8 @@ default_reloptions(Datum reloptions, bool validate, relopt_kind kind) offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_max_age)}, {"autovacuum_multixact_freeze_table_age", RELOPT_TYPE_INT, offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, multixact_freeze_table_age)}, - {"log_autovacuum_min_duration", RELOPT_TYPE_INT, - offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_min_duration)}, + {"log_autovacuum_vacuum_min_duration", RELOPT_TYPE_INT, + offsetof(StdRdOptions, autovacuum) + offsetof(AutoVacOpts, log_vacuum_min_duration)}, {"toast_tuple_target", RELOPT_TYPE_INT, offsetof(StdRdOptions, toast_tuple_target)}, {"autovacuum_vacuum_cost_delay", RELOPT_TYPE_REAL, diff --git a/src/backend/access/heap/vacuumlazy.c b/src/backend/access/heap/vacuumlazy.c index 09416450af9..86bb8083c46 100644 --- a/src/backend/access/heap/vacuumlazy.c +++ b/src/backend/access/heap/vacuumlazy.c @@ -636,7 +636,7 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, verbose = (params->options & VACOPT_VERBOSE) != 0; instrument = (verbose || (AmAutoVacuumWorkerProcess() && - params->log_min_duration >= 0)); + params->log_vacuum_min_duration >= 0)); if (instrument) { pg_rusage_init(&ru0); @@ -947,9 +947,9 @@ heap_vacuum_rel(Relation rel, VacuumParams *params, { TimestampTz endtime = GetCurrentTimestamp(); - if (verbose || params->log_min_duration == 0 || + if (verbose || params->log_vacuum_min_duration == 0 || TimestampDifferenceExceeds(starttime, endtime, - params->log_min_duration)) + params->log_vacuum_min_duration)) { long secs_dur; int usecs_dur; diff --git a/src/backend/commands/analyze.c b/src/backend/commands/analyze.c index 4fffb76e557..ba26b00cfb1 100644 --- a/src/backend/commands/analyze.c +++ b/src/backend/commands/analyze.c @@ -139,7 +139,7 @@ analyze_rel(Oid relid, RangeVar *relation, * Make sure to generate only logs for ANALYZE in this case. */ onerel = vacuum_open_relation(relid, relation, params->options & ~(VACOPT_VACUUM), - params->log_min_duration >= 0, + params->log_vacuum_min_duration >= 0, ShareUpdateExclusiveLock); /* leave if relation could not be opened or locked */ @@ -311,7 +311,7 @@ do_analyze_rel(Relation onerel, VacuumParams *params, verbose = (params->options & VACOPT_VERBOSE) != 0; instrument = (verbose || (AmAutoVacuumWorkerProcess() && - params->log_min_duration >= 0)); + params->log_vacuum_min_duration >= 0)); if (inh) ereport(elevel, (errmsg("analyzing \"%s.%s\" inheritance tree", @@ -736,9 +736,9 @@ do_analyze_rel(Relation onerel, VacuumParams *params, { TimestampTz endtime = GetCurrentTimestamp(); - if (verbose || params->log_min_duration == 0 || + if (verbose || params->log_vacuum_min_duration == 0 || TimestampDifferenceExceeds(starttime, endtime, - params->log_min_duration)) + params->log_vacuum_min_duration)) { long delay_in_ms; WalUsage walusage; diff --git a/src/backend/commands/vacuum.c b/src/backend/commands/vacuum.c index 33a33bf6b1c..7e8d02d7a86 100644 --- a/src/backend/commands/vacuum.c +++ b/src/backend/commands/vacuum.c @@ -415,8 +415,8 @@ ExecVacuum(ParseState *pstate, VacuumStmt *vacstmt, bool isTopLevel) /* user-invoked vacuum is never "for wraparound" */ params.is_wraparound = false; - /* user-invoked vacuum uses VACOPT_VERBOSE instead of log_min_duration */ - params.log_min_duration = -1; + /* user-invoked vacuum uses VACOPT_VERBOSE instead of log_vacuum_min_duration */ + params.log_vacuum_min_duration = -1; /* * Later, in vacuum_rel(), we check if a reloption override was specified. @@ -2069,7 +2069,7 @@ vacuum_rel(Oid relid, RangeVar *relation, VacuumParams *params, /* open the relation and get the appropriate lock on it */ rel = vacuum_open_relation(relid, relation, params->options, - params->log_min_duration >= 0, lmode); + params->log_vacuum_min_duration >= 0, lmode); /* leave if relation could not be opened or locked */ if (!rel) diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 451fb90a610..cc77bbd8f11 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -133,7 +133,7 @@ int autovacuum_multixact_freeze_max_age; double autovacuum_vac_cost_delay; int autovacuum_vac_cost_limit; -int Log_autovacuum_min_duration = 600000; +int Log_autovacuum_vac_min_duration = 600000; /* the minimum allowed time between two awakenings of the launcher */ #define MIN_AUTOVAC_SLEEPTIME 100.0 /* milliseconds */ @@ -2791,7 +2791,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map, int freeze_table_age; int multixact_freeze_min_age; int multixact_freeze_table_age; - int log_min_duration; + int log_vacuum_min_duration; /* * Calculate the vacuum cost parameters and the freeze ages. If there @@ -2800,10 +2800,10 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map, * defaults, autovacuum's own first and plain vacuum second. */ - /* -1 in autovac setting means use log_autovacuum_min_duration */ - log_min_duration = (avopts && avopts->log_min_duration >= 0) - ? avopts->log_min_duration - : Log_autovacuum_min_duration; + /* -1 in autovac setting means use log_autovacuum_vacuum_min_duration */ + log_vacuum_min_duration = (avopts && avopts->log_vacuum_min_duration >= 0) + ? avopts->log_vacuum_min_duration + : Log_autovacuum_vac_min_duration; /* these do not have autovacuum-specific settings */ freeze_min_age = (avopts && avopts->freeze_min_age >= 0) @@ -2854,7 +2854,7 @@ table_recheck_autovac(Oid relid, HTAB *table_toast_map, tab->at_params.multixact_freeze_min_age = multixact_freeze_min_age; tab->at_params.multixact_freeze_table_age = multixact_freeze_table_age; tab->at_params.is_wraparound = wraparound; - tab->at_params.log_min_duration = log_min_duration; + tab->at_params.log_vacuum_min_duration = log_vacuum_min_duration; tab->at_params.toast_parent = InvalidOid; /* diff --git a/src/backend/utils/misc/guc_tables.c b/src/backend/utils/misc/guc_tables.c index f04bfedb2fd..7ba26ebff5b 100644 --- a/src/backend/utils/misc/guc_tables.c +++ b/src/backend/utils/misc/guc_tables.c @@ -3169,13 +3169,14 @@ struct config_int ConfigureNamesInt[] = }, { - {"log_autovacuum_min_duration", PGC_SIGHUP, LOGGING_WHAT, + {"log_autovacuum_vacuum_min_duration", PGC_SIGHUP, LOGGING_WHAT, gettext_noop("Sets the minimum execution time above which " - "autovacuum actions will be logged."), - gettext_noop("-1 disables logging autovacuum actions. 0 means log all autovacuum actions."), + "vacuum actions by autovacuum will be logged."), + gettext_noop("-1 disables logging vacuum actions by autovacuum. " + "0 means log all vacuum actions by autovacuum."), GUC_UNIT_MS }, - &Log_autovacuum_min_duration, + &Log_autovacuum_vac_min_duration, 600000, -1, INT_MAX, NULL, NULL, NULL }, diff --git a/src/backend/utils/misc/postgresql.conf.sample b/src/backend/utils/misc/postgresql.conf.sample index 341f88adc87..90e02054acd 100644 --- a/src/backend/utils/misc/postgresql.conf.sample +++ b/src/backend/utils/misc/postgresql.conf.sample @@ -585,11 +585,11 @@ #debug_print_rewritten = off #debug_print_plan = off #debug_pretty_print = on -#log_autovacuum_min_duration = 10min # log autovacuum activity; - # -1 disables, 0 logs all actions and - # their durations, > 0 logs only - # actions running at least this number - # of milliseconds. +#log_autovacuum_vacuum_min_duration = 10min # log vacuum activity by autovacuum; + # -1 disables, 0 logs all actions and + # their durations, > 0 logs only + # actions running at least this number + # of milliseconds. #log_checkpoints = on #log_connections = '' # log aspects of connection setup # options include receipt, authentication, authorization, diff --git a/src/bin/psql/tab-complete.in.c b/src/bin/psql/tab-complete.in.c index ec65ab79fec..27f63159e43 100644 --- a/src/bin/psql/tab-complete.in.c +++ b/src/bin/psql/tab-complete.in.c @@ -1386,7 +1386,7 @@ static const char *const table_storage_parameters[] = { "autovacuum_vacuum_scale_factor", "autovacuum_vacuum_threshold", "fillfactor", - "log_autovacuum_min_duration", + "log_autovacuum_vacuum_min_duration", "parallel_workers", "toast.autovacuum_enabled", "toast.autovacuum_freeze_max_age", @@ -1402,7 +1402,7 @@ static const char *const table_storage_parameters[] = { "toast.autovacuum_vacuum_max_threshold", "toast.autovacuum_vacuum_scale_factor", "toast.autovacuum_vacuum_threshold", - "toast.log_autovacuum_min_duration", + "toast.log_autovacuum_vacuum_min_duration", "toast.vacuum_index_cleanup", "toast.vacuum_max_eager_freeze_failure_rate", "toast.vacuum_truncate", diff --git a/src/include/commands/vacuum.h b/src/include/commands/vacuum.h index bc37a80dc74..5a90b84e099 100644 --- a/src/include/commands/vacuum.h +++ b/src/include/commands/vacuum.h @@ -224,9 +224,9 @@ typedef struct VacuumParams int multixact_freeze_table_age; /* multixact age at which to scan * whole table */ bool is_wraparound; /* force a for-wraparound vacuum */ - int log_min_duration; /* minimum execution threshold in ms at - * which autovacuum is logged, -1 to use - * default */ + int log_vacuum_min_duration; /* minimum execution threshold in ms + * at which vacuum by autovacuum is + * logged, -1 to use default */ VacOptValue index_cleanup; /* Do index vacuum and cleanup */ VacOptValue truncate; /* Truncate empty pages at the end */ Oid toast_parent; /* for privilege checks when recursing */ diff --git a/src/include/postmaster/autovacuum.h b/src/include/postmaster/autovacuum.h index e8135f41a1c..4d0b44a4f7a 100644 --- a/src/include/postmaster/autovacuum.h +++ b/src/include/postmaster/autovacuum.h @@ -47,7 +47,7 @@ extern PGDLLIMPORT int autovacuum_vac_cost_limit; /* autovacuum launcher PID, only valid when worker is shutting down */ extern PGDLLIMPORT int AutovacuumLauncherPid; -extern PGDLLIMPORT int Log_autovacuum_min_duration; +extern PGDLLIMPORT int Log_autovacuum_vac_min_duration; /* Status inquiry functions */ extern bool AutoVacuumingActive(void); diff --git a/src/include/utils/rel.h b/src/include/utils/rel.h index b552359915f..23e47af9112 100644 --- a/src/include/utils/rel.h +++ b/src/include/utils/rel.h @@ -322,7 +322,7 @@ typedef struct AutoVacOpts int multixact_freeze_min_age; int multixact_freeze_max_age; int multixact_freeze_table_age; - int log_min_duration; + int log_vacuum_min_duration; float8 vacuum_cost_delay; float8 vacuum_scale_factor; float8 vacuum_ins_scale_factor; diff --git a/src/test/modules/xid_wraparound/t/001_emergency_vacuum.pl b/src/test/modules/xid_wraparound/t/001_emergency_vacuum.pl index 73d1ec4af19..9d64bee10eb 100644 --- a/src/test/modules/xid_wraparound/t/001_emergency_vacuum.pl +++ b/src/test/modules/xid_wraparound/t/001_emergency_vacuum.pl @@ -21,7 +21,7 @@ $node->append_conf( autovacuum_naptime = 1s # so it's easier to verify the order of operations autovacuum_max_workers = 1 -log_autovacuum_min_duration = 0 +log_autovacuum_vacuum_min_duration = 0 ]); $node->start; $node->safe_psql('postgres', 'CREATE EXTENSION xid_wraparound'); diff --git a/src/test/modules/xid_wraparound/t/002_limits.pl b/src/test/modules/xid_wraparound/t/002_limits.pl index aa1d8765d3a..db87477ae5d 100644 --- a/src/test/modules/xid_wraparound/t/002_limits.pl +++ b/src/test/modules/xid_wraparound/t/002_limits.pl @@ -28,7 +28,7 @@ $node->init; $node->append_conf( 'postgresql.conf', qq[ autovacuum_naptime = 1s -log_autovacuum_min_duration = 0 +log_autovacuum_vacuum_min_duration = 0 ]); $node->start; $node->safe_psql('postgres', 'CREATE EXTENSION xid_wraparound'); diff --git a/src/test/modules/xid_wraparound/t/003_wraparounds.pl b/src/test/modules/xid_wraparound/t/003_wraparounds.pl index 2aeaee8769c..59c04a1d781 100644 --- a/src/test/modules/xid_wraparound/t/003_wraparounds.pl +++ b/src/test/modules/xid_wraparound/t/003_wraparounds.pl @@ -24,7 +24,7 @@ $node->append_conf( autovacuum_naptime = 1s # so it's easier to verify the order of operations autovacuum_max_workers = 1 -log_autovacuum_min_duration = 0 +log_autovacuum_vacuum_min_duration = 0 ]); $node->start; $node->safe_psql('postgres', 'CREATE EXTENSION xid_wraparound'); diff --git a/src/test/regress/pg_regress.c b/src/test/regress/pg_regress.c index 5d85dcc62f0..e2001acd4aa 100644 --- a/src/test/regress/pg_regress.c +++ b/src/test/regress/pg_regress.c @@ -2400,7 +2400,7 @@ regression_main(int argc, char *argv[], bail("could not open \"%s\" for adding extra config: %m", buf); fputs("\n# Configuration added by pg_regress\n\n", pg_conf); - fputs("log_autovacuum_min_duration = 0\n", pg_conf); + fputs("log_autovacuum_vacuum_min_duration = 0\n", pg_conf); fputs("log_checkpoints = on\n", pg_conf); fputs("log_line_prefix = '%m %b[%p] %q%a '\n", pg_conf); fputs("log_lock_waits = on\n", pg_conf); diff --git a/src/tools/ci/pg_ci_base.conf b/src/tools/ci/pg_ci_base.conf index 9cec5c2910d..d9bb408aab4 100644 --- a/src/tools/ci/pg_ci_base.conf +++ b/src/tools/ci/pg_ci_base.conf @@ -6,7 +6,7 @@ restart_after_crash = false max_prepared_transactions = 10 # Settings that make logs more useful -log_autovacuum_min_duration = 0 +log_autovacuum_vacuum_min_duration = 0 log_checkpoints = true log_connections = all log_disconnections = true -- 2.39.3