diff options
author | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2024-11-14 16:12:28 +0200 |
---|---|---|
committer | Heikki Linnakangas <heikki.linnakangas@iki.fi> | 2024-11-14 16:12:28 +0200 |
commit | a78af0427015449269fb7d9d8c6057cfcb740149 (patch) | |
tree | eae2ea6af8d455dd8d352d0e38f667ece481bfd5 /src/backend/postmaster/launch_backend.c | |
parent | bb861414fea31073f27aaab75a0ceaf3638d7985 (diff) | |
download | postgresql-a78af0427015449269fb7d9d8c6057cfcb740149.tar.gz postgresql-a78af0427015449269fb7d9d8c6057cfcb740149.zip |
Assign a child slot to every postmaster child process
Previously, only backends, autovacuum workers, and background workers
had an entry in the PMChildFlags array. With this commit, all
postmaster child processes, including all the aux processes, have an
entry. Dead-end backends still don't get an entry, though, and other
processes that don't touch shared memory will never mark their
PMChildFlags entry as active.
We now maintain separate freelists for different kinds of child
processes. That ensures that there are always slots available for
autovacuum and background workers. Previously, pre-authentication
backends could prevent autovacuum or background workers from starting
up, by using up all the slots.
The code to manage the slots in the postmaster process is in a new
pmchild.c source file. Because postmaster.c is just so large.
Assigning pmsignal slot numbers is now pmchild.c's responsibility.
This replaces the PMChildInUse array in pmsignal.c.
Some of the comments in postmaster.c still talked about the "stats
process", but that was removed in commit 5891c7a8ed. Fix those while
we're at it.
Reviewed-by: Andres Freund <andres@anarazel.de>
Discussion: https://www.postgresql.org/message-id/a102f15f-eac4-4ff2-af02-f9ff209ec66f@iki.fi
Diffstat (limited to 'src/backend/postmaster/launch_backend.c')
-rw-r--r-- | src/backend/postmaster/launch_backend.c | 3 |
1 files changed, 3 insertions, 0 deletions
diff --git a/src/backend/postmaster/launch_backend.c b/src/backend/postmaster/launch_backend.c index 423e6120438..6ce75f6f77d 100644 --- a/src/backend/postmaster/launch_backend.c +++ b/src/backend/postmaster/launch_backend.c @@ -118,6 +118,7 @@ typedef struct bool query_id_enabled; int max_safe_fds; int MaxBackends; + int num_pmchild_slots; #ifdef WIN32 HANDLE PostmasterHandle; HANDLE initial_signal_pipe; @@ -735,6 +736,7 @@ save_backend_variables(BackendParameters *param, ClientSocket *client_sock, param->max_safe_fds = max_safe_fds; param->MaxBackends = MaxBackends; + param->num_pmchild_slots = num_pmchild_slots; #ifdef WIN32 param->PostmasterHandle = PostmasterHandle; @@ -994,6 +996,7 @@ restore_backend_variables(BackendParameters *param) max_safe_fds = param->max_safe_fds; MaxBackends = param->MaxBackends; + num_pmchild_slots = param->num_pmchild_slots; #ifdef WIN32 PostmasterHandle = param->PostmasterHandle; |