From d6686759d821c9f66473d7dc34d8459e6d1e6faf Mon Sep 17 00:00:00 2001 From: Dilip Kumar Date: Mon, 9 Mar 2020 17:40:45 +0530 Subject: [PATCH v3 3/3] Conflict Extension/Page lock in group member --- src/backend/storage/lmgr/deadlock.c | 9 +++++++++ src/backend/storage/lmgr/lock.c | 12 ++++++++++++ 2 files changed, 21 insertions(+) diff --git a/src/backend/storage/lmgr/deadlock.c b/src/backend/storage/lmgr/deadlock.c index f8c5df0..49a5998 100644 --- a/src/backend/storage/lmgr/deadlock.c +++ b/src/backend/storage/lmgr/deadlock.c @@ -568,6 +568,15 @@ FindLockCycleRecurseMember(PGPROC *checkProc, proclock = (PROCLOCK *) SHMQueueNext(procLocks, procLocks, offsetof(PROCLOCK, lockLink)); + /* + * Relation extension/page lock never participate in actual deadlock cycle. + * So avoid the wait edge for these type of lock so that we can avoid any + * false cycle detection due to group locking. + */ + if ((lock->tag.locktag_type == LOCKTAG_RELATION_EXTEND) || + (lock->tag.locktag_type == LOCKTAG_PAGE)) + return false; + while (proclock) { PGPROC *leader; diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 1fcff29..012ba96 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -1433,6 +1433,18 @@ LockCheckConflicts(LockMethod lockMethodTable, } /* + * If it's a relation extension/page lock then it will conflict even between + * the lock group member. + */ + if ((lock->tag.locktag_type == LOCKTAG_RELATION_EXTEND) || + (lock->tag.locktag_type == LOCKTAG_PAGE)) + { + PROCLOCK_PRINT("LockCheckConflicts: conflicting (simple)", + proclock); + return true; + } + + /* * Locks held in conflicting modes by members of our own lock group are * not real conflicts; we can subtract those out and see if we still have * a conflict. This is O(N) in the number of processes holding or -- 1.8.3.1