Fix postmaster failing to exit when startup crashes during crash restart Commit 9b43e6793b0f removed the PM_STARTUP shortcut that exited the postmaster directly when the startup process died, routing the case through HandleChildCrash() so that children processes running during PM_STARTUP are cleaned up rather than orphaned.
However, HandleChildCrash() does nothing if FatalError is already set, and that is exactly the case while reinitializing after a crash: a relaunched startup process that dies before WAL redo starts would leave the state machine stuck at PM_STARTUP, preventing the postmaster to shut down. This issue is fixed by restoring the pre-9b43e6793b0f shortcut behavior: if FatalError is set when the startup process crashes, signal the remaining children and move to PM_NO_CHILDREN, so as the postmaster can properly exit with nothing orphaned. This is only reachable in v18 and newer versions, the early return of HandleChildCrash() on FatalError being introduced in f0b7ab725139. This issue has been reported on Windows, for a postmaster with its console gone. A trick to make InitPostmasterChild() fail aggressively was equally able to stuck a postmaster. Reported-by: Kuan-Ting Kuo <[email protected]> Author: Zexin Li <[email protected]> Discussion: https://postgr.es/m/[email protected] Backpatch-through: 18 Branch ------ master Details ------- https://git.postgresql.org/pg/commitdiff/ead8f696b7cd013c0825ee98761a9cea28d73715 Modified Files -------------- src/backend/postmaster/postmaster.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-)
