Received: from malur.postgresql.org ([217.196.149.56]) by arkaria.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nD9Lp-0000S3-Hm for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jan 2022 18:18:29 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nD9Ln-0004B4-G7 for pgsql-hackers@arkaria.postgresql.org; Thu, 27 Jan 2022 18:18:27 +0000 Received: from makus.postgresql.org ([2001:4800:3e1:1::229]) by malur.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nD9Ln-0004AC-50 for pgsql-hackers@lists.postgresql.org; Thu, 27 Jan 2022 18:18:27 +0000 Received: from mail-pf1-x436.google.com ([2607:f8b0:4864:20::436]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nD9Lf-0006FS-TD for pgsql-hackers@lists.postgresql.org; Thu, 27 Jan 2022 18:18:25 +0000 Received: by mail-pf1-x436.google.com with SMTP id u130so3368423pfc.2 for ; Thu, 27 Jan 2022 10:18:19 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20210112; h=date:from:to:cc:subject:message-id:references:mime-version :content-disposition:in-reply-to; bh=qZ9uVG3p1AELTx1t3IOkfc3nkaCT7Men7uZVBNYojqA=; b=qCDG/ny7bbcOogmMtGw63Bj6n1hEexLbT7wHzWM5jC1OLKtclY8RnUZbBtqehRzUrN LRm/KCwE7/gP/aiE+xnpZ6sH8C4OH5NbJsCS7iNi7gHDld8OogiL2J3ZxU1LiIsvIJAz 3k66u+JMX6mW+t76MYfnELTn+Bo9oYv+HDsGB7D9rIJMZ2DZakQSR9CRHjKbpsJFsOZh S1mqOGrEyjb8koPvUXUXFUKLwnqM1+lKOgUmsXtP+Es8e7ffZMCl2r1l/IhBqBE/icbL onB/uPr+Rot2wI99Q06lzeXX+7zLP5EpaWTzW8p2qZBtDoRj5aVpWShhA1PJomi1r4kM UOZQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20210112; h=x-gm-message-state:date:from:to:cc:subject:message-id:references :mime-version:content-disposition:in-reply-to; bh=qZ9uVG3p1AELTx1t3IOkfc3nkaCT7Men7uZVBNYojqA=; b=JjLJZLbha8qUQiaQCaFbDIeKFp+tSN5p2H5mHKEzDeZVe57xHbaqAhMiScATMwlT3v +HdOkHfGM0++WLN9Vd6zVRt84jMIgrd72JEqulLHV8+2dwUKJvwoS2u8ae5EAKGE0BQs JqMqJL8oXnTxZ55rkLsNzFL0PJ1EI0ym6rek8UUNz+d92dsTIVx8pSPsyiQ2mCxGSAiW UqpYZOdXEsdvfTmoDTkeLQVKhIC6Dvv9+vFQ1UsZczAMO7r0aKEnsAdrskXYJyiRtcRD g0hZE7nd/v1Swj9QvAog2kgfpejZZhxo97hrNJsnrDLDOCLwytt1Afo1xIGFPbkAYXWp UMhA== X-Gm-Message-State: AOAM532qYwYPHiP043yj6BzN2CdTyYPT0seKan6FBrry/7zL0YYV3eHa 0r6H4g+mac8NCqWqEChH/kk= X-Google-Smtp-Source: ABdhPJzbFR9U9QH3yJuhjmHsCf/y9PWVznzmLzB9eCNcd0QiHNWAMdjOliaRSjhZbfGV1OVyU8nECA== X-Received: by 2002:a05:6a00:134b:: with SMTP id k11mr1808582pfu.33.1643307498793; Thu, 27 Jan 2022 10:18:18 -0800 (PST) Received: from nathanxps13 ([50.54.155.70]) by smtp.gmail.com with ESMTPSA id z14sm6180192pfq.3.2022.01.27.10.18.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 27 Jan 2022 10:18:18 -0800 (PST) Date: Thu, 27 Jan 2022 10:18:15 -0800 From: Nathan Bossart To: Michael Paquier Cc: "Bossart, Nathan" , Robert Haas , Fujii Masao , "wangsh.fnst@fujitsu.com" , Andres Freund , Bharath Rupireddy , Greg Sabino Mullane , Tom Lane , "pgsql-hackers@lists.postgresql.org" Subject: Re: make MaxBackends available in _PG_init Message-ID: <20220127181815.GA551692@nathanxps13> References: <01c32f6c-8101-1ce4-8295-534cf067df94@oss.nttdata.com> <7239E4F9-A46D-4A61-9200-8B1366D03ADB@amazon.com> <1E960D8B-24D7-43E0-9744-C5F8C52DDEB4@amazon.com> MIME-Version: 1.0 Content-Type: multipart/mixed; boundary="BOKacYhQ+x31HxR3" Content-Disposition: inline In-Reply-To: List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk --BOKacYhQ+x31HxR3 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline 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/ --BOKacYhQ+x31HxR3 Content-Type: text/x-diff; charset=us-ascii Content-Disposition: attachment; filename="v7-0001-Adjust-comments-about-registering-background-work.patch" From 4bc21dc199616824b8f5790e8112ebf149f45207 Mon Sep 17 00:00:00 2001 From: Nathan Bossart 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.c index 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.c index 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 --BOKacYhQ+x31HxR3--