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 <[email protected]>
Reviewed-by: Bharath Rupireddy <[email protected]>
Reviewed-by: Masahiko Sawada <[email protected]>
Reviewed-by: Daniel Gustafsson <[email protected]>
Discussion: 
https://postgr.es/m/can4czfoztepwgq6oa9lvhvn522zep8h_dw9hhexsh7pvxof...@mail.gmail.com
Backpatch-through: 19

Branch
------
REL_19_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/4af0528a0e49d06b997c443b044cb013503e1546

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(-)

Reply via email to