mirror of
https://github.com/postgres/postgres.git
synced 2025-11-25 12:03:53 +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:
@@ -1,7 +1,7 @@
|
||||
/*-------------------------------------------------------------------------
|
||||
*
|
||||
* pmsignal.h
|
||||
* routines for signaling the postmaster from its child processes
|
||||
* routines for signaling between the postmaster and its child processes
|
||||
*
|
||||
*
|
||||
* Portions Copyright (c) 1996-2020, PostgreSQL Global Development Group
|
||||
@@ -45,6 +45,16 @@ typedef enum
|
||||
NUM_PMSIGNALS /* Must be last value of enum! */
|
||||
} PMSignalReason;
|
||||
|
||||
/*
|
||||
* Reasons why the postmaster would send SIGQUIT to its children.
|
||||
*/
|
||||
typedef enum
|
||||
{
|
||||
PMQUIT_NOT_SENT = 0, /* postmaster hasn't sent SIGQUIT */
|
||||
PMQUIT_FOR_CRASH, /* some other backend bought the farm */
|
||||
PMQUIT_FOR_STOP /* immediate stop was commanded */
|
||||
} QuitSignalReason;
|
||||
|
||||
/* PMSignalData is an opaque struct, details known only within pmsignal.c */
|
||||
typedef struct PMSignalData PMSignalData;
|
||||
|
||||
@@ -55,6 +65,8 @@ extern Size PMSignalShmemSize(void);
|
||||
extern void PMSignalShmemInit(void);
|
||||
extern void SendPostmasterSignal(PMSignalReason reason);
|
||||
extern bool CheckPostmasterSignal(PMSignalReason reason);
|
||||
extern void SetQuitSignalReason(QuitSignalReason reason);
|
||||
extern QuitSignalReason GetQuitSignalReason(void);
|
||||
extern int AssignPostmasterChildSlot(void);
|
||||
extern bool ReleasePostmasterChildSlot(int slot);
|
||||
extern bool IsPostmasterChildWalSender(int slot);
|
||||
|
||||
Reference in New Issue
Block a user