pgsql: Reserve a PGPROC slot and semaphore for the slotsync worker proc - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Reserve a PGPROC slot and semaphore for the slotsync worker proc
Date
Msg-id E1tRaeO-001opy-2L@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
Reserve a PGPROC slot and semaphore for the slotsync worker process.

The need for this was missed in commit 93db6cbda, with the result
being that if we launch a slotsync worker it would consume one of
the PGPROCs in the max_connections pool.  That could lead to inability
to launch the worker, or to subsequent failures of connection requests
that should have succeeded according to the configured settings.

Rather than create some one-off infrastructure to support this,
let's group the slotsync worker with the existing autovac launcher
in a new category of "special worker" processes.  These are kind of
like auxiliary processes, but they cannot use that infrastructure
because they need to be able to run transactions.

For the moment, make these processes share the PGPROC freelist
used for autovac workers (which previously supplied the autovac
launcher too).  This is partly to avoid an ABI change in v17,
and partly because it seems silly to have a freelist with
at most two members.  This might be worth revisiting if we grow
enough workers in this category.

Tom Lane and Hou Zhijie.  Back-patch to v17.

Discussion: https://postgr.es/m/1808397.1735156190@sss.pgh.pa.us

Branch
------
REL_17_STABLE

Details
-------
https://git.postgresql.org/pg/commitdiff/14141bbbc103bf5db41c8f9a8206dfc9ca626e9f

Modified Files
--------------
src/backend/storage/lmgr/proc.c   | 37 +++++++++++++++++++++----------------
src/backend/utils/init/postinit.c |  6 +++---
src/include/miscadmin.h           |  9 +++++++--
src/include/storage/proc.h        | 14 ++++++++++++--
4 files changed, 43 insertions(+), 23 deletions(-)


pgsql-committers by date:

Previous
From: Noah Misch
Date:
Subject: pgsql: In REASSIGN OWNED of a database, lock the tuple as mandated.
Next
From: Tom Lane
Date:
Subject: pgsql: Exclude parallel workers from connection privilege/limit checks.