From a9781ae11ba2fdb44a3a72c9a7ebb727140b25c5 Mon Sep 17 00:00:00 2001 From: Daniel Gustafsson Date: Thu, 20 Apr 2023 15:45:44 +0200 Subject: [PATCH] Fix autovacuum cost debug logging Commit 7d71d3dd0 introduced finer grained updates of autovacuum option changes by increasing the frequency of reading the configuration file. The debug logging of cost parameter was however changed such that some initial values weren't logged. Fix by changing logging to use the old frequency of logging regardless of them changing. Also avoid taking a log for rendering the log message unless the set loglevel is such that the log entry will be emitted. Author: Masahiko Sawada Discussion: https://postgr.es/m/CAD21AoBS7o6Ljt_vfqPQPf67AhzKu3fR0iqk8B=vVYczMugKMQ@mail.gmail.com --- src/backend/postmaster/autovacuum.c | 15 +++++---------- 1 file changed, 5 insertions(+), 10 deletions(-) diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 53c8f8d79c..e23ec32e22 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -1785,9 +1785,6 @@ FreeWorkerInfo(int code, Datum arg) void VacuumUpdateCosts(void) { - double original_cost_delay = vacuum_cost_delay; - int original_cost_limit = vacuum_cost_limit; - if (MyWorkerInfo) { if (av_storage_param_cost_delay >= 0) @@ -1821,16 +1818,15 @@ VacuumUpdateCosts(void) VacuumCostBalance = 0; } - if (MyWorkerInfo) + /* + * Since the cost logging requires a lock, avoid rendering the log message + * in case we are using a message level where the log wouldn't be emitted. + */ + if (MyWorkerInfo && message_level_is_interesting(DEBUG2)) { Oid dboid, tableoid; - /* Only log updates to cost-related variables */ - if (vacuum_cost_delay == original_cost_delay && - vacuum_cost_limit == original_cost_limit) - return; - Assert(!LWLockHeldByMe(AutovacuumLock)); LWLockAcquire(AutovacuumLock, LW_SHARED); @@ -1844,7 +1840,6 @@ VacuumUpdateCosts(void) vacuum_cost_limit, vacuum_cost_delay, vacuum_cost_delay > 0 ? "yes" : "no", VacuumFailsafeActive ? "yes" : "no"); - } } -- 2.30.2