pg.ddx.io pgsql-committers@postgresql.org mailing list archivehelp / color / mirror / Atom feed
pgsql: Make parallel vacuum processes share the cost limit. 2+ messages / 1 participants [nested] [flat]
* pgsql: Make parallel vacuum processes share the cost limit. @ 2026-11-02 21:23 Masahiko Sawada <msawada@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Masahiko Sawada @ 2026-11-02 21:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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.rupireddyforpostgres@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: surya poondla <suryapoondla4@gmail.com> Tested-by: Manu <manuelreyesbravo@gmail.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(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
* pgsql: Make parallel vacuum processes share the cost limit. @ 2026-11-02 21:23 Masahiko Sawada <msawada@postgresql.org> 0 siblings, 0 replies; 2+ messages in thread From: Masahiko Sawada @ 2026-11-02 21:23 UTC (permalink / raw) To: pgsql-committers@lists.postgresql.org 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.rupireddyforpostgres@gmail.com> Reviewed-by: Masahiko Sawada <sawada.mshk@gmail.com> Reviewed-by: Chao Li <li.evan.chao@gmail.com> Reviewed-by: surya poondla <suryapoondla4@gmail.com> Tested-by: Manu <manuelreyesbravo@gmail.com> Discussion: https://postgr.es/m/CALj2ACWDhGH_ACJYHvxHVbL9GZ8AgMoJFnf-u5=bWx7NZtYBRQ@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(-) ^ permalink raw reply [nested|flat] 2+ messages in thread
end of thread, other threads:[~2026-11-02 21:23 UTC | newest] Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed) -- links below jump to the message on this page -- 2026-11-02 21:23 pgsql: Make parallel vacuum processes share the cost limit. Masahiko Sawada <msawada@postgresql.org> 2026-11-02 21:23 pgsql: Make parallel vacuum processes share the cost limit. Masahiko Sawada <msawada@postgresql.org>
This inbox is served by DDX for PostgreSQL; see mirroring instructions for how to clone and mirror all data and code used for this inbox