pgsql: Propagate rebalanced cost limit to parallel vacuum workers

From: Daniel Gustafsson <dgustafsson(at)postgresql(dot)org>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Propagate rebalanced cost limit to parallel vacuum workers
Date: 2026-08-28 21:35:12
Message-ID: E1x04EB-00000002Y0E-1xaT@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Propagate rebalanced cost limit to parallel vacuum workers

AutoVacuumUpdateCostLimit() runs after each nap in vacuum_delay_point()
and follows av_nworkersForBalance, but the new limit never reached the
shared cost params in the vacuum DSM: propagation only required config
reload. Parallel workers computed their delays from the stale limit,
so a parallel autovacuum could run at up to twice the configured budget
(or half of it) until the next SIGHUP, contradicting the propagation
promise in maintenance.sgml.

Call parallel_vacuum_propagate_shared_delay_params() after rebalancing.
Gated on the leader: parallel workers take the same nap path and must
not overwrite the shared parameters.

This also adds a test to validate the behaviour: pause the leader at the
existing injection point, start a second autovacuum worker and hold it at
a new injection point placed after it joined the balance, then check the
first parameter load of the parallel workers reports the balanced limit.
The hold is needed because a second worker left running can finish its own
vacuum before the leader resumes, which puts the balance back where it
started. Autovacuum is disabled for everything but the two test tables
via thresholds, as a worker spawned by catalog churn would get trapped at
the hold point and starve the test of its second worker slot.

Backpatch to v19 where autovacuum gained the ability to use parallel
vacuum workers.

Author: Zsolt Parragi <zsolt(dot)parragi(at)percona(dot)com>
Reviewed-by: Bharath Rupireddy <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Daniel Gustafsson <daniel(at)yesql(dot)se>
Discussion: https://postgr.es/m/CAN4CZFOZtEPwGQ6oa9LvHvN522zEp8h_dW9hHExSh7pVXofoKQ@mail.gmail.com
Backpatch-through: 19

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/6c5f1d6074208146930b67c2054509c3e82f6f7f

Modified Files
--------------
src/backend/commands/vacuum.c | 3 +
src/backend/postmaster/autovacuum.c | 1 +
.../test_autovacuum/t/001_parallel_autovacuum.pl | 88 +++++++++++++++++++++-
3 files changed, 91 insertions(+), 1 deletion(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Daniel Gustafsson 2026-08-28 21:35:25 pgsql: Propagate rebalanced cost limit to parallel vacuum workers
Previous Message Tom Lane 2026-08-28 20:37:35 pgsql: Update .abi-compliance-history for join removal fix.