pgsql: Improve client error messages for immediate-stop situations. - Mailing list pgsql-committers

From Tom Lane
Subject pgsql: Improve client error messages for immediate-stop situations.
Date
Msg-id E1ksUsp-0004KJ-2J@gemulon.postgresql.org
Whole thread Raw
List pgsql-committers
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

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/7e784d1dc191be24480a6b31a4ddc8e0e52be24d

Modified Files
--------------
src/backend/postmaster/postmaster.c |  4 ++++
src/backend/storage/ipc/pmsignal.c  | 39 ++++++++++++++++++++++++++++++--
src/backend/tcop/postgres.c         | 45 ++++++++++++++++++++++++++-----------
src/include/storage/pmsignal.h      | 14 +++++++++++-
4 files changed, 86 insertions(+), 16 deletions(-)


pgsql-committers by date:

Previous
From: Michael Paquier
Date:
Subject: pgsql: Fix typos and grammar in docs and comments
Next
From: Tom Lane
Date:
Subject: pgsql: Fix race condition between shutdown and unstarted background wor