mirror of
https://github.com/postgres/postgres.git
synced 2025-08-30 06:01:21 +03:00
Rename assorted LWLock tranches.
Choose names that fit into the conventions for wait event names (particularly, that multi-word names are in the style MultiWordName) and hopefully convey more information to non-hacker users than the previous names did. Also rename SerializablePredicateLockListLock to SerializablePredicateListLock; the old name was long enough to cause table formatting problems, plus the double occurrence of "Lock" seems confusing/error-prone. Also change a couple of particularly opaque LWLock field names. Discussion: https://postgr.es/m/28683.1589405363@sss.pgh.pa.us
This commit is contained in:
@@ -936,13 +936,13 @@ LockAcquireExtended(const LOCKTAG *locktag,
|
||||
* FastPathStrongRelationLocks->counts becomes visible after we test
|
||||
* it has yet to begin to transfer fast-path locks.
|
||||
*/
|
||||
LWLockAcquire(&MyProc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&MyProc->fpInfoLock, LW_EXCLUSIVE);
|
||||
if (FastPathStrongRelationLocks->count[fasthashcode] != 0)
|
||||
acquired = false;
|
||||
else
|
||||
acquired = FastPathGrantRelationLock(locktag->locktag_field2,
|
||||
lockmode);
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
if (acquired)
|
||||
{
|
||||
/*
|
||||
@@ -2085,10 +2085,10 @@ LockRelease(const LOCKTAG *locktag, LOCKMODE lockmode, bool sessionLock)
|
||||
* We might not find the lock here, even if we originally entered it
|
||||
* here. Another backend may have moved it to the main table.
|
||||
*/
|
||||
LWLockAcquire(&MyProc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&MyProc->fpInfoLock, LW_EXCLUSIVE);
|
||||
released = FastPathUnGrantRelationLock(locktag->locktag_field2,
|
||||
lockmode);
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
if (released)
|
||||
{
|
||||
RemoveLocalLock(locallock);
|
||||
@@ -2291,7 +2291,7 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks)
|
||||
*/
|
||||
if (!have_fast_path_lwlock)
|
||||
{
|
||||
LWLockAcquire(&MyProc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&MyProc->fpInfoLock, LW_EXCLUSIVE);
|
||||
have_fast_path_lwlock = true;
|
||||
}
|
||||
|
||||
@@ -2308,7 +2308,7 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks)
|
||||
* transferred to the main lock table. That's going to require
|
||||
* some extra work, so release our fast-path lock before starting.
|
||||
*/
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
have_fast_path_lwlock = false;
|
||||
|
||||
/*
|
||||
@@ -2334,7 +2334,7 @@ LockReleaseAll(LOCKMETHODID lockmethodid, bool allLocks)
|
||||
|
||||
/* Done with the fast-path data structures */
|
||||
if (have_fast_path_lwlock)
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
|
||||
/*
|
||||
* Now, scan each lock partition separately.
|
||||
@@ -2737,7 +2737,7 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
|
||||
PGPROC *proc = &ProcGlobal->allProcs[i];
|
||||
uint32 f;
|
||||
|
||||
LWLockAcquire(&proc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&proc->fpInfoLock, LW_EXCLUSIVE);
|
||||
|
||||
/*
|
||||
* If the target backend isn't referencing the same database as the
|
||||
@@ -2746,8 +2746,8 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
|
||||
*
|
||||
* proc->databaseId is set at backend startup time and never changes
|
||||
* thereafter, so it might be safe to perform this test before
|
||||
* acquiring &proc->backendLock. In particular, it's certainly safe
|
||||
* to assume that if the target backend holds any fast-path locks, it
|
||||
* acquiring &proc->fpInfoLock. In particular, it's certainly safe to
|
||||
* assume that if the target backend holds any fast-path locks, it
|
||||
* must have performed a memory-fencing operation (in particular, an
|
||||
* LWLock acquisition) since setting proc->databaseId. However, it's
|
||||
* less clear that our backend is certain to have performed a memory
|
||||
@@ -2756,7 +2756,7 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
|
||||
*/
|
||||
if (proc->databaseId != locktag->locktag_field1)
|
||||
{
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -2783,7 +2783,7 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
|
||||
if (!proclock)
|
||||
{
|
||||
LWLockRelease(partitionLock);
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
return false;
|
||||
}
|
||||
GrantLock(proclock->tag.myLock, proclock, lockmode);
|
||||
@@ -2794,7 +2794,7 @@ FastPathTransferRelationLocks(LockMethod lockMethodTable, const LOCKTAG *locktag
|
||||
/* No need to examine remaining slots. */
|
||||
break;
|
||||
}
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
@@ -2816,7 +2816,7 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock)
|
||||
Oid relid = locktag->locktag_field2;
|
||||
uint32 f;
|
||||
|
||||
LWLockAcquire(&MyProc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&MyProc->fpInfoLock, LW_EXCLUSIVE);
|
||||
|
||||
for (f = 0; f < FP_LOCK_SLOTS_PER_BACKEND; f++)
|
||||
{
|
||||
@@ -2839,7 +2839,7 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock)
|
||||
if (!proclock)
|
||||
{
|
||||
LWLockRelease(partitionLock);
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of shared memory"),
|
||||
@@ -2854,7 +2854,7 @@ FastPathGetRelationLockEntry(LOCALLOCK *locallock)
|
||||
break;
|
||||
}
|
||||
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
|
||||
/* Lock may have already been transferred by some other backend. */
|
||||
if (proclock == NULL)
|
||||
@@ -2980,7 +2980,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
|
||||
if (proc == MyProc)
|
||||
continue;
|
||||
|
||||
LWLockAcquire(&proc->backendLock, LW_SHARED);
|
||||
LWLockAcquire(&proc->fpInfoLock, LW_SHARED);
|
||||
|
||||
/*
|
||||
* If the target backend isn't referencing the same database as
|
||||
@@ -2992,7 +2992,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
|
||||
*/
|
||||
if (proc->databaseId != locktag->locktag_field1)
|
||||
{
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
continue;
|
||||
}
|
||||
|
||||
@@ -3030,7 +3030,7 @@ GetLockConflicts(const LOCKTAG *locktag, LOCKMODE lockmode, int *countp)
|
||||
break;
|
||||
}
|
||||
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3599,7 +3599,7 @@ GetLockStatusData(void)
|
||||
PGPROC *proc = &ProcGlobal->allProcs[i];
|
||||
uint32 f;
|
||||
|
||||
LWLockAcquire(&proc->backendLock, LW_SHARED);
|
||||
LWLockAcquire(&proc->fpInfoLock, LW_SHARED);
|
||||
|
||||
for (f = 0; f < FP_LOCK_SLOTS_PER_BACKEND; ++f)
|
||||
{
|
||||
@@ -3659,7 +3659,7 @@ GetLockStatusData(void)
|
||||
el++;
|
||||
}
|
||||
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4381,7 +4381,7 @@ lock_twophase_postabort(TransactionId xid, uint16 info,
|
||||
* as MyProc->lxid, you might wonder if we really need both. The
|
||||
* difference is that MyProc->lxid is set and cleared unlocked, and
|
||||
* examined by procarray.c, while fpLocalTransactionId is protected by
|
||||
* backendLock and is used only by the locking subsystem. Doing it this
|
||||
* fpInfoLock and is used only by the locking subsystem. Doing it this
|
||||
* way makes it easier to verify that there are no funny race conditions.
|
||||
*
|
||||
* We don't bother recording this lock in the local lock table, since it's
|
||||
@@ -4393,7 +4393,7 @@ VirtualXactLockTableInsert(VirtualTransactionId vxid)
|
||||
{
|
||||
Assert(VirtualTransactionIdIsValid(vxid));
|
||||
|
||||
LWLockAcquire(&MyProc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&MyProc->fpInfoLock, LW_EXCLUSIVE);
|
||||
|
||||
Assert(MyProc->backendId == vxid.backendId);
|
||||
Assert(MyProc->fpLocalTransactionId == InvalidLocalTransactionId);
|
||||
@@ -4402,7 +4402,7 @@ VirtualXactLockTableInsert(VirtualTransactionId vxid)
|
||||
MyProc->fpVXIDLock = true;
|
||||
MyProc->fpLocalTransactionId = vxid.localTransactionId;
|
||||
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
}
|
||||
|
||||
/*
|
||||
@@ -4422,14 +4422,14 @@ VirtualXactLockTableCleanup(void)
|
||||
/*
|
||||
* Clean up shared memory state.
|
||||
*/
|
||||
LWLockAcquire(&MyProc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&MyProc->fpInfoLock, LW_EXCLUSIVE);
|
||||
|
||||
fastpath = MyProc->fpVXIDLock;
|
||||
lxid = MyProc->fpLocalTransactionId;
|
||||
MyProc->fpVXIDLock = false;
|
||||
MyProc->fpLocalTransactionId = InvalidLocalTransactionId;
|
||||
|
||||
LWLockRelease(&MyProc->backendLock);
|
||||
LWLockRelease(&MyProc->fpInfoLock);
|
||||
|
||||
/*
|
||||
* If fpVXIDLock has been cleared without touching fpLocalTransactionId,
|
||||
@@ -4485,13 +4485,13 @@ VirtualXactLock(VirtualTransactionId vxid, bool wait)
|
||||
* against the ones we're waiting for. The target backend will only set
|
||||
* or clear lxid while holding this lock.
|
||||
*/
|
||||
LWLockAcquire(&proc->backendLock, LW_EXCLUSIVE);
|
||||
LWLockAcquire(&proc->fpInfoLock, LW_EXCLUSIVE);
|
||||
|
||||
/* If the transaction has ended, our work here is done. */
|
||||
if (proc->backendId != vxid.backendId
|
||||
|| proc->fpLocalTransactionId != vxid.localTransactionId)
|
||||
{
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -4501,7 +4501,7 @@ VirtualXactLock(VirtualTransactionId vxid, bool wait)
|
||||
*/
|
||||
if (!wait)
|
||||
{
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -4526,7 +4526,7 @@ VirtualXactLock(VirtualTransactionId vxid, bool wait)
|
||||
if (!proclock)
|
||||
{
|
||||
LWLockRelease(partitionLock);
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
ereport(ERROR,
|
||||
(errcode(ERRCODE_OUT_OF_MEMORY),
|
||||
errmsg("out of shared memory"),
|
||||
@@ -4540,7 +4540,7 @@ VirtualXactLock(VirtualTransactionId vxid, bool wait)
|
||||
}
|
||||
|
||||
/* Done with proc->fpLockBits */
|
||||
LWLockRelease(&proc->backendLock);
|
||||
LWLockRelease(&proc->fpInfoLock);
|
||||
|
||||
/* Time to wait. */
|
||||
(void) LockAcquire(&tag, ShareLock, false, false);
|
||||
|
Reference in New Issue
Block a user