| From: | Masahiko Sawada <msawada(at)postgresql(dot)org> |
|---|---|
| To: | pgsql-committers(at)lists(dot)postgresql(dot)org |
| Subject: | pgsql: Make parallel vacuum processes share the cost limit. |
| Date: | 2026-11-02 21:23:22 |
| Message-ID: | E1xNzUw-00000001qWt-3z3j@gemulon.postgresql.org |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-committers |
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 <bharath(dot)rupireddyforpostgres(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: Chao Li <li(dot)evan(dot)chao(at)gmail(dot)com>
Reviewed-by: surya poondla <suryapoondla4(at)gmail(dot)com>
Tested-by: Manu <manuelreyesbravo(at)gmail(dot)com>
Discussion: https://postgr.es/m/CALj2ACWDhGH_ACJYHvxHVbL9GZ8AgMoJFnf-u5=bWx7NZtYBRQ@mail.gmail.com
Backpatch-through: 19
Branch
------
master
Details
-------
https://git.postgresql.org/pg/commitdiff/8628df8891abc7c69bb12ed160e36df727ca40ea
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(-)
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Masahiko Sawada | 2026-11-02 21:23:26 | pgsql: Make parallel vacuum processes share the cost limit. |
| Previous Message | Tomas Vondra | 2026-11-02 21:08:49 | pgsql: Fix BRIN minmax-multi distance for tid values |