]> granicus.if.org Git - postgresql/commitdiff
Fix walsender processes to establish a SIGALRM handler.
authorTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Jul 2012 18:30:10 +0000 (14:30 -0400)
committerTom Lane <tgl@sss.pgh.pa.us>
Thu, 12 Jul 2012 18:30:10 +0000 (14:30 -0400)
Walsenders must have working SIGALRM handling during InitPostgres,
but they set the handler to SIG_IGN so that nothing would happen
if a timeout was reached.  This could result in two failure modes:

* If a walsender participated in a deadlock during its authentication
transaction, and was the last to wait in the deadly embrace, the deadlock
would not get cleared automatically.  This would require somebody to be
trying to take out AccessExclusiveLock on multiple system catalogs, so
it's not very probable.

* If a client failed to respond to a walsender's authentication challenge,
the intended disconnect after AuthenticationTimeout wouldn't happen, and
the walsender would wait indefinitely for the client.

For the moment, fix in back branches only, since this is fixed in a
different way in the timeout-infrastructure patch that's awaiting
application to HEAD.  If we choose not to apply that, then we'll need
to do this in HEAD as well.

src/backend/replication/walsender.c

index 2a16888b0ff8821d7eeac442ddadbf11192f25f2..5c40a1ef1b59a445e47a5ffb86b4128fd3553382 100644 (file)
@@ -47,6 +47,7 @@
 #include "storage/fd.h"
 #include "storage/ipc.h"
 #include "storage/pmsignal.h"
+#include "storage/proc.h"
 #include "tcop/tcopprot.h"
 #include "utils/guc.h"
 #include "utils/memutils.h"
@@ -844,7 +845,7 @@ WalSndSignals(void)
        pqsignal(SIGINT, SIG_IGN);      /* not used */
        pqsignal(SIGTERM, WalSndShutdownHandler);       /* request shutdown */
        pqsignal(SIGQUIT, WalSndQuickDieHandler);       /* hard crash time */
-       pqsignal(SIGALRM, SIG_IGN);
+       pqsignal(SIGALRM, handle_sig_alarm);
        pqsignal(SIGPIPE, SIG_IGN);
        pqsignal(SIGUSR1, SIG_IGN); /* not used */
        pqsignal(SIGUSR2, WalSndLastCycleHandler);      /* request a last cycle and