if (pid == StartupPID)
{
StartupPID = 0;
- Assert(pmState == PM_STARTUP || pmState == PM_RECOVERY);
+ Assert(pmState != PM_RUN);
- /* FATAL exit of startup is treated as catastrophic */
- if (!EXIT_STATUS_0(exitstatus))
+ /*
+ * FATAL exit of startup during PM_STARTUP is treated as
+ * catastrophic. There is no other processes running yet.
+ */
+ if (!EXIT_STATUS_0(exitstatus) && pmState == PM_STARTUP)
{
LogChildExit(LOG, _("startup process"),
pid, exitstatus);
(errmsg("aborting startup due to startup process failure")));
ExitPostmaster(1);
}
+ /*
+ * Any other unexpected exit of the startup process (including
+ * FATAL exit) is treated as a crash.
+ */
+ if (!EXIT_STATUS_0(exitstatus))
+ {
+ HandleChildCrash(pid, exitstatus,
+ _("startup process"));
+ continue;
+ }
/*
* Startup succeeded - we are done with system startup or
* recovery.
*/
- FatalError = false;
+ if (pmState == PM_STARTUP)
+ FatalError = false;
/*
* Go to shutdown mode if a shutdown request was pending.
}
}
+ /* Take care of the startup process too */
+ if (pid == StartupPID)
+ StartupPID = 0;
+ else if (StartupPID != 0 && !FatalError)
+ {
+ ereport(DEBUG2,
+ (errmsg_internal("sending %s to process %d",
+ (SendStop ? "SIGSTOP" : "SIGQUIT"),
+ (int) StartupPID)));
+ signal_child(BgWriterPID, (SendStop ? SIGSTOP : SIGQUIT));
+ }
+
/* Take care of the bgwriter too */
if (pid == BgWriterPID)
BgWriterPID = 0;
FatalError = true;
/* We now transit into a state of waiting for children to die */
if (pmState == PM_RUN ||
+ pmState == PM_RECOVERY ||
pmState == PM_WAIT_BACKUP ||
pmState == PM_SHUTDOWN)
pmState = PM_WAIT_BACKENDS;
else
{
/*
- * Startup process has entered recovery
+ * Startup process has entered recovery. We consider that good
+ * enough to reset FatalError.
*/
pmState = PM_RECOVERY;
+ FatalError = false;
/*
* Load the flat authorization file into postmaster's cache. The