Skip to content

Commit cc0f6ff

Browse files
committed
Fix postmaster to attempt restart after a hot-standby crash.
The postmaster was coded to treat any unexpected exit of the startup process (i.e., the WAL replay process) as a catastrophic crash, and not try to restart it. This was OK so long as the startup process could not have any sibling postmaster children. However, if a hot-standby backend crashes, we SIGQUIT the startup process along with everything else, and the resulting exit is hardly "unexpected". Treating it as such meant we failed to restart a standby server after any child crash at all, not only a crash of the WAL replay process as intended. Adjust that. Back-patch to 9.0 where hot standby was introduced.
1 parent 07e3641 commit cc0f6ff

File tree

1 file changed

+9
-4
lines changed

1 file changed

+9
-4
lines changed

src/backend/postmaster/postmaster.c

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2362,13 +2362,18 @@ reaper(SIGNAL_ARGS)
23622362
}
23632363

23642364
/*
2365-
* Any unexpected exit (including FATAL exit) of the startup
2366-
* process is treated as a crash, except that we don't want to
2367-
* reinitialize.
2365+
* After PM_STARTUP, any unexpected exit (including FATAL exit) of
2366+
* the startup process is catastrophic, so kill other children,
2367+
* and set RecoveryError so we don't try to reinitialize after
2368+
* they're gone. Exception: if FatalError is already set, that
2369+
* implies we previously sent the startup process a SIGQUIT, so
2370+
* that's probably the reason it died, and we do want to try to
2371+
* restart in that case.
23682372
*/
23692373
if (!EXIT_STATUS_0(exitstatus))
23702374
{
2371-
RecoveryError = true;
2375+
if (!FatalError)
2376+
RecoveryError = true;
23722377
HandleChildCrash(pid, exitstatus,
23732378
_("startup process"));
23742379
continue;

0 commit comments

Comments
 (0)