diff options
author | Amit Kapila <akapila@postgresql.org> | 2023-07-06 08:41:30 +0530 |
---|---|---|
committer | Amit Kapila <akapila@postgresql.org> | 2023-07-06 08:41:30 +0530 |
commit | 3c1adbbf86c2cfa44ebed64bd01ed589ad0b832b (patch) | |
tree | 2b141de0dbdc1a9f9ae5827a6018648f4c624c43 /src/backend/storage/lmgr/lock.c | |
parent | dc0b5841746c025f6e51b0a6ba0e423b2ac518f0 (diff) | |
download | postgresql-3c1adbbf86c2cfa44ebed64bd01ed589ad0b832b.tar.gz postgresql-3c1adbbf86c2cfa44ebed64bd01ed589ad0b832b.zip |
Revert the commits related to allowing page lock to conflict among parallel group members.
This commit reverts the work done by commits 3ba59ccc89 and 72e78d831a.
Those commits were incorrect in asserting that we never acquire any other
heavy-weight lock after acquring page lock other than relation extension
lock. We can acquire a lock on catalogs while doing catalog look up after
acquring page lock.
This won't impact any existing feature but we need to think some other way
to achieve this before parallelizing other write operations or even
improving the parallelism in vacuum (like allowing multiple workers
for an index).
Reported-by: Jaime Casanova
Author: Amit Kapila
Backpatch-through: 13
Discussion: https://postgr.es/m/CAJKUy5jffnRKNvRHKQ0LynRb0RJC-o4P8Ku3x9vGAVLwDBWumQ@mail.gmail.com
Diffstat (limited to 'src/backend/storage/lmgr/lock.c')
-rw-r--r-- | src/backend/storage/lmgr/lock.c | 32 |
1 files changed, 4 insertions, 28 deletions
diff --git a/src/backend/storage/lmgr/lock.c b/src/backend/storage/lmgr/lock.c index 0a692ee0a6d..f595bce31b9 100644 --- a/src/backend/storage/lmgr/lock.c +++ b/src/backend/storage/lmgr/lock.c @@ -186,18 +186,6 @@ static int FastPathLocalUseCount = 0; */ static bool IsRelationExtensionLockHeld PG_USED_FOR_ASSERTS_ONLY = false; -/* - * Flag to indicate if the page lock is held by this backend. We don't - * acquire any other heavyweight lock while holding the page lock except for - * relation extension. However, these locks are never taken in reverse order - * which implies that page locks will also never participate in the deadlock - * cycle. - * - * Similar to relation extension, page locks are also held for a short - * duration, so imposing such a restriction won't hurt. - */ -static bool IsPageLockHeld PG_USED_FOR_ASSERTS_ONLY = false; - /* Macros for manipulating proc->fpLockBits */ #define FAST_PATH_BITS_PER_SLOT 3 #define FAST_PATH_LOCKNUMBER_OFFSET 1 @@ -887,13 +875,6 @@ LockAcquireExtended(const LOCKTAG *locktag, Assert(!IsRelationExtensionLockHeld); /* - * We don't acquire any other heavyweight lock while holding the page lock - * except for relation extension. - */ - Assert(!IsPageLockHeld || - (locktag->locktag_type == LOCKTAG_RELATION_EXTEND)); - - /* * Prepare to emit a WAL record if acquisition of this lock needs to be * replayed in a standby server. * @@ -1340,10 +1321,10 @@ SetupLockInTable(LockMethod lockMethodTable, PGPROC *proc, } /* - * Check and set/reset the flag that we hold the relation extension/page lock. + * Check and set/reset the flag that we hold the relation extension lock. * * It is callers responsibility that this function is called after - * acquiring/releasing the relation extension/page lock. + * acquiring/releasing the relation extension lock. * * Pass acquired as true if lock is acquired, false otherwise. */ @@ -1353,9 +1334,6 @@ CheckAndSetLockHeld(LOCALLOCK *locallock, bool acquired) #ifdef USE_ASSERT_CHECKING if (LOCALLOCK_LOCKTAG(*locallock) == LOCKTAG_RELATION_EXTEND) IsRelationExtensionLockHeld = acquired; - else if (LOCALLOCK_LOCKTAG(*locallock) == LOCKTAG_PAGE) - IsPageLockHeld = acquired; - #endif } @@ -1480,11 +1458,9 @@ LockCheckConflicts(LockMethod lockMethodTable, } /* - * The relation extension or page lock conflict even between the group - * members. + * The relation extension lock conflict even between the group members. */ - if (LOCK_LOCKTAG(*lock) == LOCKTAG_RELATION_EXTEND || - (LOCK_LOCKTAG(*lock) == LOCKTAG_PAGE)) + if (LOCK_LOCKTAG(*lock) == LOCKTAG_RELATION_EXTEND) { PROCLOCK_PRINT("LockCheckConflicts: conflicting (group)", proclock); |