aboutsummaryrefslogtreecommitdiff
path: root/src/backend/utils/init/postinit.c
diff options
context:
space:
mode:
authorTom Lane <tgl@sss.pgh.pa.us>2024-12-28 12:30:42 -0500
committerTom Lane <tgl@sss.pgh.pa.us>2024-12-28 12:30:42 -0500
commit2bdf1b2a2efc7bbbe2db3213153c14615485eadd (patch)
tree5b46360c77a71836503a6efcb6570f9df5f8214a /src/backend/utils/init/postinit.c
parentff90ee61450921e03fe3af4e0f75337a4bbd0584 (diff)
downloadpostgresql-2bdf1b2a2efc7bbbe2db3213153c14615485eadd.tar.gz
postgresql-2bdf1b2a2efc7bbbe2db3213153c14615485eadd.zip
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
Diffstat (limited to 'src/backend/utils/init/postinit.c')
-rw-r--r--src/backend/utils/init/postinit.c8
1 files changed, 4 insertions, 4 deletions
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c
index 770ab6906e7..9731de5781d 100644
--- a/src/backend/utils/init/postinit.c
+++ b/src/backend/utils/init/postinit.c
@@ -544,9 +544,9 @@ InitializeMaxBackends(void)
{
Assert(MaxBackends == 0);
- /* the extra unit accounts for the autovacuum launcher */
- MaxBackends = MaxConnections + autovacuum_max_workers + 1 +
- max_worker_processes + max_wal_senders;
+ /* Note that this does not include "auxiliary" processes */
+ MaxBackends = MaxConnections + autovacuum_max_workers +
+ max_worker_processes + max_wal_senders + NUM_SPECIAL_WORKER_PROCS;
if (MaxBackends > MAX_BACKENDS)
ereport(ERROR,
@@ -555,7 +555,7 @@ InitializeMaxBackends(void)
errdetail("\"max_connections\" (%d) plus \"autovacuum_max_workers\" (%d) plus \"max_worker_processes\" (%d) plus \"max_wal_senders\" (%d) must be less than %d.",
MaxConnections, autovacuum_max_workers,
max_worker_processes, max_wal_senders,
- MAX_BACKENDS)));
+ MAX_BACKENDS - (NUM_SPECIAL_WORKER_PROCS - 1))));
}
/*