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

Commit5525297

Browse files
author
Hiroshi Inoue
committed
Change cancel while waiting-for-lock stuff.
1 parent167dce8 commit5525297

File tree

5 files changed

+37
-24
lines changed

5 files changed

+37
-24
lines changed

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88
*
99
*
1010
* IDENTIFICATION
11-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.65 2000/01/26 05:57:01 momjian Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.66 2000/02/22 09:55:20 inoue Exp $
1212
*
1313
* NOTES
1414
* Outside modules can create a lock table and acquire/release
@@ -1743,6 +1743,7 @@ DeadLockCheck(void *proc, LOCK *findlock)
17431743
MyProc->xid,
17441744
NULL)==STATUS_OK)
17451745
{
1746+
SetWaitingForLock(false);
17461747
GrantLock(MyProc->waitLock,MyProc->token);
17471748
(MyProc->waitLock->waitProcs.size)--;
17481749
ProcWakeup(MyProc,NO_ERROR);

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

Lines changed: 27 additions & 6 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.68 2000/02/21 02:42:36 inoue Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.69 2000/02/22 09:55:20 inoue Exp $
1212
*
1313
*-------------------------------------------------------------------------
1414
*/
@@ -47,7 +47,7 @@
4747
*This is so that we can support more backends. (system-wide semaphore
4848
*sets run out pretty fast.) -ay 4/95
4949
*
50-
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.68 2000/02/21 02:42:36 inoue Exp $
50+
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.69 2000/02/22 09:55:20 inoue Exp $
5151
*/
5252
#include<sys/time.h>
5353
#include<unistd.h>
@@ -74,6 +74,7 @@
7474

7575
voidHandleDeadLock(SIGNAL_ARGS);
7676
staticvoidProcFreeAllSemaphores(void);
77+
staticboolGetOffWaitqueue(PROC*);
7778

7879
#defineDeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
7980

@@ -316,9 +317,10 @@ InitProcess(IPCKey key)
316317
* get off the wait queue
317318
* -----------------------
318319
*/
319-
staticvoid
320+
staticbool
320321
GetOffWaitqueue(PROC*proc)
321322
{
323+
boolgetoffed= false;
322324
LockLockTable();
323325
if (proc->links.next!=INVALID_OFFSET)
324326
{
@@ -334,11 +336,12 @@ GetOffWaitqueue(PROC *proc)
334336
if (proc->waitLock->activeHolders[lockmode]==
335337
proc->waitLock->holders[lockmode])
336338
proc->waitLock->waitMask &= ~(1 <<lockmode);
339+
getoffed= true;
337340
}
338341
SHMQueueElemInit(&(proc->links));
339342
UnlockLockTable();
340343

341-
return;
344+
returngetoffed;
342345
}
343346
/*
344347
* ProcReleaseLocks() -- release all locks associated with this process
@@ -478,6 +481,23 @@ ProcQueueInit(PROC_QUEUE *queue)
478481
}
479482

480483

484+
staticboollockWaiting= false;
485+
voidSetWaitingForLock(boolwaiting)
486+
{
487+
lockWaiting=waiting;
488+
}
489+
voidLockWaitCancel(void)
490+
{
491+
structitimervaltimeval,dummy;
492+
493+
if (!lockWaiting)return;
494+
lockWaiting= false;
495+
/* Deadlock timer off */
496+
MemSet(&timeval,0,sizeof(structitimerval));
497+
setitimer(ITIMER_REAL,&timeval,&dummy);
498+
if (GetOffWaitqueue(MyProc))
499+
elog(ERROR,"Query cancel requested while waiting lock");
500+
}
481501

482502
/*
483503
* ProcSleep -- put a process to sleep
@@ -590,7 +610,7 @@ ins:;
590610
timeval.it_value.tv_sec= \
591611
(DeadlockCheckTimer ?DeadlockCheckTimer :DEADLOCK_CHECK_TIMER);
592612

593-
SetLockWaiting(true);
613+
lockWaiting=true;
594614
do
595615
{
596616
MyProc->errType=NO_ERROR;/* reset flag after deadlock check */
@@ -610,7 +630,7 @@ ins:;
610630
IpcExclusiveLock);
611631
}while (MyProc->errType==STATUS_NOT_FOUND);/* sleep after deadlock
612632
* check */
613-
SetLockWaiting(false);
633+
lockWaiting=false;
614634

