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 1nef5M-000106-VB for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Apr 2022 15:39:12 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.92) (envelope-from ) id 1nef5L-0007PK-Rf for pgsql-hackers@arkaria.postgresql.org; Wed, 13 Apr 2022 15:39:11 +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 1nef5L-0007P7-I2 for pgsql-hackers@lists.postgresql.org; Wed, 13 Apr 2022 15:39:11 +0000 Received: from sss.pgh.pa.us ([66.207.139.130]) by makus.postgresql.org with esmtps (TLS1.3:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.92) (envelope-from ) id 1nef5J-00018A-9Z for pgsql-hackers@lists.postgresql.org; Wed, 13 Apr 2022 15:39:10 +0000 Received: from sss1.sss.pgh.pa.us (localhost [127.0.0.1]) by sss.pgh.pa.us (8.15.2/8.15.2) with ESMTP id 23DFd2nC1100208; Wed, 13 Apr 2022 11:39:02 -0400 From: Tom Lane To: Robert Haas cc: Nathan Bossart , Andres Freund , Julien Rouhaud , 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 In-reply-to: References: <20220411211435.GA2057981@nathanxps13> <20220412174427.sngj2uexzsttazs2@alap3.anarazel.de> <20220412180306.GA2063516@nathanxps13> <908945.1649791317@sss.pgh.pa.us> <20220412195908.GA2064996@nathanxps13> <918045.1649797122@sss.pgh.pa.us> <20220412210745.GB2065815@nathanxps13> <995617.1649799996@sss.pgh.pa.us> <20220412222616.GA2113503@nathanxps13> <1088297.1649856441@sss.pgh.pa.us> <1095139.1649860995@sss.pgh.pa.us> Comments: In-reply-to Robert Haas message dated "Wed, 13 Apr 2022 11:25:43 -0400" MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-ID: <1100206.1649864342.1@sss.pgh.pa.us> Date: Wed, 13 Apr 2022 11:39:02 -0400 Message-ID: <1100207.1649864342@sss.pgh.pa.us> List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Archived-At: Precedence: bulk Robert Haas writes: > I guess my feeling about this is that _PG_init() is sort of a grab > bag, and that's not very good. You're supposed to register new GUCs > there, and request shared memory space, and install any hook functions > you want to use, and maybe some other stuff. But why is it appropriate > for all of those things to happen at the same time? I think it pretty > clearly isn't, and that's why you see _PG_init() functions testing > process_shared_preload_libraries_in_progress, and why > RequestAddinShmemSpace() is a no-op if it's not the right time for > such things. To me, all of that is just a sign that the system is > badly designed. Hmm, that's a good point. If we can replace "RequestAddinShmemSpace does nothing if called at the wrong time" with "RequestAddinShmemSpace throws error if called at the wrong time", that seems like a pretty clear improvement in robustness. Is there anything else typically done in _PG_init that has to be conditional on process_shared_preload_libraries_in_progress? I recall something about reserving LWLocks, which probably should get the same treatment. If we can get to a point where _PG_init shouldn't need to care about process_shared_preload_libraries_in_progress, because all the stuff that would care is moved to this new hook, then that would be very clear cleanup. regards, tom lane