diff options
author | Andres Freund <andres@anarazel.de> | 2015-02-03 22:25:20 +0100 |
---|---|---|
committer | Andres Freund <andres@anarazel.de> | 2015-02-03 22:25:20 +0100 |
commit | 4f85fde8eb860f263384fffdca660e16e77c7f76 (patch) | |
tree | 9d9d18a368f4e7db987140d6dfd384b9e2e51b0a /src/include/commands/async.h | |
parent | 387da18874afa17156ee3af63766f17efb53c4b9 (diff) | |
download | postgresql-4f85fde8eb860f263384fffdca660e16e77c7f76.tar.gz postgresql-4f85fde8eb860f263384fffdca660e16e77c7f76.zip |
Introduce and use infrastructure for interrupt processing during client reads.
Up to now large swathes of backend code ran inside signal handlers
while reading commands from the client, to allow for speedy reaction to
asynchronous events. Most prominently shared invalidation and NOTIFY
handling. That means that complex code like the starting/stopping of
transactions is run in signal handlers... The required code was
fragile and verbose, and is likely to contain bugs.
That approach also severely limited what could be done while
communicating with the client. As the read might be from within
openssl it wasn't safely possible to trigger an error, e.g. to cancel
a backend in idle-in-transaction state. We did that in some cases,
namely fatal errors, nonetheless.
Now that FE/BE communication in the backend employs non-blocking
sockets and latches to block, we can quite simply interrupt reads from
signal handlers by setting the latch. That allows us to signal an
interrupted read, which is supposed to be retried after returning from
within the ssl library.
As signal handlers now only need to set the latch to guarantee timely
interrupt processing, remove a fair amount of complicated & fragile
code from async.c and sinval.c.
We could now actually start to process some kinds of interrupts, like
sinval ones, more often that before, but that seems better done
separately.
This work will hopefully allow to handle cases like being blocked by
sending data, interrupting idle transactions and similar to be
implemented without too much effort. In addition to allowing getting
rid of ImmediateInterruptOK, that is.
Author: Andres Freund
Reviewed-By: Heikki Linnakangas
Diffstat (limited to 'src/include/commands/async.h')
-rw-r--r-- | src/include/commands/async.h | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/src/include/commands/async.h b/src/include/commands/async.h index 87c3abbfee7..8491f4736f7 100644 --- a/src/include/commands/async.h +++ b/src/include/commands/async.h @@ -13,6 +13,8 @@ #ifndef ASYNC_H #define ASYNC_H +#include <signal.h> + #include "fmgr.h" /* @@ -21,6 +23,7 @@ #define NUM_ASYNC_BUFFERS 8 extern bool Trace_notify; +extern volatile sig_atomic_t notifyInterruptPending; extern Size AsyncShmemSize(void); extern void AsyncShmemInit(void); @@ -48,12 +51,7 @@ extern void ProcessCompletedNotifies(void); /* signal handler for inbound notifies (PROCSIG_NOTIFY_INTERRUPT) */ extern void HandleNotifyInterrupt(void); -/* - * enable/disable processing of inbound notifies directly from signal handler. - * The enable routine first performs processing of any inbound notifies that - * have occurred since the last disable. - */ -extern void EnableNotifyInterrupt(void); -extern bool DisableNotifyInterrupt(void); +/* process interrupts */ +extern void ProcessNotifyInterrupt(void); #endif /* ASYNC_H */ |