1
0
mirror of https://github.com/postgres/postgres.git synced 2025-09-08 00:47:37 +03:00

Do this TODO item:

* HOLDER/HOLDERTAB rename to PROCLOCK/PROCLOCKTAG (Tom)

Didn't use PROCLOCKLINK because it made PROCLOCKLINKTAG too long.
This commit is contained in:
Bruce Momjian
2001-09-29 21:35:14 +00:00
parent 8ca61476e0
commit f738747494
5 changed files with 92 additions and 92 deletions

View File

@@ -12,7 +12,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.4 2001/09/29 04:02:24 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/deadlock.c,v 1.5 2001/09/29 21:35:14 momjian Exp $
*
* Interface:
*
@@ -382,7 +382,7 @@ FindLockCycleRecurse(PROC *checkProc,
{
PROC *proc;
LOCK *lock;
HOLDER *holder;
PROCLOCK *holder;
SHM_QUEUE *lockHolders;
LOCKMETHODTABLE *lockMethodTable;
LOCKMETHODCTL *lockctl;
@@ -434,8 +434,8 @@ FindLockCycleRecurse(PROC *checkProc,
*/
lockHolders = &(lock->lockHolders);
holder = (HOLDER *) SHMQueueNext(lockHolders, lockHolders,
offsetof(HOLDER, lockLink));
holder = (PROCLOCK *) SHMQueueNext(lockHolders, lockHolders,
offsetof(PROCLOCK, lockLink));
while (holder)
{
@@ -458,8 +458,8 @@ FindLockCycleRecurse(PROC *checkProc,
}
}
holder = (HOLDER *) SHMQueueNext(lockHolders, &holder->lockLink,
offsetof(HOLDER, lockLink));
holder = (PROCLOCK *) SHMQueueNext(lockHolders, &holder->lockLink,
offsetof(PROCLOCK, lockLink));
}
/*

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.96 2001/09/29 04:02:24 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/lock.c,v 1.97 2001/09/29 21:35:14 momjian Exp $
*
* NOTES
* Outside modules can create a lock table and acquire/release
@@ -48,7 +48,7 @@ int max_locks_per_xact; /* set by guc.c */
static int WaitOnLock(LOCKMETHOD lockmethod, LOCKMODE lockmode,
LOCK *lock, HOLDER *holder);
LOCK *lock, PROCLOCK *holder);
static void LockCountMyLocks(SHMEM_OFFSET lockOffset, PROC *proc,
int *myHolding);
@@ -125,18 +125,18 @@ LOCK_PRINT(const char *where, const LOCK *lock, LOCKMODE type)
inline static void
HOLDER_PRINT(const char *where, const HOLDER *holderP)
PROCLOCK_PRINT(const char *where, const PROCLOCK *holderP)
{
if (
(((HOLDER_LOCKMETHOD(*holderP) == DEFAULT_LOCKMETHOD && Trace_locks)
|| (HOLDER_LOCKMETHOD(*holderP) == USER_LOCKMETHOD && Trace_userlocks))
(((PROCLOCK_LOCKMETHOD(*holderP) == DEFAULT_LOCKMETHOD && Trace_locks)
|| (PROCLOCK_LOCKMETHOD(*holderP) == USER_LOCKMETHOD && Trace_userlocks))
&& (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId >= (Oid) Trace_lock_oidmin))
|| (Trace_lock_table && (((LOCK *) MAKE_PTR(holderP->tag.lock))->tag.relId == Trace_lock_table))
)
elog(DEBUG,
"%s: holder(%lx) lock(%lx) tbl(%d) proc(%lx) xid(%u) hold(%d,%d,%d,%d,%d,%d,%d)=%d",
where, MAKE_OFFSET(holderP), holderP->tag.lock,
HOLDER_LOCKMETHOD(*(holderP)),
PROCLOCK_LOCKMETHOD(*(holderP)),
holderP->tag.proc, holderP->tag.xid,
holderP->holding[1], holderP->holding[2], holderP->holding[3],
holderP->holding[4], holderP->holding[5], holderP->holding[6],
@@ -146,7 +146,7 @@ HOLDER_PRINT(const char *where, const HOLDER *holderP)
#else /* not LOCK_DEBUG */
#define LOCK_PRINT(where, lock, type)
#define HOLDER_PRINT(where, holderP)
#define PROCLOCK_PRINT(where, holderP)
#endif /* not LOCK_DEBUG */
@@ -325,11 +325,11 @@ LockMethodTableInit(char *tabName,
Assert(lockMethodTable->lockHash->hash == tag_hash);
/*
* allocate a hash table for HOLDER structs. This is used to store
* allocate a hash table for PROCLOCK structs. This is used to store
* per-lock-holder information.
*/
info.keysize = SHMEM_HOLDERTAB_KEYSIZE;
info.datasize = SHMEM_HOLDERTAB_DATASIZE;
info.keysize = SHMEM_PROCLOCKTAB_KEYSIZE;
info.datasize = SHMEM_PROCLOCKTAB_DATASIZE;
info.hash = tag_hash;
hash_flags = (HASH_ELEM | HASH_FUNCTION);
@@ -449,8 +449,8 @@ bool
LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
TransactionId xid, LOCKMODE lockmode, bool dontWait)
{
HOLDER *holder;
HOLDERTAG holdertag;
PROCLOCK *holder;
PROCLOCKTAG holdertag;
HTAB *holderTable;
bool found;
LOCK *lock;
@@ -520,7 +520,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
/*
* Create the hash key for the holder table.
*/
MemSet(&holdertag, 0, sizeof(HOLDERTAG)); /* must clear padding,
MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding,
* needed */
holdertag.lock = MAKE_OFFSET(lock);
holdertag.proc = MAKE_OFFSET(MyProc);
@@ -530,7 +530,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
* Find or create a holder entry with this tag
*/
holderTable = lockMethodTable->holderHash;
holder = (HOLDER *) hash_search(holderTable, (Pointer) &holdertag,
holder = (PROCLOCK *) hash_search(holderTable, (Pointer) &holdertag,
HASH_ENTER, &found);
if (!holder)
{
@@ -549,11 +549,11 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
/* Add holder to appropriate lists */
SHMQueueInsertBefore(&lock->lockHolders, &holder->lockLink);
SHMQueueInsertBefore(&MyProc->procHolders, &holder->procLink);
HOLDER_PRINT("LockAcquire: new", holder);
PROCLOCK_PRINT("LockAcquire: new", holder);
}
else
{
HOLDER_PRINT("LockAcquire: found", holder);
PROCLOCK_PRINT("LockAcquire: found", holder);
Assert((holder->nHolding >= 0) && (holder->holding[lockmode] >= 0));
Assert(holder->nHolding <= lock->nGranted);
@@ -606,7 +606,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
if (holder->holding[lockmode] > 0)
{
GrantLock(lock, holder, lockmode);
HOLDER_PRINT("LockAcquire: owning", holder);
PROCLOCK_PRINT("LockAcquire: owning", holder);
LWLockRelease(masterLock);
return TRUE;
}
@@ -619,7 +619,7 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
if (myHolding[lockmode] > 0)
{
GrantLock(lock, holder, lockmode);
HOLDER_PRINT("LockAcquire: my other XID owning", holder);
PROCLOCK_PRINT("LockAcquire: my other XID owning", holder);
LWLockRelease(masterLock);
return TRUE;
}
@@ -654,14 +654,14 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
{
SHMQueueDelete(&holder->lockLink);
SHMQueueDelete(&holder->procLink);
holder = (HOLDER *) hash_search(holderTable,
holder = (PROCLOCK *) hash_search(holderTable,
(Pointer) holder,
HASH_REMOVE, &found);
if (!holder || !found)
elog(NOTICE, "LockAcquire: remove holder, table corrupted");
}
else
HOLDER_PRINT("LockAcquire: NHOLDING", holder);
PROCLOCK_PRINT("LockAcquire: NHOLDING", holder);
lock->nRequested--;
lock->requested[lockmode]--;
LOCK_PRINT("LockAcquire: conditional lock failed", lock, lockmode);
@@ -706,13 +706,13 @@ LockAcquire(LOCKMETHOD lockmethod, LOCKTAG *locktag,
*/
if (!((holder->nHolding > 0) && (holder->holding[lockmode] > 0)))
{
HOLDER_PRINT("LockAcquire: INCONSISTENT", holder);
PROCLOCK_PRINT("LockAcquire: INCONSISTENT", holder);
LOCK_PRINT("LockAcquire: INCONSISTENT", lock, lockmode);
/* Should we retry ? */
LWLockRelease(masterLock);
return FALSE;
}
HOLDER_PRINT("LockAcquire: granted", holder);
PROCLOCK_PRINT("LockAcquire: granted", holder);
LOCK_PRINT("LockAcquire: granted", lock, lockmode);
}
@@ -741,7 +741,7 @@ int
LockCheckConflicts(LOCKMETHODTABLE *lockMethodTable,
LOCKMODE lockmode,
LOCK *lock,
HOLDER *holder,
PROCLOCK *holder,
PROC *proc,
int *myHolding) /* myHolding[] array or NULL */
{
@@ -763,7 +763,7 @@ LockCheckConflicts(LOCKMETHODTABLE *lockMethodTable,
*/
if (!(lockctl->conflictTab[lockmode] & lock->grantMask))
{
HOLDER_PRINT("LockCheckConflicts: no conflict", holder);
PROCLOCK_PRINT("LockCheckConflicts: no conflict", holder);
return STATUS_OK;
}
@@ -797,11 +797,11 @@ LockCheckConflicts(LOCKMETHODTABLE *lockMethodTable,
if (!(lockctl->conflictTab[lockmode] & bitmask))
{
/* no conflict. OK to get the lock */
HOLDER_PRINT("LockCheckConflicts: resolved", holder);
PROCLOCK_PRINT("LockCheckConflicts: resolved", holder);
return STATUS_OK;
}
HOLDER_PRINT("LockCheckConflicts: conflicting", holder);
PROCLOCK_PRINT("LockCheckConflicts: conflicting", holder);
return STATUS_FOUND;
}
@@ -819,13 +819,13 @@ static void
LockCountMyLocks(SHMEM_OFFSET lockOffset, PROC *proc, int *myHolding)
{
SHM_QUEUE *procHolders = &(proc->procHolders);
HOLDER *holder;
PROCLOCK *holder;
int i;
MemSet(myHolding, 0, MAX_LOCKMODES * sizeof(int));
holder = (HOLDER *) SHMQueueNext(procHolders, procHolders,
offsetof(HOLDER, procLink));
holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders,
offsetof(PROCLOCK, procLink));
while (holder)
{
@@ -835,8 +835,8 @@ LockCountMyLocks(SHMEM_OFFSET lockOffset, PROC *proc, int *myHolding)
myHolding[i] += holder->holding[i];
}
holder = (HOLDER *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(HOLDER, procLink));
holder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(PROCLOCK, procLink));
}
}
@@ -848,7 +848,7 @@ LockCountMyLocks(SHMEM_OFFSET lockOffset, PROC *proc, int *myHolding)
* and have its waitLock/waitHolder fields cleared. That's not done here.
*/
void
GrantLock(LOCK *lock, HOLDER *holder, LOCKMODE lockmode)
GrantLock(LOCK *lock, PROCLOCK *holder, LOCKMODE lockmode)
{
lock->nGranted++;
lock->granted[lockmode]++;
@@ -873,7 +873,7 @@ GrantLock(LOCK *lock, HOLDER *holder, LOCKMODE lockmode)
*/
static int
WaitOnLock(LOCKMETHOD lockmethod, LOCKMODE lockmode,
LOCK *lock, HOLDER *holder)
LOCK *lock, PROCLOCK *holder)
{
LOCKMETHODTABLE *lockMethodTable = LockMethodTable[lockmethod];
char *new_status,
@@ -991,8 +991,8 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
LWLockId masterLock;
bool found;
LOCKMETHODTABLE *lockMethodTable;
HOLDER *holder;
HOLDERTAG holdertag;
PROCLOCK *holder;
PROCLOCKTAG holdertag;
HTAB *holderTable;
bool wakeupNeeded = false;
@@ -1044,14 +1044,14 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
/*
* Find the holder entry for this holder.
*/
MemSet(&holdertag, 0, sizeof(HOLDERTAG)); /* must clear padding,
MemSet(&holdertag, 0, sizeof(PROCLOCKTAG)); /* must clear padding,
* needed */
holdertag.lock = MAKE_OFFSET(lock);
holdertag.proc = MAKE_OFFSET(MyProc);
TransactionIdStore(xid, &holdertag.xid);
holderTable = lockMethodTable->holderHash;
holder = (HOLDER *) hash_search(holderTable, (Pointer) &holdertag,
holder = (PROCLOCK *) hash_search(holderTable, (Pointer) &holdertag,
HASH_FIND_SAVE, &found);
if (!holder || !found)
{
@@ -1064,7 +1064,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
elog(NOTICE, "LockRelease: holder table corrupted");
return FALSE;
}
HOLDER_PRINT("LockRelease: found", holder);
PROCLOCK_PRINT("LockRelease: found", holder);
/*
* Check that we are actually holding a lock of the type we want to
@@ -1072,7 +1072,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
*/
if (!(holder->holding[lockmode] > 0))
{
HOLDER_PRINT("LockRelease: WRONGTYPE", holder);
PROCLOCK_PRINT("LockRelease: WRONGTYPE", holder);
Assert(holder->holding[lockmode] >= 0);
LWLockRelease(masterLock);
elog(NOTICE, "LockRelease: you don't own a lock of type %s",
@@ -1141,7 +1141,7 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
*/
holder->holding[lockmode]--;
holder->nHolding--;
HOLDER_PRINT("LockRelease: updated", holder);
PROCLOCK_PRINT("LockRelease: updated", holder);
Assert((holder->nHolding >= 0) && (holder->holding[lockmode] >= 0));
/*
@@ -1150,10 +1150,10 @@ LockRelease(LOCKMETHOD lockmethod, LOCKTAG *locktag,
*/
if (holder->nHolding == 0)
{
HOLDER_PRINT("LockRelease: deleting", holder);
PROCLOCK_PRINT("LockRelease: deleting", holder);
SHMQueueDelete(&holder->lockLink);
SHMQueueDelete(&holder->procLink);
holder = (HOLDER *) hash_search(holderTable, (Pointer) &holder,
holder = (PROCLOCK *) hash_search(holderTable, (Pointer) &holder,
HASH_REMOVE_SAVED, &found);
if (!holder || !found)
{
@@ -1189,8 +1189,8 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
bool allxids, TransactionId xid)
{
SHM_QUEUE *procHolders = &(proc->procHolders);
HOLDER *holder;
HOLDER *nextHolder;
PROCLOCK *holder;
PROCLOCK *nextHolder;
LWLockId masterLock;
LOCKMETHODTABLE *lockMethodTable;
int i,
@@ -1217,16 +1217,16 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
LWLockAcquire(masterLock, LW_EXCLUSIVE);
holder = (HOLDER *) SHMQueueNext(procHolders, procHolders,
offsetof(HOLDER, procLink));
holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders,
offsetof(PROCLOCK, procLink));
while (holder)
{
bool wakeupNeeded = false;
/* Get link first, since we may unlink/delete this holder */
nextHolder = (HOLDER *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(HOLDER, procLink));
nextHolder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(PROCLOCK, procLink));
Assert(holder->tag.proc == MAKE_OFFSET(proc));
@@ -1240,7 +1240,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
if (!allxids && !TransactionIdEquals(xid, holder->tag.xid))
goto next_item;
HOLDER_PRINT("LockReleaseAll", holder);
PROCLOCK_PRINT("LockReleaseAll", holder);
LOCK_PRINT("LockReleaseAll", lock, 0);
Assert(lock->nRequested >= 0);
Assert(lock->nGranted >= 0);
@@ -1294,7 +1294,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
}
LOCK_PRINT("LockReleaseAll: updated", lock, 0);
HOLDER_PRINT("LockReleaseAll: deleting", holder);
PROCLOCK_PRINT("LockReleaseAll: deleting", holder);
/*
* Remove the holder entry from the linked lists
@@ -1305,7 +1305,7 @@ LockReleaseAll(LOCKMETHOD lockmethod, PROC *proc,
/*
* remove the holder entry from the hashtable
*/
holder = (HOLDER *) hash_search(lockMethodTable->holderHash,
holder = (PROCLOCK *) hash_search(lockMethodTable->holderHash,
(Pointer) holder,
HASH_REMOVE,
&found);
@@ -1370,8 +1370,8 @@ LockShmemSize(int maxBackends)
/* holderHash table */
size += hash_estimate_size(max_table_size,
SHMEM_HOLDERTAB_KEYSIZE,
SHMEM_HOLDERTAB_DATASIZE);
SHMEM_PROCLOCKTAB_KEYSIZE,
SHMEM_PROCLOCKTAB_DATASIZE);
/*
* Since the lockHash entry count above is only an estimate, add 10%
@@ -1394,7 +1394,7 @@ DumpLocks(void)
{
PROC *proc;
SHM_QUEUE *procHolders;
HOLDER *holder;
PROCLOCK *holder;
LOCK *lock;
int lockmethod = DEFAULT_LOCKMETHOD;
LOCKMETHODTABLE *lockMethodTable;
@@ -1413,8 +1413,8 @@ DumpLocks(void)
if (proc->waitLock)
LOCK_PRINT("DumpLocks: waiting on", proc->waitLock, 0);
holder = (HOLDER *) SHMQueueNext(procHolders, procHolders,
offsetof(HOLDER, procLink));
holder = (PROCLOCK *) SHMQueueNext(procHolders, procHolders,
offsetof(PROCLOCK, procLink));
while (holder)
{
@@ -1422,11 +1422,11 @@ DumpLocks(void)
lock = (LOCK *) MAKE_PTR(holder->tag.lock);
HOLDER_PRINT("DumpLocks", holder);
PROCLOCK_PRINT("DumpLocks", holder);
LOCK_PRINT("DumpLocks", lock, 0);
holder = (HOLDER *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(HOLDER, procLink));
holder = (PROCLOCK *) SHMQueueNext(procHolders, &holder->procLink,
offsetof(PROCLOCK, procLink));
}
}
@@ -1437,7 +1437,7 @@ void
DumpAllLocks(void)
{
PROC *proc;
HOLDER *holder = NULL;
PROCLOCK *holder = NULL;
LOCK *lock;
int lockmethod = DEFAULT_LOCKMETHOD;
LOCKMETHODTABLE *lockMethodTable;
@@ -1459,10 +1459,10 @@ DumpAllLocks(void)
LOCK_PRINT("DumpAllLocks: waiting on", proc->waitLock, 0);
hash_seq_init(&status, holderTable);
while ((holder = (HOLDER *) hash_seq_search(&status)) &&
(holder != (HOLDER *) TRUE))
while ((holder = (PROCLOCK *) hash_seq_search(&status)) &&
(holder != (PROCLOCK *) TRUE))
{
HOLDER_PRINT("DumpAllLocks", holder);
PROCLOCK_PRINT("DumpAllLocks", holder);
if (holder->tag.lock)
{

View File

@@ -8,7 +8,7 @@
*
*
* IDENTIFICATION
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.109 2001/09/29 04:02:24 tgl Exp $
* $Header: /cvsroot/pgsql/src/backend/storage/lmgr/proc.c,v 1.110 2001/09/29 21:35:14 momjian Exp $
*
*-------------------------------------------------------------------------
*/
@@ -563,7 +563,7 @@ int
ProcSleep(LOCKMETHODTABLE *lockMethodTable,
LOCKMODE lockmode,
LOCK *lock,
HOLDER *holder)
PROCLOCK *holder)
{
LOCKMETHODCTL *lockctl = lockMethodTable->ctl;
LWLockId masterLock = lockctl->masterLock;