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
32cc6cbe
Commit
32cc6cbe
authored
Feb 18, 2003
by
Bruce Momjian
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Rename 'holder' references to 'proclock' for PROCLOCK references, for
consistency.
parent
cf55ee57
Changes
6
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
6 changed files
with
218 additions
and
217 deletions
+218
-217
src/backend/storage/lmgr/deadlock.c
src/backend/storage/lmgr/deadlock.c
+8
-8
src/backend/storage/lmgr/lock.c
src/backend/storage/lmgr/lock.c
+177
-177
src/backend/storage/lmgr/proc.c
src/backend/storage/lmgr/proc.c
+5
-5
src/backend/utils/adt/lockfuncs.c
src/backend/utils/adt/lockfuncs.c
+6
-6
src/include/storage/lock.h
src/include/storage/lock.h
+20
-19
src/include/storage/proc.h
src/include/storage/proc.h
+2
-2
No files found.
src/backend/storage/lmgr/deadlock.c
View file @
32cc6cbe
...
...
@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.1
6 2003/01/16 21:01:44 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.1
7 2003/02/18 02:13:24 momjian
Exp $
*
* Interface:
*
...
...
@@ -425,7 +425,7 @@ FindLockCycleRecurse(PGPROC *checkProc,
{
PGPROC
*
proc
;
LOCK
*
lock
;
PROCLOCK
*
holder
;
PROCLOCK
*
proclock
;
SHM_QUEUE
*
lockHolders
;
LOCKMETHODTABLE
*
lockMethodTable
;
PROC_QUEUE
*
waitQueue
;
...
...
@@ -484,19 +484,19 @@ FindLockCycleRecurse(PGPROC *checkProc,
*/
lockHolders
=
&
(
lock
->
lockHolders
);
holder
=
(
PROCLOCK
*
)
SHMQueueNext
(
lockHolders
,
lockHolders
,
proclock
=
(
PROCLOCK
*
)
SHMQueueNext
(
lockHolders
,
lockHolders
,
offsetof
(
PROCLOCK
,
lockLink
));
while
(
holder
)
while
(
proclock
)
{
proc
=
(
PGPROC
*
)
MAKE_PTR
(
holder
->
tag
.
proc
);
proc
=
(
PGPROC
*
)
MAKE_PTR
(
proclock
->
tag
.
proc
);
/* A proc never blocks itself */
if
(
proc
!=
checkProc
)
{
for
(
lm
=
1
;
lm
<=
numLockModes
;
lm
++
)
{
if
(
holder
->
holding
[
lm
]
>
0
&&
if
(
proclock
->
holding
[
lm
]
>
0
&&
((
1
<<
lm
)
&
conflictMask
)
!=
0
)
{
/* This proc hard-blocks checkProc */
...
...
@@ -512,13 +512,13 @@ FindLockCycleRecurse(PGPROC *checkProc,
return
true
;
}
/* If no deadlock, we're done looking at this
holder
*/
/* If no deadlock, we're done looking at this
proclock
*/
break
;
}
}
}
holder
=
(
PROCLOCK
*
)
SHMQueueNext
(
lockHolders
,
&
holder
->
lockLink
,
proclock
=
(
PROCLOCK
*
)
SHMQueueNext
(
lockHolders
,
&
proclock
->
lockLink
,
offsetof
(
PROCLOCK
,
lockLink
));
}
...
...
src/backend/storage/lmgr/lock.c
View file @
32cc6cbe
This diff is collapsed.
Click to expand it.
src/backend/storage/lmgr/proc.c
View file @
32cc6cbe
...
...
@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.12
8 2003/01/16 21:01:44 tgl
Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.12
9 2003/02/18 02:13:24 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -521,7 +521,7 @@ int
ProcSleep
(
LOCKMETHODTABLE
*
lockMethodTable
,
LOCKMODE
lockmode
,
LOCK
*
lock
,
PROCLOCK
*
holder
)
PROCLOCK
*
proclock
)
{
LWLockId
masterLock
=
lockMethodTable
->
masterLock
;
PROC_QUEUE
*
waitQueue
=
&
(
lock
->
waitProcs
);
...
...
@@ -577,12 +577,12 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable,
LockCheckConflicts
(
lockMethodTable
,
lockmode
,
lock
,
holder
,
proclock
,
MyProc
,
NULL
)
==
STATUS_OK
)
{
/* Skip the wait and just grant myself the lock. */
GrantLock
(
lock
,
holder
,
lockmode
);
GrantLock
(
lock
,
proclock
,
lockmode
);
return
STATUS_OK
;
}
/* Break out of loop to put myself before him */
...
...
@@ -615,7 +615,7 @@ ProcSleep(LOCKMETHODTABLE *lockMethodTable,
/* Set up wait information in PGPROC object, too */
MyProc
->
waitLock
=
lock
;
MyProc
->
waitHolder
=
holder
;
MyProc
->
waitHolder
=
proclock
;
MyProc
->
waitLockMode
=
lockmode
;
MyProc
->
errType
=
STATUS_OK
;
/* initialize result for success */
...
...
src/backend/utils/adt/lockfuncs.c
View file @
32cc6cbe
...
...
@@ -6,7 +6,7 @@
* Copyright (c) 2002, PostgreSQL Global Development Group
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.
7 2002/09/04 20:31:28
momjian Exp $
* $Header: /cvsroot/pgsql/src/backend/utils/adt/lockfuncs.c,v 1.
8 2003/02/18 02:13:24
momjian Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -88,7 +88,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
while
(
mystatus
->
currIdx
<
lockData
->
nelements
)
{
PROCLOCK
*
holder
;
PROCLOCK
*
proclock
;
LOCK
*
lock
;
PGPROC
*
proc
;
bool
granted
;
...
...
@@ -98,7 +98,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
HeapTuple
tuple
;
Datum
result
;
holder
=
&
(
lockData
->
holder
s
[
mystatus
->
currIdx
]);
proclock
=
&
(
lockData
->
proclock
s
[
mystatus
->
currIdx
]);
lock
=
&
(
lockData
->
locks
[
mystatus
->
currIdx
]);
proc
=
&
(
lockData
->
procs
[
mystatus
->
currIdx
]);
...
...
@@ -110,10 +110,10 @@ pg_lock_status(PG_FUNCTION_ARGS)
granted
=
false
;
for
(
mode
=
0
;
mode
<
MAX_LOCKMODES
;
mode
++
)
{
if
(
holder
->
holding
[
mode
]
>
0
)
if
(
proclock
->
holding
[
mode
]
>
0
)
{
granted
=
true
;
holder
->
holding
[
mode
]
=
0
;
proclock
->
holding
[
mode
]
=
0
;
break
;
}
}
...
...
@@ -124,7 +124,7 @@ pg_lock_status(PG_FUNCTION_ARGS)
*/
if
(
!
granted
)
{
if
(
proc
->
waitLock
==
(
LOCK
*
)
MAKE_PTR
(
holder
->
tag
.
lock
))
if
(
proc
->
waitLock
==
(
LOCK
*
)
MAKE_PTR
(
proclock
->
tag
.
lock
))
{
/* Yes, so report it with proper mode */
mode
=
proc
->
waitLockMode
;
...
...
src/include/storage/lock.h
View file @
32cc6cbe
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: lock.h,v 1.6
8 2003/01/16 21:01:45 tgl
Exp $
* $Id: lock.h,v 1.6
9 2003/02/18 02:13:24 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -68,7 +68,7 @@ typedef int LOCKMETHOD;
*
* lockHash -- hash table holding per-locked-object lock information
*
*
holderHash -- hash table holding per-lock-
holder lock information
*
proclockHash -- hash table holding per-lock-waiter/
holder lock information
*
* lockmethod -- the handle used by the lock table's clients to
* refer to the type of lock table being used.
...
...
@@ -86,7 +86,7 @@ typedef int LOCKMETHOD;
typedef
struct
LOCKMETHODTABLE
{
HTAB
*
lockHash
;
HTAB
*
holder
Hash
;
HTAB
*
proclock
Hash
;
LOCKMETHOD
lockmethod
;
int
numLockModes
;
int
conflictTab
[
MAX_LOCKMODES
];
...
...
@@ -156,24 +156,25 @@ typedef struct LOCK
/*
* We may have several different transactions holding or awaiting locks
* on the same lockable object. We need to store some per-
holder information
* for each such holder (or would-be holder).
* on the same lockable object. We need to store some per-
waiter/holder
*
information
for each such holder (or would-be holder).
*
* PROCLOCKTAG is the key information needed to look up a PROCLOCK item in the
* holder hashtable. A PROCLOCKTAG value uniquely identifies a lock holder.
* proclock hashtable. A PROCLOCKTAG value uniquely identifies a lock
* holder/waiter.
*
* There are two possible kinds of
holder
tags: a transaction (identified
* There are two possible kinds of
proclock
tags: a transaction (identified
* both by the PGPROC of the backend running it, and the xact's own ID) and
* a session (identified by backend PGPROC, with xid = InvalidTransactionId).
*
* Currently, session
holder
s are used for user locks and for cross-xact
* Currently, session
proclock
s are used for user locks and for cross-xact
* locks obtained for VACUUM. We assume that a session lock never conflicts
* with per-transaction locks obtained by the same backend.
*
* The holding[] array counts the granted locks (of each type) represented
* by this
holder. Note that there will be a holder
object, possibly with
* by this
proclock. Note that there will be a proclock
object, possibly with
* zero holding[], for any lock that the process is currently waiting on.
* Otherwise,
holder
objects whose counts have gone to zero are recycled
* Otherwise,
proclock
objects whose counts have gone to zero are recycled
* as soon as convenient.
*
* Each PROCLOCK object is linked into lists for both the associated LOCK object
...
...
@@ -192,17 +193,17 @@ typedef struct PROCLOCKTAG
typedef
struct
PROCLOCK
{
/* tag */
PROCLOCKTAG
tag
;
/* unique identifier of
holder
object */
PROCLOCKTAG
tag
;
/* unique identifier of
proclock
object */
/* data */
int
holding
[
MAX_LOCKMODES
];
/* count of locks currently held */
int
nHolding
;
/* total of holding[] array */
SHM_QUEUE
lockLink
;
/* list link for lock's list of
holder
s */
SHM_QUEUE
procLink
;
/* list link for process's list of
holder
s */
SHM_QUEUE
lockLink
;
/* list link for lock's list of
proclock
s */
SHM_QUEUE
procLink
;
/* list link for process's list of
proclock
s */
}
PROCLOCK
;
#define PROCLOCK_LOCKMETHOD(
holder
) \
(((LOCK *) MAKE_PTR((
holder
).tag.lock))->tag.lockmethod)
#define PROCLOCK_LOCKMETHOD(
proclock
) \
(((LOCK *) MAKE_PTR((
proclock
).tag.lock))->tag.lockmethod)
/*
* This struct holds information passed from lmgr internals to the lock
...
...
@@ -215,8 +216,8 @@ typedef struct PROCLOCK
typedef
struct
{
int
nelements
;
/* The length of each of the arrays */
SHMEM_OFFSET
*
holder
addrs
;
PROCLOCK
*
holder
s
;
SHMEM_OFFSET
*
proclock
addrs
;
PROCLOCK
*
proclock
s
;
PGPROC
*
procs
;
LOCK
*
locks
;
}
LockData
;
...
...
@@ -237,9 +238,9 @@ extern bool LockReleaseAll(LOCKMETHOD lockmethod, PGPROC *proc,
bool
allxids
,
TransactionId
xid
);
extern
int
LockCheckConflicts
(
LOCKMETHODTABLE
*
lockMethodTable
,
LOCKMODE
lockmode
,
LOCK
*
lock
,
PROCLOCK
*
holder
,
PGPROC
*
proc
,
LOCK
*
lock
,
PROCLOCK
*
proclock
,
PGPROC
*
proc
,
int
*
myHolding
);
extern
void
GrantLock
(
LOCK
*
lock
,
PROCLOCK
*
holder
,
LOCKMODE
lockmode
);
extern
void
GrantLock
(
LOCK
*
lock
,
PROCLOCK
*
proclock
,
LOCKMODE
lockmode
);
extern
void
RemoveFromWaitQueue
(
PGPROC
*
proc
);
extern
int
LockShmemSize
(
int
maxBackends
);
extern
bool
DeadLockCheck
(
PGPROC
*
proc
);
...
...
src/include/storage/proc.h
View file @
32cc6cbe
...
...
@@ -7,7 +7,7 @@
* Portions Copyright (c) 1996-2002, PostgreSQL Global Development Group
* Portions Copyright (c) 1994, Regents of the University of California
*
* $Id: proc.h,v 1.6
2 2002/10/31 21:34:17 tgl
Exp $
* $Id: proc.h,v 1.6
3 2003/02/18 02:13:24 momjian
Exp $
*
*-------------------------------------------------------------------------
*/
...
...
@@ -102,7 +102,7 @@ extern void ProcReleaseLocks(bool isCommit);
extern
void
ProcQueueInit
(
PROC_QUEUE
*
queue
);
extern
int
ProcSleep
(
LOCKMETHODTABLE
*
lockMethodTable
,
LOCKMODE
lockmode
,
LOCK
*
lock
,
PROCLOCK
*
holder
);
LOCK
*
lock
,
PROCLOCK
*
proclock
);
extern
PGPROC
*
ProcWakeup
(
PGPROC
*
proc
,
int
errType
);
extern
void
ProcLockWakeup
(
LOCKMETHODTABLE
*
lockMethodTable
,
LOCK
*
lock
);
extern
bool
LockWaitCancel
(
void
);
...
...
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