diff options
author | Tom Lane <tgl@sss.pgh.pa.us> | 2008-01-26 19:55:08 +0000 |
---|---|---|
committer | Tom Lane <tgl@sss.pgh.pa.us> | 2008-01-26 19:55:08 +0000 |
commit | 6322e84430e2b1756fbf31072679507266f2b304 (patch) | |
tree | 27ba528789d651db8cb7f19ba6e904c97a2cde36 /src/backend/tcop/postgres.c | |
parent | ace1b29b047ffa9474275078065ca697f0d69852 (diff) | |
download | postgresql-6322e84430e2b1756fbf31072679507266f2b304.tar.gz postgresql-6322e84430e2b1756fbf31072679507266f2b304.zip |
Change StatementCancelHandler() to check the DoingCommandRead flag to decide
whether to execute an immediate interrupt, rather than testing whether
LockWaitCancel() cancelled a lock wait. The old way misclassified the case
where we were blocked in ProcWaitForSignal(), and arguably would misclassify
any other future additions of new ImmediateInterruptOK states too. This
allows reverting the old kluge that gave LockWaitCancel() a return value,
since no callers care anymore. Improve comments in the various
implementations of PGSemaphoreLock() to explain that on some platforms, the
assumption that semop() exits after a signal is wrong, and so we must ensure
that the signal handler itself throws elog if we want cancel or die interrupts
to be effective. Per testing related to bug #3883, though this patch doesn't
solve those problems fully.
Perhaps this change should be back-patched, but since pre-8.3 branches aren't
really relying on autovacuum to respond to SIGINT, it doesn't seem critical
for them.
Diffstat (limited to 'src/backend/tcop/postgres.c')
-rw-r--r-- | src/backend/tcop/postgres.c | 21 |
1 files changed, 8 insertions, 13 deletions
diff --git a/src/backend/tcop/postgres.c b/src/backend/tcop/postgres.c index 05127c40b30..325411df09c 100644 --- a/src/backend/tcop/postgres.c +++ b/src/backend/tcop/postgres.c @@ -8,7 +8,7 @@ * * * IDENTIFICATION - * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.541 2008/01/01 19:45:52 momjian Exp $ + * $PostgreSQL: pgsql/src/backend/tcop/postgres.c,v 1.542 2008/01/26 19:55:08 tgl Exp $ * * NOTES * this is the "main" module of the postgres backend and @@ -2449,10 +2449,9 @@ die(SIGNAL_ARGS) /* bump holdoff count to make ProcessInterrupts() a no-op */ /* until we are done getting ready for it */ InterruptHoldoffCount++; + LockWaitCancel(); /* prevent CheckDeadLock from running */ DisableNotifyInterrupt(); DisableCatchupInterrupt(); - /* Make sure CheckDeadLock won't run while shutting down... */ - LockWaitCancel(); InterruptHoldoffCount--; ProcessInterrupts(); } @@ -2498,20 +2497,16 @@ StatementCancelHandler(SIGNAL_ARGS) * waiting for input, however. */ if (ImmediateInterruptOK && InterruptHoldoffCount == 0 && - CritSectionCount == 0) + CritSectionCount == 0 && !DoingCommandRead) { /* bump holdoff count to make ProcessInterrupts() a no-op */ /* until we are done getting ready for it */ InterruptHoldoffCount++; - if (LockWaitCancel()) - { - DisableNotifyInterrupt(); - DisableCatchupInterrupt(); - InterruptHoldoffCount--; - ProcessInterrupts(); - } - else - InterruptHoldoffCount--; + LockWaitCancel(); /* prevent CheckDeadLock from running */ + DisableNotifyInterrupt(); + DisableCatchupInterrupt(); + InterruptHoldoffCount--; + ProcessInterrupts(); } } |