Re: straightening out backend process startup

Robert Haas <robertmhaas@gmail.com>

From: Robert Haas <robertmhaas@gmail.com>
To: Andres Freund <andres@anarazel.de>
Cc: "pgsql-hackers@postgresql.org" <pgsql-hackers@postgresql.org>
Date: 2021-08-04T20:34:52Z
Lists: pgsql-hackers
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.

> - 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.

-- 
Robert Haas
EDB: http://www.enterprisedb.com



Commits

  1. process startup: Split single user code out of PostgresMain().

  2. process startup: Do InitProcess() at the same time regardless of EXEC_BACKEND.

  3. process startup: Initialize PgStartTime earlier in single user mode.

  4. pgstat: Schedule per-backend pgstat shutdown via before_shmem_exit().

  5. pgstat: Bring up pgstat in BaseInit() to fix uninitialized use of pgstat by AV.

  6. process startup: Always call Init[Auxiliary]Process() before BaseInit().

  7. process startup: Centralize pgwin32_signal_initialize() calls.

  8. process startup: Remove bootstrap / checker modes from AuxProcType.

  9. process startup: Move AuxiliaryProcessMain into its own file.

  10. process startup: auxprocess: reindent block

  11. process startup: Separate out BootstrapModeMain from AuxiliaryProcessMain.

  12. process startup: Rename postmaster's --forkboot to --forkaux.