pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Nathan Bossart <nathandbossart@gmail.com>
To: Julien Rouhaud <rjuju123@gmail.com>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Bossart, Nathan <bossartn@amazon.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, 24 Mar 2022 13:20:50 -0700
Message-ID: <20220324202050.GA1855897@nathanxps13> (raw)
In-Reply-To: <20220323130318.hazuzotfcb6zadcc@jrouhaud>
References: <YgMpGZhPOjNfS7er@paquier.xyz>
	<CA+TgmoaggbnV3ThxcBnDDJiQJnOduHRCWX1=kFyKVog+ZVFcCg@mail.gmail.com>
	<YgNOhxDPadZy5q+1@paquier.xyz>
	<CA+TgmoZ7PWOxdCrH6J91qghxiayHJ=UGhg66k8JGd+8_vLz26g@mail.gmail.com>
	<20220209175338.GB1627503@nathanxps13>
	<YgRuu/8g6ntZRdVf@paquier.xyz>
	<20220210192612.GA1684442@nathanxps13>
	<20220323045229.i23skfscdbvrsuxa@jrouhaud>
	<CA+TgmoacGW7kGda0DC+JHXKsa6anEUvfuuSenG=FCohRX_NHzA@mail.gmail.com>
	<20220323130318.hazuzotfcb6zadcc@jrouhaud>

On Wed, Mar 23, 2022 at 09:03:18PM +0800, Julien Rouhaud wrote:
> On Wed, Mar 23, 2022 at 08:32:39AM -0400, Robert Haas wrote:
>> Well, the conclusion upthread was that extensions might change the
>> values of those GUCs from _PG_init(). If that's a real thing, then
>> what you're asking for here is impossible, because the final value is
>> indeterminate until all such extensions have finished twiddling those
>> the GUCs. On the other hand, it's definitely intended that extensions
>> should RequestAddinShmemSpace() from _PG_init(), and wanting to size
>> that memory based on MaxBackends is totally reasonable. Do we need to
>> add another function, alongside _PG_init(), that gets called after
>> MaxBackends is determined and before it's too late to
>> RequestAddinShmemSpace()?
> 
> Yes, I don't see how we can support such extensions without an additional hook,
> probably called right after InitializeMaxBackends() since at least
> InitializeShmemGUCs() will need to know about those extra memory needs.

Another possibility could be to add a hook that is called _before_
_PG_init() where libraries are permitted to adjust GUCs.  After the library
is loaded, we first call this _PG_change_GUCs() function, then we
initialize MaxBackends, and then we finally call _PG_init().  This way,
extensions would have access to MaxBackends within _PG_init(), and if an
extension really needed to alter GUCs, іt could define this new function.

> I'm not sure how to prevent third party code from messing with the gucs in it,
> but a clear indication in the hook comment should probably be enough.  It's not
> like it's hard for third-party code author to break something anyway.

ERROR-ing in SetConfigOption() might be another way to dissuade folks from
messing with GUCs.  This is obviously not a perfect solution.

-- 
Nathan Bossart
Amazon Web Services: https://aws.amazon.com





view thread (132+ messages)  latest in thread

Message-ID: <20220324202050.GA1855897@nathanxps13>
Permalink:  ../20220324202050.GA1855897@nathanxps13/
Also on:    postgresql.org/message-id/20220324202050.GA1855897@nathanxps13

 · 

reply

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, rjuju123@gmail.com, robertmhaas@gmail.com, michael@paquier.xyz, bossartn@amazon.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: <20220324202050.GA1855897@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