Make parallel vacuum processes share the cost limit. Since commit 40d964ec99 introduced parallel vacuum in v13, each process taking part in it has slept for every vacuum_cost_limit cost units it incurred on its own, so the leader and its workers together could consume the budget several times over.
Fix by scaling each process's delay by the number of processes active in the parallel vacuum. The cap on a single delay is scaled the same way but also limited to one second, as sleeping longer in pg_usleep() keeps the process from responding to latches and signals promptly. While the new behavior is the correct one, backpatching it to v18 and older would make parallel VACUUM with cost-based delay slower after a minor update, and users would need to retune the parameters. Since we haven't received any complaints about the old behavior, we don't backpatch it to those branches for now. On v19, however, parallel autovacuum breaks autovacuum_vacuum_cost_limit, whose value is divided among autovacuum workers so that their sum doesn't exceed it, because parallel workers aren't counted. So backpatch to v19. Author: Bharath Rupireddy <[email protected]> Reviewed-by: Masahiko Sawada <[email protected]> Reviewed-by: Chao Li <[email protected]> Reviewed-by: surya poondla <[email protected]> Tested-by: Manu <[email protected]> Discussion: https://postgr.es/m/CALj2ACWDhGH_ACJYHvxHVbL9GZ8AgMoJFnf-u5=bwx7nzty...@mail.gmail.com Backpatch-through: 19 Branch ------ REL_19_STABLE Details ------- https://git.postgresql.org/pg/commitdiff/bf42705c7ddfc8e0550dcf521b51e73320298d58 Modified Files -------------- doc/src/sgml/config.sgml | 11 ++++++++++- doc/src/sgml/maintenance.sgml | 4 ++-- doc/src/sgml/ref/vacuum.sgml | 7 +++++-- src/backend/commands/vacuum.c | 35 ++++++++++++++++++++++++++--------- 4 files changed, 43 insertions(+), 14 deletions(-)
