From dc32923f690390f120fccc154d656ff6529d6302 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 22 Jul 2024 17:38:06 +0300 Subject: [PATCH v5 7/8] Release partition lock a little earlier We don't need to hold the lock to prevent die/cancel interrupts, they are only processed at explicit CHECK_FOR_INTERRUPTS() points now. --- src/backend/storage/lmgr/lock.c | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 91d2402609..fc77c88747 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -1042,6 +1042,7 @@ LockAcquireExtended(const LOCKTAG *locktag, { /* No conflict with held or previously requested locks */ GrantLock(lock, proclock, lockmode); + LWLockRelease(partitionLock); } else { @@ -1117,8 +1118,10 @@ LockAcquireExtended(const LOCKTAG *locktag, elog(ERROR, "LockAcquire failed"); } } + PROCLOCK_PRINT("LockAcquire: granted", proclock); LOCK_PRINT("LockAcquire: granted", lock, lockmode); + LWLockRelease(partitionLock); } /* The lock was granted to us. Update the local lock entry accordingly */ @@ -1130,8 +1133,6 @@ LockAcquireExtended(const LOCKTAG *locktag, */ FinishStrongLockAcquire(); - LWLockRelease(partitionLock); - /* * Emit a WAL record if acquisition of this lock needs to be replayed in a * standby server. -- 2.34.1