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 1nesNI-0007xM-7B for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Apr 2022 05:50:36 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nesNH-0007Fq-0K for pgsql-hackers@arkaria.postgresql.org; Thu, 14 Apr 2022 05:50:35 +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 1nesNG-0007Fh-LC for pgsql-hackers@lists.postgresql.org; Thu, 14 Apr 2022 05:50:34 +0000 Received: from mail-pl1-x632.google.com ([2607:f8b0:4864:20::632]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.92) (envelope-from ) id 1nesNE-0007oo-Ct for pgsql-hackers@lists.postgresql.org; Thu, 14 Apr 2022 05:50:33 +0000 Received: by mail-pl1-x632.google.com with SMTP id p10so3808974plf.9 for ; Wed, 13 Apr 2022 22:50:32 -0700 (PDT) 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=0nxWstkr4tEPEd0AOqv8+C280Byh72/7hW6bwhy2hnU=; b=mNoYf4Bb0u+XsCT0YmZxKfqWDfiPLkT48aY1S31wwK/TU+YUT2b/VrZJYEcwIYCoOC vC/2RgNNvUGUao9ppBqeEdYqv0BxtYFnVP2VfO2Awr2TEs2zbfMJ5YE5wv2DrZd8LMH5 ZrBTD3S3f7jAzc3+XhyffaMnTiZZP7GTVc4I9wU+VM/XPKjfjFB8YTWpxfCOq2gpkxdR /fDXy8bCyHs5a52O/JbUOksTbJjamGUuqxIeC0u13OS/ehaDsOfzWOX3Zioq4QDj9D2H t002ReQKcHaZzPm2ALjT3z4lD4EmUWjtfP4uCg/eufAwXb41CHIJ3/ol/5NsTqeF/BW7 mORA== 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=0nxWstkr4tEPEd0AOqv8+C280Byh72/7hW6bwhy2hnU=; b=CFrvcxI9NeyBSzLIt+jKo6bqZr7vllbI85Af6Je9S1U/9R2IIZ7SlauT2Kf8QbfnwX vBu+HAbglTSI6m44IV2/ZhH2ZVIZsmei5Fl2CRt8kzLjIFcQxRAHcx3lRLFLjVamPRLC ZODaFMeNl+AR6DlZ++p9B2qSb8ReUwHEfmrTu/DZ9xM3C3Asz6gG7uet9fakkp5YVGic f0b6V1r+K0NVcuQXrZOlmviuPipe8JSJsWMEomQZtD3PvVIlf05I3ifBu30iBeeJRE3v vlZ5EwIRHkO88TREIWmTXSlfPrSW+o624RW01knoLOeO2H6GHSAAqZCG5uhemAy5UQ+H xU6g== X-Gm-Message-State: AOAM5315dtWCsZmMyzWq6JFR/0a10w16qqH7aNUAe7WOhZFa14lvUE9a fnQvoOGW+RxoRoOpGTfNfZI= X-Google-Smtp-Source: ABdhPJyT3Lpv68LJDOT6LE6Rk1lg0qqb9/2USUGv23A7Ij7E7XTbyAnM68mCJXWmjpRZV6jUS+gPyg== X-Received: by 2002:a17:90a:d584:b0:1bc:e520:91f2 with SMTP id v4-20020a17090ad58400b001bce52091f2mr2608624pju.192.1649915430762; Wed, 13 Apr 2022 22:50:30 -0700 (PDT) Received: from jrouhaud (2001-b011-1005-f552-11af-c6c3-5701-767e.dynamic-ip6.hinet.net. [2001:b011:1005:f552:11af:c6c3:5701:767e]) by smtp.gmail.com with ESMTPSA id z6-20020a056a00240600b004e17ab23340sm876389pfh.177.2022.04.13.22.50.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 13 Apr 2022 22:50:30 -0700 (PDT) Date: Thu, 14 Apr 2022 13:50:24 +0800 From: Julien Rouhaud To: Nathan Bossart Cc: Tom Lane , Robert Haas , Andres Freund , Michael Paquier , "Bossart, Nathan" , Fujii Masao , "wangsh.fnst@fujitsu.com" , Bharath Rupireddy , Greg Sabino Mullane , "pgsql-hackers@lists.postgresql.org" Subject: Re: make MaxBackends available in _PG_init Message-ID: References: <20220412222616.GA2113503@nathanxps13> <1088297.1649856441@sss.pgh.pa.us> <1095139.1649860995@sss.pgh.pa.us> <1100207.1649864342@sss.pgh.pa.us> <1102589.1649865908@sss.pgh.pa.us> <20220413183040.GA2116671@nathanxps13> MIME-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <20220413183040.GA2116671@nathanxps13> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk On Wed, Apr 13, 2022 at 11:30:40AM -0700, Nathan Bossart wrote: > On Wed, Apr 13, 2022 at 12:05:08PM -0400, Tom Lane wrote: > > Robert Haas writes: > >> It may be too much to hope that we're going to completely get rid of > >> process_shared_preload_libraries_in_progress tests. > > > > Perhaps, but this is definitely an area that could stand to have some > > serious design thought put into it. You're quite right that it's > > largely a mess today, but I think proposals like "forbid setting GUCs > > during _PG_init" would add to the mess rather than clean things up. > > +1. The simplest design might be to just make a separate preload hook. > _PG_init() would install hooks, and then this preload hook would do > anything that needs to happen when the library is loaded via s_p_l. > However, I think we still want a new shmem request hook where MaxBackends > is initialized. Yeah this one seems needed no matter what. > If we do move forward with the shmem request hook, do we want to disallow > shmem requests anywhere else, or should we just leave it up to extension > authors to do the right thing? Many shmem requests in _PG_init() are > probably okay unless they depend on MaxBackends or another GUC that someone > might change. Given that, I think I currently prefer the latter (option B > from upthread). I'd be in favor of a hard break. There are already multiple extensions that relies on non final value of GUCs to size their shmem request. And as an extension author it can be hard to realize that, as those extensions work just fine until someone wants to try it with some other extension that changes some GUC. Forcing shmem request in a new hook will make sure that it's *always* correct, and that only requires very minimal work on the extension side.