615635
/* ---------------
616636
* We were awoken before a timeout - now disable the timer
@@ -824,6 +844,7 @@ HandleDeadLock(SIGNAL_ARGS)
824844
* ------------------------
825845
*/
826846
Assert(mywaitlock->waitProcs.size>0);
847+
lockWaiting= false;
827848
--mywaitlock->waitProcs.size;
828849
SHMQueueDelete(&(MyProc->links));
829850
SHMQueueElemInit(&(MyProc->links));

‎src/backend/tcop/postgres.c

Lines changed: 4 additions & 14 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.145 2000/02/21 02:42:35 inoue Exp $
11+
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.146 2000/02/22 09:55:18 inoue Exp $
1212
*
1313
* NOTES
1414
* this is the "main" module of the postgres backend and
@@ -809,22 +809,12 @@ FloatExceptionHandler(SIGNAL_ARGS)
809809
" or was a divide by zero");
810810
}
811811

812-
813-
staticboollockWaiting= false;
814-
voidSetLockWaiting(boolwaiting)
815-
{
816-
lockWaiting=waiting;
817-
}
818812
/* signal handler for query cancel signal from postmaster */
819813
staticvoid
820814
QueryCancelHandler(SIGNAL_ARGS)
821815
{
822816
QueryCancel= true;
823-
if (lockWaiting)
824-
{
825-
lockWaiting= false;
826-
elog(ERROR,"Query Cancel requested while waiting lock");
827-
}
817+
LockWaitCancel();
828818
}
829819

830820
void
@@ -1513,7 +1503,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15131503
if (!IsUnderPostmaster)
15141504
{
15151505
puts("\nPOSTGRES backend interactive interface ");
1516-
puts("$Revision: 1.145 $ $Date: 2000/02/21 02:42:35 $\n");
1506+
puts("$Revision: 1.146 $ $Date: 2000/02/22 09:55:18 $\n");
15171507
}
15181508

15191509
/*
@@ -1573,6 +1563,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15731563
* ----------------
15741564
*/
15751565
QueryCancel= false;/* forget any earlier CANCEL signal */
1566+
SetWaitingForLock(false);
15761567

15771568
EnableNotifyInterrupt();
15781569

@@ -1583,7 +1574,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
15831574
firstchar=ReadCommand(parser_input);
15841575

15851576
QueryCancel= false;/* forget any earlier CANCEL signal */
1586-
lockWaiting= false;
15871577

15881578
/* ----------------
15891579
* (4) disable async.c's signal handler.

‎src/include/miscadmin.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,7 @@
1212
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
1313
* Portions Copyright (c) 1994, Regents of the University of California
1414
*
15-
* $Id: miscadmin.h,v 1.52 2000/02/21 02:42:37 inoue Exp $
15+
* $Id: miscadmin.h,v 1.53 2000/02/22 09:55:20 inoue Exp $
1616
*
1717
* NOTES
1818
* some of the information in this file will be moved to
@@ -214,7 +214,7 @@ extern ProcessingMode Mode;
214214
externvoidIgnoreSystemIndexes(boolmode);
215215
externboolIsIgnoringSystemIndexes(void);
216216
externboolIsCacheInitialized(void);
217-
externvoidSetLockWaiting(bool);
217+
externvoidSetWaitingForLock(bool);
218218

219219
/*
220220
* "postmaster.pid" is a file containing postmaster's pid, being

‎src/include/storage/proc.h

Lines changed: 2 additions & 1 deletion
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.28 2000/01/26 05:58:33 momjian Exp $
10+
* $Id: proc.h,v 1.29 2000/02/22 09:55:26 inoue Exp $
1111
*
1212
*-------------------------------------------------------------------------
1313
*/
@@ -130,5 +130,6 @@ extern int ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod,
130130
LOCK*lock);
131131
externvoidProcAddLock(SHM_QUEUE*elem);
132132
externvoidProcReleaseSpins(PROC*proc);
133+
externvoidLockWaitCancel(void);
133134

134135
#endif/* PROC_H */

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp