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 <sawada.mshk@gmail.com>
Discussion: https://postgr.es/m/CAD21AoBS7o6Ljt_vfqPQPf67AhzKu3fR0iqk8B=vVYczMugKMQ@mail.gmail.com
This commit is contained in:
Daniel Gustafsson 2023-04-20 15:45:44 +02:00
parent 0d0aeb04c1
commit a9781ae11b
1 changed files with 5 additions and 10 deletions

View File

@ -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");
}
}