Re: make MaxBackends available in _PG_init
Tom Lane <tgl@sss.pgh.pa.us>
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Robert Haas <robertmhaas@gmail.com>
Cc: Nathan Bossart <nathandbossart@gmail.com>,
Andres Freund <andres@anarazel.de>,
Julien Rouhaud <rjuju123@gmail.com>,
Michael Paquier <michael@paquier.xyz>,
"Bossart,
Nathan" <bossartn@amazon.com>,
Fujii Masao <masao.fujii@oss.nttdata.com>,
"wangsh.fnst@fujitsu.com" <wangsh.fnst@fujitsu.com>,
Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>,
Greg Sabino Mullane <htamfids@gmail.com>,
"pgsql-hackers@lists.postgresql.org"
<pgsql-hackers@lists.postgresql.org>
Date: 2022-04-13T15:39:02Z
Lists: pgsql-hackers
Robert Haas <robertmhaas@gmail.com> 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
Commits
-
Add a new shmem_request_hook hook.
- 4f2400cb3f10 15.0 landed
-
Remove non-functional code for unloading loadable modules.
- ab02d702ef08 15.0 landed
-
Fix misleading comments about background worker registration.
- 701d918a426b 15.0 landed
-
Revert the addition of GetMaxBackends() and related stuff.
- 7fc0e7de9fb8 15.0 landed
-
Fix typo in multixact.c
- 0147fc7c8c92 15.0 landed
-
Reduce more the number of calls to GetMaxBackends()
- 4567596316d1 15.0 landed
-
Remove MaxBackends variable in favor of GetMaxBackends() function.
- aa64f23b0292 15.0 landed
-
Fix comments about bgworker registration before MaxBackends initialization
- 5ecd0183fb6a 15.0 landed
-
Fix bogus assertion in BootstrapModeMain().
- e12694523e7e 15.0 cited
-
Make sure MaxBackends is always set
- dfbba2c86cc8 9.3.0 cited