summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPavan Deolasee2018-06-18 09:16:08 +0000
committerPavan Deolasee2018-07-27 07:59:53 +0000
commita6ea0d32baf68e696f17c6696a82c17b2f232871 (patch)
treeeab068115d3d7e85eb93c5c5de697a3ab824e667
parentebb11cfa503b186e1f1d087e2b89b883e7e08aae (diff)
Ensure pooler process follows consistent model for SIGQUIT handling
We'd occassionally seen that the pooler process fails to respond to SIGQUIT and gets stuck in a non recoverable state. Code inspection reveals that we're not following the model followed by rest of the background worker processes in handling SIGQUIT. So get that fixed, with the hope that this will fix the problem case.
-rw-r--r--src/backend/pgxc/pool/poolmgr.c21
1 files changed, 21 insertions, 0 deletions
diff --git a/src/backend/pgxc/pool/poolmgr.c b/src/backend/pgxc/pool/poolmgr.c
index 6aa2922813..2152ed8e5d 100644
--- a/src/backend/pgxc/pool/poolmgr.c
+++ b/src/backend/pgxc/pool/poolmgr.c
@@ -259,6 +259,7 @@
#include "pgxc/poolmgr.h"
#include "pgxc/poolutils.h"
#include "postmaster/postmaster.h" /* For UnixSocketDir */
+#include "storage/ipc.h"
#include "storage/procarray.h"
#include "utils/varlena.h"
@@ -3485,7 +3486,27 @@ pooler_die(SIGNAL_ARGS)
static void
pooler_quickdie(SIGNAL_ARGS)
{
+ sigaddset(&BlockSig, SIGQUIT); /* prevent nested calls */
PG_SETMASK(&BlockSig);
+
+ /*
+ * We DO NOT want to run proc_exit() callbacks -- we're here because
+ * shared memory may be corrupted, so we don't want to try to clean up our
+ * transaction. Just nail the windows shut and get out of town. Now that
+ * there's an atexit callback to prevent third-party code from breaking
+ * things by calling exit() directly, we have to reset the callbacks
+ * explicitly to make this work as intended.
+ */
+ on_exit_reset();
+
+ /*
+ * Note we do exit(2) not exit(0). This is to force the postmaster into a
+ * system reset cycle if some idiot DBA sends a manual SIGQUIT to a random
+ * backend. This is necessary precisely because we don't clean up our
+ * shared memory state. (The "dead man switch" mechanism in pmsignal.c
+ * should ensure the postmaster sees this as a crash, too, but no harm in
+ * being doubly sure.)
+ */
exit(2);
}