From 84f6fb81b8cb69c8da479d74e5b8078f6a1395c3 Mon Sep 17 00:00:00 2001 From: Alvaro Herrera Date: Wed, 2 Jan 2013 18:39:20 -0300 Subject: [PATCH] Fix IsUnderPostmaster/EXEC_BACKEND confusion --- src/backend/bootstrap/bootstrap.c | 4 ++++ src/backend/tcop/postgres.c | 4 +--- src/backend/utils/init/postinit.c | 5 +++++ 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/backend/bootstrap/bootstrap.c b/src/backend/bootstrap/bootstrap.c index 7787c1199b..82ef726574 100644 --- a/src/backend/bootstrap/bootstrap.c +++ b/src/backend/bootstrap/bootstrap.c @@ -359,6 +359,10 @@ AuxiliaryProcessMain(int argc, char *argv[]) SetProcessingMode(BootstrapProcessing); IgnoreSystemIndexes = true; + /* Initialize MaxBackends (if under postmaster, was done already) */ + if (!IsUnderPostmaster) + InitializeMaxBackends(); + BaseInit(); /* diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 937191334f..407c548cf8 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -3654,10 +3654,8 @@ PostgresMain(int argc, char *argv[], const char *username) */ CreateDataDirLockFile(false); - /* In EXEC_BACKEND, this was set via BackendParameters */ -#ifndef EXEC_BACKEND + /* Initialize MaxBackends (if under postmaster, was done already) */ InitializeMaxBackends(); -#endif } /* Early initialization */ diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.c index ddd79d0aa2..7e21ceae88 100644 --- a/src/backend/utils/init/postinit.c +++ b/src/backend/utils/init/postinit.c @@ -427,6 +427,11 @@ pg_split_opts(char **argv, int *argcp, char *optstr) * This must be called after modules have had the chance to register background * workers in shared_preload_libraries, and before shared memory size is * determined. + * + * Note that in EXEC_BACKEND environment, the value is passed down from + * postmaster to subprocesses via BackendParameters in SubPostmasterMain; only + * postmaster itself and processes not under postmaster control should call + * this. */ void InitializeMaxBackends(void) -- 2.40.0