postgresql/src/backend/postmaster
Michael Paquier affdb2dd5c 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 7ff23c6d27, 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
2026-04-21 09:40:03 +09:00
..
autovacuum.c Fix snapshot handling bug in recent BRIN fix 2025-11-04 20:31:43 +01:00
auxprocess.c Fix a few oversights in the longer cancel keys patch 2025-04-09 13:11:42 +03:00
bgworker.c Fix background worker not restarting after crash-and-restart cycle. 2025-07-25 18:40:49 +09:00
bgwriter.c aio: Basic subsystem initialization 2025-03-17 18:51:33 -04:00
checkpointer.c Fix checkpointer shared memory allocation 2025-08-07 14:31:18 +03:00
fork_process.c Update copyright for 2025 2025-01-01 11:21:55 -05:00
interrupt.c Fix LOCK_TIMEOUT handling during parallel apply. 2025-09-24 04:00:15 +00:00
launch_backend.c Fix incorrect const qualifier 2025-09-16 07:23:50 +02:00
Makefile Assign a child slot to every postmaster child process 2024-11-14 16:12:28 +02:00
meson.build Update copyright for 2025 2025-01-01 11:21:55 -05:00
pgarch.c Revert function to get memory context stats for processes 2025-05-23 15:44:54 +02:00
pmchild.c aio: Infrastructure for io_method=worker 2025-03-18 11:54:01 -04:00
postmaster.c Fix orphaned processes when startup process fails during PM_STARTUP 2026-04-21 09:40:03 +09:00
startup.c Revert function to get memory context stats for processes 2025-05-23 15:44:54 +02:00
syslogger.c backend launchers void * arguments for binary data 2025-02-21 08:03:33 +01:00
walsummarizer.c Prevent restore of incremental backup from bloating VM fork. 2026-03-09 06:46:20 -04:00
walwriter.c aio: Basic subsystem initialization 2025-03-17 18:51:33 -04:00