Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
Postgres FD Implementation
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Abuhujair Javed
Postgres FD Implementation
Commits
55252974
Commit
55252974
authored
Feb 22, 2000
by
Hiroshi Inoue
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Change cancel while waiting-for-lock stuff.
parent
167dce89
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
37 additions
and
24 deletions
+37
-24
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/lock.c
+2
-1
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+27
-6
src/backend/tcop/postgres.c
src/backend/tcop/postgres.c
+4
-14
src/include/miscadmin.h
src/include/miscadmin.h
+2
-2
src/include/storage/proc.h
src/include/storage/proc.h
+2
-1
No files found.
src/backend/storage/lmgr/lock.c
View file @
55252974
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.6
5 2000/01/26 05:57:01 momjian
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.6
6 2000/02/22 09:55:20 inoue
Exp $
*
*
* NOTES
* NOTES
* Outside modules can create a lock table and acquire/release
* Outside modules can create a lock table and acquire/release
...
@@ -1743,6 +1743,7 @@ DeadLockCheck(void *proc, LOCK *findlock)
...
@@ -1743,6 +1743,7 @@ DeadLockCheck(void *proc, LOCK *findlock)
MyProc
->
xid
,
MyProc
->
xid
,
NULL
)
==
STATUS_OK
)
NULL
)
==
STATUS_OK
)
{
{
SetWaitingForLock
(
false
);
GrantLock
(
MyProc
->
waitLock
,
MyProc
->
token
);
GrantLock
(
MyProc
->
waitLock
,
MyProc
->
token
);
(
MyProc
->
waitLock
->
waitProcs
.
size
)
--
;
(
MyProc
->
waitLock
->
waitProcs
.
size
)
--
;
ProcWakeup
(
MyProc
,
NO_ERROR
);
ProcWakeup
(
MyProc
,
NO_ERROR
);
...
...
src/backend/storage/lmgr/proc.c
View file @
55252974
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.6
8 2000/02/21 02:42:36
inoue Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.6
9 2000/02/22 09:55:20
inoue Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -47,7 +47,7 @@
...
@@ -47,7 +47,7 @@
* This is so that we can support more backends. (system-wide semaphore
* This is so that we can support more backends. (system-wide semaphore
* sets run out pretty fast.) -ay 4/95
* sets run out pretty fast.) -ay 4/95
*
*
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.6
8 2000/02/21 02:42:36
inoue Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.6
9 2000/02/22 09:55:20
inoue Exp $
*/
*/
#include <sys/time.h>
#include <sys/time.h>
#include <unistd.h>
#include <unistd.h>
...
@@ -74,6 +74,7 @@
...
@@ -74,6 +74,7 @@
void
HandleDeadLock
(
SIGNAL_ARGS
);
void
HandleDeadLock
(
SIGNAL_ARGS
);
static
void
ProcFreeAllSemaphores
(
void
);
static
void
ProcFreeAllSemaphores
(
void
);
static
bool
GetOffWaitqueue
(
PROC
*
);
#define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
#define DeadlockCheckTimer pg_options[OPT_DEADLOCKTIMEOUT]
...
@@ -316,9 +317,10 @@ InitProcess(IPCKey key)
...
@@ -316,9 +317,10 @@ InitProcess(IPCKey key)
* get off the wait queue
* get off the wait queue
* -----------------------
* -----------------------
*/
*/
static
void
static
bool
GetOffWaitqueue
(
PROC
*
proc
)
GetOffWaitqueue
(
PROC
*
proc
)
{
{
bool
getoffed
=
false
;
LockLockTable
();
LockLockTable
();
if
(
proc
->
links
.
next
!=
INVALID_OFFSET
)
if
(
proc
->
links
.
next
!=
INVALID_OFFSET
)
{
{
...
@@ -334,11 +336,12 @@ GetOffWaitqueue(PROC *proc)
...
@@ -334,11 +336,12 @@ GetOffWaitqueue(PROC *proc)
if
(
proc
->
waitLock
->
activeHolders
[
lockmode
]
==
if
(
proc
->
waitLock
->
activeHolders
[
lockmode
]
==
proc
->
waitLock
->
holders
[
lockmode
])
proc
->
waitLock
->
holders
[
lockmode
])
proc
->
waitLock
->
waitMask
&=
~
(
1
<<
lockmode
);
proc
->
waitLock
->
waitMask
&=
~
(
1
<<
lockmode
);
getoffed
=
true
;
}
}
SHMQueueElemInit
(
&
(
proc
->
links
));
SHMQueueElemInit
(
&
(
proc
->
links
));
UnlockLockTable
();
UnlockLockTable
();
return
;
return
getoffed
;
}
}
/*
/*
* ProcReleaseLocks() -- release all locks associated with this process
* ProcReleaseLocks() -- release all locks associated with this process
...
@@ -478,6 +481,23 @@ ProcQueueInit(PROC_QUEUE *queue)
...
@@ -478,6 +481,23 @@ ProcQueueInit(PROC_QUEUE *queue)
}
}
static
bool
lockWaiting
=
false
;
void
SetWaitingForLock
(
bool
waiting
)
{
lockWaiting
=
waiting
;
}
void
LockWaitCancel
(
void
)
{
struct
itimerval
timeval
,
dummy
;
if
(
!
lockWaiting
)
return
;
lockWaiting
=
false
;
/* Deadlock timer off */
MemSet
(
&
timeval
,
0
,
sizeof
(
struct
itimerval
));
setitimer
(
ITIMER_REAL
,
&
timeval
,
&
dummy
);
if
(
GetOffWaitqueue
(
MyProc
))
elog
(
ERROR
,
"Query cancel requested while waiting lock"
);
}
/*
/*
* ProcSleep -- put a process to sleep
* ProcSleep -- put a process to sleep
...
@@ -590,7 +610,7 @@ ins:;
...
@@ -590,7 +610,7 @@ ins:;
timeval
.
it_value
.
tv_sec
=
\
timeval
.
it_value
.
tv_sec
=
\
(
DeadlockCheckTimer
?
DeadlockCheckTimer
:
DEADLOCK_CHECK_TIMER
);
(
DeadlockCheckTimer
?
DeadlockCheckTimer
:
DEADLOCK_CHECK_TIMER
);
SetLockWaiting
(
true
)
;
lockWaiting
=
true
;
do
do
{
{
MyProc
->
errType
=
NO_ERROR
;
/* reset flag after deadlock check */
MyProc
->
errType
=
NO_ERROR
;
/* reset flag after deadlock check */
...
@@ -610,7 +630,7 @@ ins:;
...
@@ -610,7 +630,7 @@ ins:;
IpcExclusiveLock
);
IpcExclusiveLock
);
}
while
(
MyProc
->
errType
==
STATUS_NOT_FOUND
);
/* sleep after deadlock
}
while
(
MyProc
->
errType
==
STATUS_NOT_FOUND
);
/* sleep after deadlock
* check */
* check */
SetLockWaiting
(
false
)
;
lockWaiting
=
false
;
/* ---------------
/* ---------------
* We were awoken before a timeout - now disable the timer
* We were awoken before a timeout - now disable the timer
...
@@ -824,6 +844,7 @@ HandleDeadLock(SIGNAL_ARGS)
...
@@ -824,6 +844,7 @@ HandleDeadLock(SIGNAL_ARGS)
* ------------------------
* ------------------------
*/
*/
Assert
(
mywaitlock
->
waitProcs
.
size
>
0
);
Assert
(
mywaitlock
->
waitProcs
.
size
>
0
);
lockWaiting
=
false
;
--
mywaitlock
->
waitProcs
.
size
;
--
mywaitlock
->
waitProcs
.
size
;
SHMQueueDelete
(
&
(
MyProc
->
links
));
SHMQueueDelete
(
&
(
MyProc
->
links
));
SHMQueueElemInit
(
&
(
MyProc
->
links
));
SHMQueueElemInit
(
&
(
MyProc
->
links
));
...
...
src/backend/tcop/postgres.c
View file @
55252974
...
@@ -8,7 +8,7 @@
...
@@ -8,7 +8,7 @@
*
*
*
*
* IDENTIFICATION
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.14
5 2000/02/21 02:42:35
inoue Exp $
* $Header: /cvsroot/pgsql/src/backend/tcop/postgres.c,v 1.14
6 2000/02/22 09:55:18
inoue Exp $
*
*
* NOTES
* NOTES
* this is the "main" module of the postgres backend and
* this is the "main" module of the postgres backend and
...
@@ -809,22 +809,12 @@ FloatExceptionHandler(SIGNAL_ARGS)
...
@@ -809,22 +809,12 @@ FloatExceptionHandler(SIGNAL_ARGS)
" or was a divide by zero"
);
" or was a divide by zero"
);
}
}
static
bool
lockWaiting
=
false
;
void
SetLockWaiting
(
bool
waiting
)
{
lockWaiting
=
waiting
;
}
/* signal handler for query cancel signal from postmaster */
/* signal handler for query cancel signal from postmaster */
static
void
static
void
QueryCancelHandler
(
SIGNAL_ARGS
)
QueryCancelHandler
(
SIGNAL_ARGS
)
{
{
QueryCancel
=
true
;
QueryCancel
=
true
;
if
(
lockWaiting
)
LockWaitCancel
();
{
lockWaiting
=
false
;
elog
(
ERROR
,
"Query Cancel requested while waiting lock"
);
}
}
}
void
void
...
@@ -1513,7 +1503,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
...
@@ -1513,7 +1503,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
if
(
!
IsUnderPostmaster
)
if
(
!
IsUnderPostmaster
)
{
{
puts
(
"
\n
POSTGRES backend interactive interface "
);
puts
(
"
\n
POSTGRES backend interactive interface "
);
puts
(
"$Revision: 1.14
5 $ $Date: 2000/02/21 02:42:35
$
\n
"
);
puts
(
"$Revision: 1.14
6 $ $Date: 2000/02/22 09:55:18
$
\n
"
);
}
}
/*
/*
...
@@ -1573,6 +1563,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
...
@@ -1573,6 +1563,7 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
* ----------------
* ----------------
*/
*/
QueryCancel
=
false
;
/* forget any earlier CANCEL signal */
QueryCancel
=
false
;
/* forget any earlier CANCEL signal */
SetWaitingForLock
(
false
);
EnableNotifyInterrupt
();
EnableNotifyInterrupt
();
...
@@ -1583,7 +1574,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
...
@@ -1583,7 +1574,6 @@ PostgresMain(int argc, char *argv[], int real_argc, char *real_argv[])
firstchar
=
ReadCommand
(
parser_input
);
firstchar
=
ReadCommand
(
parser_input
);
QueryCancel
=
false
;
/* forget any earlier CANCEL signal */
QueryCancel
=
false
;
/* forget any earlier CANCEL signal */
lockWaiting
=
false
;
/* ----------------
/* ----------------
* (4) disable async.c's signal handler.
* (4) disable async.c's signal handler.
...
...
src/include/miscadmin.h
View file @
55252974
...
@@ -12,7 +12,7 @@
...
@@ -12,7 +12,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: miscadmin.h,v 1.5
2 2000/02/21 02:42:37
inoue Exp $
* $Id: miscadmin.h,v 1.5
3 2000/02/22 09:55:20
inoue Exp $
*
*
* NOTES
* NOTES
* some of the information in this file will be moved to
* some of the information in this file will be moved to
...
@@ -214,7 +214,7 @@ extern ProcessingMode Mode;
...
@@ -214,7 +214,7 @@ extern ProcessingMode Mode;
extern
void
IgnoreSystemIndexes
(
bool
mode
);
extern
void
IgnoreSystemIndexes
(
bool
mode
);
extern
bool
IsIgnoringSystemIndexes
(
void
);
extern
bool
IsIgnoringSystemIndexes
(
void
);
extern
bool
IsCacheInitialized
(
void
);
extern
bool
IsCacheInitialized
(
void
);
extern
void
Set
LockWaiting
(
bool
);
extern
void
Set
WaitingForLock
(
bool
);
/*
/*
* "postmaster.pid" is a file containing postmaster's pid, being
* "postmaster.pid" is a file containing postmaster's pid, being
...
...
src/include/storage/proc.h
View file @
55252974
...
@@ -7,7 +7,7 @@
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1996-2000, PostgreSQL, Inc
* Portions Copyright (c) 1994, Regents of the University of California
* Portions Copyright (c) 1994, Regents of the University of California
*
*
* $Id: proc.h,v 1.2
8 2000/01/26 05:58:33 momjian
Exp $
* $Id: proc.h,v 1.2
9 2000/02/22 09:55:26 inoue
Exp $
*
*
*-------------------------------------------------------------------------
*-------------------------------------------------------------------------
*/
*/
...
@@ -130,5 +130,6 @@ extern int ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod,
...
@@ -130,5 +130,6 @@ extern int ProcLockWakeup(PROC_QUEUE *queue, LOCKMETHOD lockmethod,
LOCK
*
lock
);
LOCK
*
lock
);
extern
void
ProcAddLock
(
SHM_QUEUE
*
elem
);
extern
void
ProcAddLock
(
SHM_QUEUE
*
elem
);
extern
void
ProcReleaseSpins
(
PROC
*
proc
);
extern
void
ProcReleaseSpins
(
PROC
*
proc
);
extern
void
LockWaitCancel
(
void
);
#endif
/* PROC_H */
#endif
/* PROC_H */
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment