mirror of
https://github.com/postgres/postgres.git
synced 2025-07-28 23:42:10 +03:00
Simplify shared-memory lock data structures as per recent discussion:
it is sufficient to track whether a backend holds a lock or not, and store information about transaction vs. session locks only in the inside-the-backend LocalLockTable. Since there can now be but one PROCLOCK per lock per backend, LockCountMyLocks() is no longer needed, thus eliminating some O(N^2) behavior when a backend holds many locks. Also simplify the LockAcquire/LockRelease API by passing just a 'sessionLock' boolean instead of a transaction ID. The previous API was designed with the idea that per-transaction lock holding would be important for subtransactions, but now that we have subtransactions we know that this is unwanted. While at it, add an 'isTempObject' parameter to LockAcquire to indicate whether the lock is being taken on a temp table. This is not used just yet, but will be needed shortly for two-phase commit.
This commit is contained in:
@ -33,8 +33,8 @@ user_lock(uint32 id1, uint32 id2, LOCKMODE lockmode)
|
||||
|
||||
SET_LOCKTAG_USERLOCK(tag, id1, id2);
|
||||
|
||||
return (LockAcquire(USER_LOCKMETHOD, &tag, InvalidTransactionId,
|
||||
lockmode, true) != LOCKACQUIRE_NOT_AVAIL);
|
||||
return (LockAcquire(USER_LOCKMETHOD, &tag, false,
|
||||
lockmode, true, true) != LOCKACQUIRE_NOT_AVAIL);
|
||||
}
|
||||
|
||||
int
|
||||
@ -44,7 +44,7 @@ user_unlock(uint32 id1, uint32 id2, LOCKMODE lockmode)
|
||||
|
||||
SET_LOCKTAG_USERLOCK(tag, id1, id2);
|
||||
|
||||
return LockRelease(USER_LOCKMETHOD, &tag, InvalidTransactionId, lockmode);
|
||||
return LockRelease(USER_LOCKMETHOD, &tag, lockmode, true);
|
||||
}
|
||||
|
||||
int
|
||||
|
Reference in New Issue
Block a user