mirror of
https://github.com/postgres/postgres.git
synced 2025-07-27 12:41:57 +03:00
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.
This commit is contained in:
@ -8,7 +8,7 @@
|
||||
*
|
||||
*
|
||||
* IDENTIFICATION
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.198 2008/01/01 19:45:52 momjian Exp $
|
||||
* $PostgreSQL: pgsql/src/backend/storage/lmgr/proc.c,v 1.199 2008/01/26 19:55:08 tgl Exp $
|
||||
*
|
||||
*-------------------------------------------------------------------------
|
||||
*/
|
||||
@ -486,20 +486,18 @@ HaveNFreeProcs(int n)
|
||||
/*
|
||||
* Cancel any pending wait for lock, when aborting a transaction.
|
||||
*
|
||||
* Returns true if we had been waiting for a lock, else false.
|
||||
*
|
||||
* (Normally, this would only happen if we accept a cancel/die
|
||||
* interrupt while waiting; but an ereport(ERROR) while waiting is
|
||||
* within the realm of possibility, too.)
|
||||
*/
|
||||
bool
|
||||
void
|
||||
LockWaitCancel(void)
|
||||
{
|
||||
LWLockId partitionLock;
|
||||
|
||||
/* Nothing to do if we weren't waiting for a lock */
|
||||
if (lockAwaited == NULL)
|
||||
return false;
|
||||
return;
|
||||
|
||||
/* Turn off the deadlock timer, if it's still running (see ProcSleep) */
|
||||
disable_sig_alarm(false);
|
||||
@ -538,12 +536,6 @@ LockWaitCancel(void)
|
||||
* wakeup signal isn't harmful, and it seems not worth expending cycles to
|
||||
* get rid of a signal that most likely isn't there.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Return true even if we were kicked off the lock before we were able to
|
||||
* remove ourselves.
|
||||
*/
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
|
Reference in New Issue
Block a user