Skip to content

Commit 47ce595

Browse files
committed
Don't intercept SIGQUIT as a signal to trigger failover; that's what
postmaster uses for immediate shutdown. Trap SIGUSR1 as the preferred signal for that. Per report by Fujii Masao and subsequent discussion on -hackers.
1 parent afcde99 commit 47ce595

File tree

1 file changed

+25
-3
lines changed

1 file changed

+25
-3
lines changed

contrib/pg_standby/pg_standby.c

Lines changed: 25 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* $PostgreSQL: pgsql/contrib/pg_standby/pg_standby.c,v 1.18 2009/02/27 09:30:21 petere Exp $
2+
* $PostgreSQL: pgsql/contrib/pg_standby/pg_standby.c,v 1.19 2009/03/18 19:27:28 heikki Exp $
33
*
44
*
55
* pg_standby.c
@@ -463,6 +463,15 @@ sighandler(int sig)
463463
signaled = true;
464464
}
465465

466+
/* We don't want SIGQUIT to core dump */
467+
static void
468+
sigquit_handler(int sig)
469+
{
470+
signal(SIGINT, SIG_DFL);
471+
kill(getpid(), SIGINT);
472+
}
473+
474+
466475
/*------------ MAIN ----------------------------------------*/
467476
int
468477
main(int argc, char **argv)
@@ -485,8 +494,21 @@ main(int argc, char **argv)
485494
}
486495
}
487496

488-
(void) signal(SIGINT, sighandler);
489-
(void) signal(SIGQUIT, sighandler);
497+
/*
498+
* You can send SIGUSR1 to trigger failover.
499+
*
500+
* Postmaster uses SIGQUIT to request immediate shutdown. The default
501+
* action is to core dump, but we don't want that, so trap it and
502+
* commit suicide without core dump.
503+
*
504+
* We used to use SIGINT and SIGQUIT to trigger failover, but that
505+
* turned out to be a bad idea because postmaster uses SIGQUIT to
506+
* request immediate shutdown. We still trap SIGINT, but that may
507+
* change in a future release.
508+
*/
509+
(void) signal(SIGUSR1, sighandler);
510+
(void) signal(SIGINT, sighandler); /* deprecated, use SIGUSR1 */
511+
(void) signal(SIGQUIT, sigquit_handler);
490512

491513
while ((c = getopt(argc, argv, "cdk:lr:s:t:w:")) != -1)
492514
{

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy