mirror of
https://github.com/postgres/postgres.git
synced 2025-11-07 19:06:32 +03:00
Improve client error messages for immediate-stop situations.
Up to now, if the DBA issued "pg_ctl stop -m immediate", the message sent to clients was the same as for a crash-and-restart situation. This is confusing, not least because the message claims that the database will soon be up again, something we have no business predicting. Improve things so that we can generate distinct messages for the two cases (and also recognize an ad-hoc SIGQUIT, should somebody try that). To do that, add a field to pmsignal.c's shared memory data structure that the postmaster sets just before broadcasting SIGQUIT to its children. No interlocking seems to be necessary; the intervening signal-sending and signal-receipt should sufficiently serialize accesses to the field. Hence, this isn't any riskier than the existing usages of pmsignal.c. We might in future extend this idea to improve other postmaster-to-children signal scenarios, although none of them currently seem to be as badly overloaded as SIGQUIT. Discussion: https://postgr.es/m/559291.1608587013@sss.pgh.pa.us
This commit is contained in:
@@ -218,6 +218,7 @@ int ReservedBackends;
|
||||
/* The socket(s) we're listening to. */
|
||||
#define MAXLISTEN 64
|
||||
static pgsocket ListenSocket[MAXLISTEN];
|
||||
|
||||
/*
|
||||
* These globals control the behavior of the postmaster in case some
|
||||
* backend dumps core. Normally, it kills all peers of the dead backend
|
||||
@@ -2887,6 +2888,8 @@ pmdie(SIGNAL_ARGS)
|
||||
sd_notify(0, "STOPPING=1");
|
||||
#endif
|
||||
|
||||
/* tell children to shut down ASAP */
|
||||
SetQuitSignalReason(PMQUIT_FOR_STOP);
|
||||
TerminateChildren(SIGQUIT);
|
||||
pmState = PM_WAIT_BACKENDS;
|
||||
|
||||
@@ -3464,6 +3467,7 @@ HandleChildCrash(int pid, int exitstatus, const char *procname)
|
||||
LogChildExit(LOG, procname, pid, exitstatus);
|
||||
ereport(LOG,
|
||||
(errmsg("terminating any other active server processes")));
|
||||
SetQuitSignalReason(PMQUIT_FOR_CRASH);
|
||||
}
|
||||
|
||||
/* Process background workers. */
|
||||
|
||||
Reference in New Issue
Block a user