Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commitdae52bf

Browse files
committed
Oops, I had managed to break query-cancel-while-waiting-for-lock.
1 parent64e6c60 commitdae52bf

File tree

3 files changed

+30
-10
lines changed

3 files changed

+30
-10
lines changed

‎src/backend/storage/lmgr/proc.c

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.93 2001/01/1606:11:34 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.94 2001/01/1620:59:34 tgl Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -48,7 +48,7 @@
4848
*This is so that we can support more backends. (system-wide semaphore
4949
*sets run out pretty fast.) -ay 4/95
5050
*
51-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.93 2001/01/1606:11:34 tgl Exp $
51+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.94 2001/01/1620:59:34 tgl Exp $
5252
*/
5353
#include"postgres.h"
5454

@@ -353,16 +353,19 @@ RemoveFromWaitQueue(PROC *proc)
353353
/*
354354
* Cancel any pending wait for lock, when aborting a transaction.
355355
*
356+
* Returns true if we had been waiting for a lock, else false.
357+
*
356358
* (Normally, this would only happen if we accept a cancel/die
357359
* interrupt while waiting; but an elog(ERROR) while waiting is
358360
* within the realm of possibility, too.)
359361
*/
360-
void
362+
bool
361363
LockWaitCancel(void)
362364
{
363365
/* Nothing to do if we weren't waiting for a lock */
364366
if (!waitingForLock)
365-
return;
367+
return false;
368+
366369
waitingForLock= false;
367370

368371
/* Turn off the deadlock timer, if it's still running (see ProcSleep) */
@@ -395,6 +398,12 @@ LockWaitCancel(void)
395398
* prematurely.
396399
*/
397400
ZeroProcSemaphore(MyProc);
401+
402+
/*
403+
* Return true even if we were kicked off the lock before we were
404+
* able to remove ourselves.
405+
*/
406+
return true;
398407
}
399408

400409

‎src/backend/tcop/postgres.c

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.201 2001/01/14 05:08:16 tgl Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.202 2001/01/16 20:59:34 tgl Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -940,11 +940,14 @@ die(SIGNAL_ARGS)
940940
InterruptPending= true;
941941
ProcDiePending= true;
942942
/*
943-
* If we're waiting for input, service the interrupt immediately
943+
* If it's safe to interrupt, and we're waiting for input or a lock,
944+
* service the interrupt immediately
944945
*/
945946
if (ImmediateInterruptOK&&CritSectionCount==0)
946947
{
947948
DisableNotifyInterrupt();
949+
/* Make sure HandleDeadLock won't run while shutting down... */
950+
LockWaitCancel();
948951
ProcessInterrupts();
949952
}
950953
}
@@ -967,8 +970,16 @@ QueryCancelHandler(SIGNAL_ARGS)
967970
InterruptPending= true;
968971
QueryCancelPending= true;
969972
/*
970-
* No point in raising Cancel if we are waiting for input ...
973+
* If it's safe to interrupt, and we're waiting for a lock,
974+
* service the interrupt immediately. No point in interrupting
975+
* if we're waiting for input, however.
971976
*/
977+
if (ImmediateInterruptOK&&CritSectionCount==0&&
978+
LockWaitCancel())
979+
{
980+
DisableNotifyInterrupt();
981+
ProcessInterrupts();
982+
}
972983
}
973984

974985
errno=save_errno;
@@ -1668,7 +1679,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[], const cha
16681679
if (!IsUnderPostmaster)
16691680
{
16701681
puts("\nPOSTGRES backend interactive interface ");
1671-
puts("$Revision: 1.201 $ $Date: 2001/01/14 05:08:16 $\n");
1682+
puts("$Revision: 1.202 $ $Date: 2001/01/16 20:59:34 $\n");
16721683
}
16731684

16741685
/*

‎src/include/storage/proc.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
88
* Portions Copyright (c) 1994, Regents of the University of California
99
*
10-
* $Id: proc.h,v 1.35 2001/01/1606:11:34 tgl Exp $
10+
* $Id: proc.h,v 1.36 2001/01/1620:59:34 tgl Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -140,7 +140,7 @@ extern PROC *ProcWakeup(PROC *proc, int errType);
140140
externintProcLockWakeup(LOCKMETHODlockmethod,LOCK*lock);
141141
externvoidProcAddLock(SHM_QUEUE*elem);
142142
externvoidProcReleaseSpins(PROC*proc);
143-
externvoidLockWaitCancel(void);
143+
externboolLockWaitCancel(void);
144144
externvoidHandleDeadLock(SIGNAL_ARGS);
145145

146146
#endif/* PROC_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp