From 7d5556cabd3955ee25afc55a145d82cefb39b663 Mon Sep 17 00:00:00 2001 From: Heikki Linnakangas Date: Mon, 22 Jul 2024 17:27:16 +0300 Subject: [PATCH v5 6/8] Update local lock table in ProcSleep's caller ProcSleep is now responsible only for the shared state. Seems a little nicer that way. --- src/backend/storage/lmgr/lock.c | 4 +++- src/backend/storage/lmgr/proc.c | 7 ------- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 4e1890276f..91d2402609 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -1042,7 +1042,6 @@ LockAcquireExtended(const LOCKTAG *locktag, { /* No conflict with held or previously requested locks */ GrantLock(lock, proclock, lockmode); - GrantLockLocal(locallock, owner); } else { @@ -1122,6 +1121,9 @@ LockAcquireExtended(const LOCKTAG *locktag, LOCK_PRINT("LockAcquire: granted", lock, lockmode); } + /* The lock was granted to us. Update the local lock entry accordingly */ + GrantLockLocal(locallock, owner); + /* * Lock state is fully up-to-date now; if we error out after this, no * special error cleanup is required. diff --git a/src/backend/storage/lmgr/proc.c b/src/backend/storage/lmgr/proc.c index e8084dd3d5..f29e02e902 100644 --- a/src/backend/storage/lmgr/proc.c +++ b/src/backend/storage/lmgr/proc.c @@ -1158,7 +1158,6 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable, bool dontWait) { /* Skip the wait and just grant myself the lock. */ GrantLock(lock, proclock, lockmode); - GrantAwaitedLock(); return PROC_WAIT_STATUS_OK; } @@ -1634,12 +1633,6 @@ ProcSleep(LOCALLOCK *locallock, LockMethod lockMethodTable, bool dontWait) */ LWLockAcquire(partitionLock, LW_EXCLUSIVE); - /* - * If we got the lock, be sure to remember it in the locallock table. - */ - if (MyProc->waitStatus == PROC_WAIT_STATUS_OK) - GrantAwaitedLock(); - /* * We don't have to do anything else, because the awaker did all the * necessary update of the lock table and MyProc. -- 2.34.1