pgsql: Fix race in autovacuum freeze score calculations.

From: Nathan Bossart <nathan(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Fix race in autovacuum freeze score calculations.
Date: 2026-11-19 15:21:08
Message-ID: E1xU3wh-00000000Ose-0c02@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Fix race in autovacuum freeze score calculations.

We calculate the transaction ID and multixact ID component scores
by subtracting a table's relfrozenxid or relminmxid from a "recent"
ID that we read before scanning pg_class. If something advances
relfrozenxid or relminmxid past the recent ID in the meantime
(e.g., a concurrent VACUUM), the subtraction wraps around and gives
the table a much higher score than it deserves. The window is
small enough that this is probably rare in practice. To fix, set
the affected component score to 0 in this case.

Oversight in commit d7965d65fc.

Author: Baji Shaik <baji(dot)pgdev(at)gmail(dot)com>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Discussion: https://postgr.es/m/CA%2Bfm-RPOMc-GHjpv4DpXO1eqMahCeZDpAgXWqVgnsB3s3arptA%40mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/4226f1f01ad1a1bd6f017d181c085c788b2961a0

Modified Files
--------------
src/backend/postmaster/autovacuum.c | 17 ++++++++++++++---
1 file changed, 14 insertions(+), 3 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Melanie Plageman 2026-11-19 16:36:04 pgsql: Return NULL for unknown pgstattuple estimate
Previous Message Tomas Vondra 2026-11-19 14:35:44 pgsql: Fix FULL JOIN constant propagation with non-strict operands