pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Masahiko Sawada <msawada@postgresql.org>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Make parallel vacuum processes share the cost limit.
Date: Mon, 02 Nov 2026 21:23:22 +0000
Message-ID: <E1xNzUw-00000001qWt-3z3j@gemulon.postgresql.org> (raw)

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



view thread (2+ messages)  latest in thread

Message-ID: <E1xNzUw-00000001qWt-3z3j@gemulon.postgresql.org>
Permalink:  ../E1xNzUw-00000001qWt-3z3j@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1xNzUw-00000001qWt-3z3j@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: msawada@postgresql.org
  Subject: Re: pgsql: Make parallel vacuum processes share the cost limit.
  In-Reply-To: <E1xNzUw-00000001qWt-3z3j@gemulon.postgresql.org>
  References: <E1xNzUw-00000001qWt-3z3j@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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