Re: make MaxBackends available in _PG_init

Greg Sabino Mullane <htamfids@gmail.com>

From: Greg Sabino Mullane <htamfids@gmail.com>
To: "Bossart, Nathan" <bossartn@amazon.com>
Cc: Robert Haas <robertmhaas@gmail.com>, Andres Freund <andres@anarazel.de>, Bharath Rupireddy <bharath.rupireddyforpostgres@gmail.com>, "pgsql-hackers@lists.postgresql.org" <pgsql-hackers@lists.postgresql.org>
Date: 2021-08-11T13:41:43Z
Lists: pgsql-hackers
On Mon, Aug 9, 2021 at 8:22 PM Bossart, Nathan <bossartn@amazon.com> wrote:

> > Is this going to get tripped by a call from restore_backend_variables?
>
> I ran 'make check-world' with EXEC_BACKEND with no problems, so I
> don't think so.
>

v3 looks good, but I'm still not sure how to test the bit mentioned above.
I'm not familiar with this part of the code (SubPostmasterMain etc.), but
running make check-world with EXEC_BACKEND does not seem to execute that
code, as I added exit(1) to restore_backend_variables() and the tests still
ran fine. Further digging shows that even though the #ifdef EXEC_BACKEND
path is triggered, no --fork argument was being passed. Is there something
else one needs to provide to force that --fork (see line 189 of
src/backend/main/main.c) when testing?

Cheers,
Greg

Commits

  1. Add a new shmem_request_hook hook.

  2. Remove non-functional code for unloading loadable modules.

  3. Fix misleading comments about background worker registration.

  4. Revert the addition of GetMaxBackends() and related stuff.

  5. Fix typo in multixact.c

  6. Reduce more the number of calls to GetMaxBackends()

  7. Remove MaxBackends variable in favor of GetMaxBackends() function.

  8. Fix comments about bgworker registration before MaxBackends initialization

  9. Fix bogus assertion in BootstrapModeMain().

  10. Make sure MaxBackends is always set