From 49e098b41420aebda60804410b33fcbb5279503f Mon Sep 17 00:00:00 2001 From: Nathan Bossart Date: Tue, 1 Sep 2026 15:20:01 -0500 Subject: [PATCH] Fix scaling of autovacuum freeze scores. Sufficiently large settings of the *_freeze_score_weight parameters can lower the scaling thresholds below the *_freeze_max_age settings. This can lead the scoring code to raise a value < 1.0 to a power > 1.0, thus lowering the score, which is the opposite of what is intended. To fix, only exponentiate the scores when doing so won't lower their values. Oversight in commit d7965d65fc. Reviewed-by: Bharath Rupireddy Reviewed-by: Greg Burd Discussion: https://postgr.es/m/apWcbq91BAfhmsKU%40nathan Backpatch-through: 19 --- src/backend/postmaster/autovacuum.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/postmaster/autovacuum.c b/src/backend/postmaster/autovacuum.c index 393e81d53e9..60ebe828900 100644 --- a/src/backend/postmaster/autovacuum.c +++ b/src/backend/postmaster/autovacuum.c @@ -3210,9 +3210,10 @@ relation_needs_vacanalyze(Oid relid, if (autovacuum_multixact_freeze_score_weight > 1.0) effective_mxid_failsafe_age /= autovacuum_multixact_freeze_score_weight; - if (xid_age >= effective_xid_failsafe_age) + /* We must be careful to avoid lowering the score. */ + if (xid_age >= effective_xid_failsafe_age && scores->xid > 1.0) scores->xid = pow(scores->xid, Max(1.0, (double) xid_age / 100000000)); - if (mxid_age >= effective_mxid_failsafe_age) + if (mxid_age >= effective_mxid_failsafe_age && scores->mxid > 1.0) scores->mxid = pow(scores->mxid, Max(1.0, (double) mxid_age / 100000000)); scores->xid *= autovacuum_freeze_score_weight;