pgsql: Wake up autovacuum launcher from postmaster when a worker exits

From: Heikki Linnakangas <heikki(dot)linnakangas(at)iki(dot)fi>
To: pgsql-committers(at)lists(dot)postgresql(dot)org
Subject: pgsql: Wake up autovacuum launcher from postmaster when a worker exits
Date: 2026-01-15 16:02:42
Message-ID: E1vgPo1-000dVH-1x@gemulon.postgresql.org
Views: Whole Thread | Raw Message | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Wake up autovacuum launcher from postmaster when a worker exits

When an autovacuum worker exits, the launcher needs to be notified
with SIGUSR2, so that it can rebalance and possibly launch a new
worker. The launcher must be notified only after the worker has
finished ProcKill(), so that the worker slot is available for a new
worker. Before this commit, the autovacuum worker was responsible for
that, which required a slightly complicated dance to pass the
launcher's PID from FreeWorkerInfo() to ProcKill() in a global
variable.

Simplify that by moving the responsibility of the signaling to the
postmaster. The postmaster was already doing it when it failed to fork
a worker process, so it seems logical to make it responsible for
notifying the launcher on worker exit too. That's also how the
notification on background worker exit is done.

Reviewed-by: Nathan Bossart <nathandbossart(at)gmail(dot)com>
Reviewed-by: Masahiko Sawada <sawada(dot)mshk(at)gmail(dot)com>
Reviewed-by: li carol <carol(dot)li2025(at)outlook(dot)com>
Discussion: https://www.postgresql.org/message-id/a5e27d25-c7e7-45d5-9bac-a17c8f462def@iki.fi

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d9c3c943653740d1df44385c3cd658ed67bb4fb2

Modified Files
--------------
src/backend/postmaster/autovacuum.c | 22 ----------------------
src/backend/postmaster/postmaster.c | 8 ++++++++
src/backend/storage/lmgr/proc.c | 4 ----
src/include/postmaster/autovacuum.h | 3 ---
4 files changed, 8 insertions(+), 29 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Andres Freund 2026-01-15 16:10:37 pgsql: aio: io_uring: Fix danger of completion getting reused before be
Previous Message Heikki Linnakangas 2026-01-15 15:03:28 pgsql: Add check for invalid offset at multixid truncation