pg.ddx.io  pgsql-hackers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Julien Rouhaud <rjuju123@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: Michael Paquier <michael@paquier.xyz>
Cc: Robert Haas <robertmhaas@gmail.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>
Cc: Bossart, Nathan <bossartn@amazon.com>
Cc: Fujii Masao <masao.fujii@oss.nttdata.com>
Cc: wangsh.fnst@fujitsu.com <wangsh.fnst@fujitsu.com>
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: Sun, 27 Mar 2022 12:15:25 +0800
Message-ID: <20220327041525.nmpansfuez5wpocw@jrouhaud> (raw)
In-Reply-To: <20220326172316.obspcdmjqerislri@alap3.anarazel.de>
References: <20220323130318.hazuzotfcb6zadcc@jrouhaud>
	<20220324202050.GA1855897@nathanxps13>
	<CA+TgmoaonHdak_8utKJCirZNA==62Om_xSnMrm7j2zZox-U8WA@mail.gmail.com>
	<20220325023951.purgu4gb5jyrtc7w@jrouhaud>
	<20220325031146.cd23gaak5qlzdy6l@jrouhaud>
	<Yj1OOR/oQOrEt7OI@paquier.xyz>
	<20220325063542.n6die7fmawluqkfp@jrouhaud>
	<20220325222317.dftrmzuyrb3iv62o@alap3.anarazel.de>
	<20220326072203.asge6bua7dxczf7m@jrouhaud>
	<20220326172316.obspcdmjqerislri@alap3.anarazel.de>

On Sat, Mar 26, 2022 at 10:23:16AM -0700, Andres Freund wrote:
>
> On 2022-03-26 15:22:03 +0800, Julien Rouhaud wrote:
> > On Fri, Mar 25, 2022 at 03:23:17PM -0700, Andres Freund wrote:
> > >
> > > I don't really understand. The issue that started this thread was bugs in
> > > extensions due to accessing MaxBackends before it is initialized - which the
> > > patch prevents.
> > 
> > Well, the patch prevents accessing a 0-valued MaxBackends but doesn't do
> > anything to solve the original complaint.  It's not like extensions won't need
> > to access that information during _PG_init anymore.
> 
> It resolves the pretty common bug that an extension breaks once it's used via
> s_p_l instead of loaded on-demand because MaxBackends isn't initialized in the
> s_p_l case.

I can hear the argument.  However I don't know any extension that relies on
MaxBackends and doesn't need to be in s_p_l, and unless I'm missing something
no one provided such an example, only people needing the value for
RequestAddinShmemSpace().

> > And indeed, any third party code that previously needed to access what
> > MaxBackends is supposed to store should already be using that formula, and
> > the new GetMaxBackends() doesn't do anything about it.
> 
> It couldn't rely on MaxBackends before. It can't rely on GetMaxBackends()
> now. You can see why I think that what you want is unrelated to the
> introduction of GetMaxBackends().

Sure, but code also couldn't really rely on MaxConnections or any other similar
GUCs and yet nothing is done for that, and the chosen approach doesn't help for
that.

The only difference is that those GUCs are less broken, as in the value is
likely to be valid more often, and closer to the final value when it's not.
But still broken.

I think GetMaxBackends() is more likely to force authors to rely on computing
the value using the underlying GUCs, since there's nothing else that can be
done.  And if that's an acceptable answer, why aren't we computing MaxBackends
before and after processing s_p_l?

> If we introduce a separate hook that allows to influence things like
> max_connections or whatnot we'd *even more* need a way to verify whether it's
> legal to access MaxBackends in that moment.

Again, I'm not opposed to validating that MaxBackends is valid when third-party
code is accessing it, quite the opposite.  I'm opposed to do so *only* for
MaxBackends, and without providing a way for third-party code to access that
value when they need it, which is for all the cases I know (after more digging
that's now 5 extensions) for RequestAddinShmemSpace().





view thread (132+ messages)  latest in thread

Message-ID: <20220327041525.nmpansfuez5wpocw@jrouhaud>
Permalink:  ../20220327041525.nmpansfuez5wpocw@jrouhaud/
Also on:    postgresql.org/message-id/20220327041525.nmpansfuez5wpocw@jrouhaud

 · 

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 from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-hackers@postgresql.org
  Cc: rjuju123@gmail.com, andres@anarazel.de, michael@paquier.xyz, robertmhaas@gmail.com, nathandbossart@gmail.com, bossartn@amazon.com, masao.fujii@oss.nttdata.com, wangsh.fnst@fujitsu.com, bharath.rupireddyforpostgres@gmail.com, htamfids@gmail.com, tgl@sss.pgh.pa.us
  Subject: Re: make MaxBackends available in _PG_init
  In-Reply-To: <20220327041525.nmpansfuez5wpocw@jrouhaud>
  References: <20220323130318.hazuzotfcb6zadcc@jrouhaud> <20220324202050.GA1855897@nathanxps13> <CA+TgmoaonHdak_8utKJCirZNA==62Om_xSnMrm7j2zZox-U8WA@mail.gmail.com> <20220325023951.purgu4gb5jyrtc7w@jrouhaud> <20220325031146.cd23gaak5qlzdy6l@jrouhaud> <Yj1OOR/oQOrEt7OI@paquier.xyz> <20220325063542.n6die7fmawluqkfp@jrouhaud> <20220325222317.dftrmzuyrb3iv62o@alap3.anarazel.de> <20220326072203.asge6bua7dxczf7m@jrouhaud> <20220326172316.obspcdmjqerislri@alap3.anarazel.de> <20220327041525.nmpansfuez5wpocw@jrouhaud>

* 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