From 7fc0e7de9fb8306e84d1c15211aba4308f694455 Mon Sep 17 00:00:00 2001 From: Robert Haas Date: Tue, 12 Apr 2022 14:45:23 -0400 Subject: Revert the addition of GetMaxBackends() and related stuff. This reverts commits 0147fc7, 4567596, aa64f23, and 5ecd018. There is no longer agreement that introducing this function was the right way to address the problem. The consensus now seems to favor trying to make a correct value for MaxBackends available to mdules executing their _PG_init() functions. Nathan Bossart Discussion: http://postgr.es/m/20220323045229.i23skfscdbvrsuxa@jrouhaud --- src/backend/postmaster/auxprocess.c | 2 +- src/backend/postmaster/postmaster.c | 14 ++++++++------ 2 files changed, 9 insertions(+), 7 deletions(-) (limited to 'src/backend/postmaster') diff --git a/src/backend/postmaster/auxprocess.c b/src/backend/postmaster/auxprocess.c index 0587e45920a..39ac4490db1 100644 --- a/src/backend/postmaster/auxprocess.c +++ b/src/backend/postmaster/auxprocess.c @@ -116,7 +116,7 @@ AuxiliaryProcessMain(AuxProcType auxtype) * This will need rethinking if we ever want more than one of a particular * auxiliary process type. */ - ProcSignalInit(GetMaxBackends() + MyAuxProcType + 1); + ProcSignalInit(MaxBackends + MyAuxProcType + 1); /* * Auxiliary processes don't run transactions, but they may need a diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.c index 3535e9e47d2..3dcaf8a4a5d 100644 --- a/src/backend/postmaster/postmaster.c +++ b/src/backend/postmaster/postmaster.c @@ -1005,8 +1005,10 @@ PostmasterMain(int argc, char *argv[]) LocalProcessControlFile(false); /* - * Register the apply launcher. It's probably a good idea to call this - * before any modules had a chance to take the background worker slots. + * Register the apply launcher. Since it registers a background worker, + * it needs to be called before InitializeMaxBackends(), and it's probably + * a good idea to call it before any modules had chance to take the + * background worker slots. */ ApplyLauncherRegister(); @@ -1027,8 +1029,8 @@ PostmasterMain(int argc, char *argv[]) #endif /* - * Now that loadable modules have had their chance to alter any GUCs, - * calculate MaxBackends. + * Now that loadable modules have had their chance to register background + * workers, calculate MaxBackends. */ InitializeMaxBackends(); @@ -6142,7 +6144,7 @@ save_backend_variables(BackendParameters *param, Port *port, param->query_id_enabled = query_id_enabled; param->max_safe_fds = max_safe_fds; - param->MaxBackends = GetMaxBackends(); + param->MaxBackends = MaxBackends; #ifdef WIN32 param->PostmasterHandle = PostmasterHandle; @@ -6375,7 +6377,7 @@ restore_backend_variables(BackendParameters *param, Port *port) query_id_enabled = param->query_id_enabled; max_safe_fds = param->max_safe_fds; - SetMaxBackends(param->MaxBackends); + MaxBackends = param->MaxBackends; #ifdef WIN32 PostmasterHandle = param->PostmasterHandle; -- cgit v1.2.3