]> git.ipfire.org Git - thirdparty/postgresql.git/commit
Fix orphaned processes when startup process fails during PM_STARTUP master github/master
authorMichael Paquier <michael@paquier.xyz>
Tue, 21 Apr 2026 00:39:59 +0000 (09:39 +0900)
committerMichael Paquier <michael@paquier.xyz>
Tue, 21 Apr 2026 00:39:59 +0000 (09:39 +0900)
commit9b43e6793b0f9dcd2c3935af020cf96cd7b05ec2
treeba5416402aa5563acfefe2f74a32ac5e89cdffcb
parent8155581ec695095711a5abd903a95236fbdfb823
Fix orphaned processes when startup process fails during PM_STARTUP

When the startup process exists with a FATAL error during PM_STARTUP,
the postmaster called ExitPostmaster() directly, assuming that no other
processes are running at this stage.  Since 7ff23c6d277d, this
assumption is not true, as the checkpointer, the background writer, the
IO workers and bgworkers kicking in early would be around.

This commit removes the startup-specific shortcut happening in
process_pm_child_exit() for a failing startup process during PM_STARTUP,
falling down to the existing exit() flow to signal all the started
children with SIGQUIT, so as we have no risk of creating orphaned
processes.

This required an extra change in HandleFatalError() for v18 and newer
versions, as an assertion could be triggered for PM_STARTUP.  It is now
incorrect.  In v17 and older versions, HandleChildCrash() needs to be
changed to handle PM_STARTUP so as children can be waited on.

While on it, fix a comment at the top of postmaster.c.  It was claiming
that the checkpointer and the background writer were started after
PM_RECOVERY.  That is not the case.

Author: Ayush Tiwari <ayushtiwari.slg01@gmail.com>
Discussion: https://postgr.es/m/CAJTYsWVoD3V9yhhqSae1_wqcnTdpFY-hDT7dPm5005ZFsL_bpA@mail.gmail.com
Backpatch-through: 15
src/backend/postmaster/postmaster.c