From: Nathan Bossart <nathandbossart@gmail.com>
To: Michael Paquier <michael@paquier.xyz>
Cc: Bossart, Nathan <bossartn@amazon.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: wangsh.fnst@fujitsu.com <wangsh.fnst@fujitsu.com>
Cc: Andres Freund <andres@anarazel.de>
Cc: Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>
Cc: Greg Sabino Mullane <htamfids@gmail.com>
Cc: Tom Lane <tgl@sss.pgh.pa.us>
Cc: pgsql-hackers@lists.postgresql.org <pgsql-hackers@lists.postgresql.org>
Subject: Re: make MaxBackends available in _PG_init
Date: Thu, 27 Jan 2022 10:18:15 -0800
Message-ID: <20220127181815.GA551692@nathanxps13> (raw)
In-Reply-To: <YfHtpO9+pxsHblmX@paquier.xyz>
References: <CAKAnmmJ_3HQZ7PvpiJoJKYfffp8GOUXE3BVHsD9EOjDrcrU1FA@mail.gmail.com>
<OSBPR01MB42140A01E3441C576539AF38F2FC9@OSBPR01MB4214.jpnprd01.prod.outlook.com>
<B7E20C65-D0AB-47B2-BC43-A831601711A2@amazon.com>
<01c32f6c-8101-1ce4-8295-534cf067df94@oss.nttdata.com>
<7239E4F9-A46D-4A61-9200-8B1366D03ADB@amazon.com>
<CA+TgmoZoyOKcE4TpAExHNSvfwE8Q_Y-tDvASN783Zb870pwKAA@mail.gmail.com>
<1E960D8B-24D7-43E0-9744-C5F8C52DDEB4@amazon.com>
<Ye+uOIE0TSbHf/FF@paquier.xyz>
<B6186047-CB98-49B1-A2CA-959057703788@amazon.com>
<YfHtpO9+pxsHblmX@paquier.xyz>
On Thu, Jan 27, 2022 at 09:56:04AM +0900, Michael Paquier wrote:
> Hmm. I have been looking at this patch, and the lack of centralized
> solution that could be used for other GUCs worries me like Fujii-san,
> even if this would prevent an incorrect use of MaxBackends in contexts
> where it should not be used because it is not initialized yet. I
> don't think it is a good idea in the long-term to apply this as-is.
Alright. I think the comment adjustments still apply, so I split those out
to a new patch.
--
Nathan Bossart
Amazon Web Services: https://aws.amazon.com/Attachments:
[text/x-diff] v7-0001-Adjust-comments-about-registering-background-work.patch (2.6K, ../20220127181815.GA551692@nathanxps13/2-v7-0001-Adjust-comments-about-registering-background-work.patch)
download | inline diff:
From 4bc21dc199616824b8f5790e8112ebf149f45207 Mon Sep 17 00:00:00 2001
From: Nathan Bossart <bossartn@amazon.com>
Date: Mon, 2 Aug 2021 17:42:25 +0000
Subject: [PATCH v7 1/1] Adjust comments about registering background workers
before initializing MaxBackends.
Since 6bc8ef0b, InitializeMaxBackends() has used
max_worker_processes instead of tallying up the number of
registered background workers, so background worker registration is
no longer a prerequisite. The ordering of this logic is still
useful for allowing libraries to adjust GUCs, so the comments have
been updated to mention that use-case.
---
src/backend/postmaster/postmaster.c | 10 ++++------
src/backend/utils/init/postinit.c | 5 ++---
2 files changed, 6 insertions(+), 9 deletions(-)
diff --git a/src/backend/postmaster/postmaster.c b/src/backend/postmaster/postmaster.cindex dc4afdd75a..ac0ec0986a 100644--- a/src/backend/postmaster/postmaster.c+++ b/src/backend/postmaster/postmaster.c@@ -1014,10 +1014,8 @@ PostmasterMain(int argc, char *argv[])
LocalProcessControlFile(false);
/*
- * 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.+ * 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.
*/
ApplyLauncherRegister();
@@ -1038,8 +1036,8 @@ PostmasterMain(int argc, char *argv[])
#endif
/*
- * Now that loadable modules have had their chance to register background- * workers, calculate MaxBackends.+ * Now that loadable modules have had their chance to alter any GUCs,+ * calculate MaxBackends.
*/
InitializeMaxBackends();
diff --git a/src/backend/utils/init/postinit.c b/src/backend/utils/init/postinit.cindex d046caabd7..cd7c829ff5 100644--- a/src/backend/utils/init/postinit.c+++ b/src/backend/utils/init/postinit.c@@ -483,9 +483,8 @@ pg_split_opts(char **argv, int *argcp, const char *optstr)
/*
* Initialize MaxBackends value from config options.
*
- * 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.+ * This must be called after modules have had the chance to alter GUCs 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
--
2.25.1
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-hackers@postgresql.org
Cc: nathandbossart@gmail.com, michael@paquier.xyz, bossartn@amazon.com, robertmhaas@gmail.com, masao.fujii@oss.nttdata.com, wangsh.fnst@fujitsu.com, andres@anarazel.de, bharath.rupireddyforpostgres@gmail.com, htamfids@gmail.com, tgl@sss.pgh.pa.us, pgsql-hackers@lists.postgresql.org
Subject: Re: make MaxBackends available in _PG_init
In-Reply-To: <20220127181815.GA551692@nathanxps13>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox