diff options
Diffstat (limited to 'src/backend/access')
-rw-r--r-- | src/backend/access/transam/xact.c | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/src/backend/access/transam/xact.c b/src/backend/access/transam/xact.c index bab048d38a1..b467b5c89d1 100644 --- a/src/backend/access/transam/xact.c +++ b/src/backend/access/transam/xact.c @@ -34,6 +34,7 @@ #include "commands/trigger.h" #include "executor/spi.h" #include "libpq/be-fsstubs.h" +#include "libpq/pqsignal.h" #include "miscadmin.h" #include "pgstat.h" #include "replication/walsender.h" @@ -52,6 +53,7 @@ #include "utils/memutils.h" #include "utils/relmapper.h" #include "utils/snapmgr.h" +#include "utils/timeout.h" #include "utils/timestamp.h" #include "pg_trace.h" @@ -2297,6 +2299,22 @@ AbortTransaction(void) LockErrorCleanup(); /* + * If any timeout events are still active, make sure the timeout interrupt + * is scheduled. This covers possible loss of a timeout interrupt due to + * longjmp'ing out of the SIGINT handler (see notes in handle_sig_alarm). + * We delay this till after LockErrorCleanup so that we don't uselessly + * reschedule lock or deadlock check timeouts. + */ + reschedule_timeouts(); + + /* + * Re-enable signals, in case we got here by longjmp'ing out of a signal + * handler. We do this fairly early in the sequence so that the timeout + * infrastructure will be functional if needed while aborting. + */ + PG_SETMASK(&UnBlockSig); + + /* * check the current transaction state */ if (s->state != TRANS_INPROGRESS && s->state != TRANS_PREPARE) @@ -4222,9 +4240,29 @@ AbortSubTransaction(void) AbortBufferIO(); UnlockBuffers(); + /* + * Also clean up any open wait for lock, since the lock manager will choke + * if we try to wait for another lock before doing this. + */ LockErrorCleanup(); /* + * If any timeout events are still active, make sure the timeout interrupt + * is scheduled. This covers possible loss of a timeout interrupt due to + * longjmp'ing out of the SIGINT handler (see notes in handle_sig_alarm). + * We delay this till after LockErrorCleanup so that we don't uselessly + * reschedule lock or deadlock check timeouts. + */ + reschedule_timeouts(); + + /* + * Re-enable signals, in case we got here by longjmp'ing out of a signal + * handler. We do this fairly early in the sequence so that the timeout + * infrastructure will be functional if needed while aborting. + */ + PG_SETMASK(&UnBlockSig); + + /* * check the current transaction state */ ShowTransactionState("AbortSubTransaction"); |