Re: straightening out backend process startup
Andres Freund <andres@anarazel.de>
Hi, Thanks Robert, Horiguchi-san for looking. On 2021-08-04 16:34:52 -0400, Robert Haas wrote: > On Mon, Aug 2, 2021 at 12:41 PM Andres Freund <andres@anarazel.de> wrote: > > - AuxiliaryProcessMain() is used for two independent tasks: Start bootstrap / > > checker mode and starting auxiliary processes. In HEAD there's maybe 5 lines > > out 250 that are actually common to both uses. > > > > A related oddity is that we reserve shared memory resources for bootstrap & > > checker aux processes, despite those never existing. > > > > This is addressed in patches 1-7 > > This all looks pretty mechanical and, I would guess, not very controversial. Pushed these patches. > > - The order of invocation of InitProcess()/InitAuxiliaryProcess() and > > BaseInit() depends on EXEC_BACKEND. Due to that there often is no single > > place initialization code can be put if it needs any locks. > > > > This is addressed in patches 8-9 > > > > - PostgresMain() has code for single user and multi user interleaved, making > > it unnecessarily hard to understand what's going on. > > > > This is addressed in patches 10 > > This stuff I'd need to study more in order to have an intelligent opinion. Unless somebody protests soon I plan to push at least the "process startup: Always call Init[Auxiliary]Process() before BaseInit()." portion, as the inconsistent order between EXEC_BACKEND/!EB is making life hard for me in other patches. I don't have a dependency on "process startup: Split single user code out of PostgresMain()." but it does make the code a good bit more readable imo... Greetings, Andres Freund
Commits
-
process startup: Split single user code out of PostgresMain().
- 7c83a3bf5148 15.0 landed
-
process startup: Do InitProcess() at the same time regardless of EXEC_BACKEND.
- 3d7c752a2f09 15.0 landed
-
process startup: Initialize PgStartTime earlier in single user mode.
- 2c7615f77b8d 15.0 landed
-
pgstat: Schedule per-backend pgstat shutdown via before_shmem_exit().
- fb2c5028e635 15.0 landed
-
pgstat: Bring up pgstat in BaseInit() to fix uninitialized use of pgstat by AV.
- ee3f8d3d3aec 15.0 landed
-
process startup: Always call Init[Auxiliary]Process() before BaseInit().
- b406478b87e2 15.0 landed
-
process startup: Centralize pgwin32_signal_initialize() calls.
- 07bf37850991 15.0 landed
-
process startup: Remove bootstrap / checker modes from AuxProcType.
- f8dd4ecb0b7f 15.0 landed
-
process startup: Move AuxiliaryProcessMain into its own file.
- 0a692109dcc7 15.0 landed
-
process startup: auxprocess: reindent block
- 27f790346621 15.0 landed
-
process startup: Separate out BootstrapModeMain from AuxiliaryProcessMain.
- 5aa4a9d2077f 15.0 landed
-
process startup: Rename postmaster's --forkboot to --forkaux.
- 50017f77722b 15.0 landed