Skip to content

Commit d5e3d1e

Browse files
committed
Fix thinko in lock mode enum
Commit 0e5680f contained a thinko mixing LOCKMODE with LockTupleMode. This caused misbehavior in the case where a tuple is marked with a multixact with at most a FOR SHARE lock, and another transaction tries to acquire a FOR NO KEY EXCLUSIVE lock; this case should block but doesn't. Include a new isolation tester spec file to explicitely try all the tuple lock combinations; without the fix it shows the problem: starting permutation: s1_begin s1_lcksvpt s1_tuplock2 s2_tuplock3 s1_commit step s1_begin: BEGIN; step s1_lcksvpt: SELECT * FROM multixact_conflict FOR KEY SHARE; SAVEPOINT foo; a 1 step s1_tuplock2: SELECT * FROM multixact_conflict FOR SHARE; a 1 step s2_tuplock3: SELECT * FROM multixact_conflict FOR NO KEY UPDATE; a 1 step s1_commit: COMMIT; With the fixed code, step s2_tuplock3 blocks until session 1 commits, which is the correct behavior. All other cases behave correctly. Backpatch to 9.3, like the commit that introduced the problem.
1 parent 2ea9595 commit d5e3d1e

File tree

4 files changed

+537
-2
lines changed

4 files changed

+537
-2
lines changed

src/backend/access/heap/heapam.c

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6102,6 +6102,7 @@ DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
61026102
int nmembers;
61036103
MultiXactMember *members;
61046104
bool result = false;
6105+
LOCKMODE wanted = tupleLockExtraInfo[lockmode].hwlock;
61056106

61066107
allow_old = !(infomask & HEAP_LOCK_MASK) && HEAP_XMAX_IS_LOCKED_ONLY(infomask);
61076108
nmembers = GetMultiXactIdMembers(multi, &members, allow_old,
@@ -6113,11 +6114,12 @@ DoesMultiXactIdConflict(MultiXactId multi, uint16 infomask,
61136114
for (i = 0; i < nmembers; i++)
61146115
{
61156116
TransactionId memxid;
6116-
LockTupleMode memlockmode;
6117+
LOCKMODE memlockmode;
61176118

61186119
memlockmode = LOCKMODE_from_mxstatus(members[i].status);
6120+
61196121
/* ignore members that don't conflict with the lock we want */
6120-
if (!DoLockModesConflict(memlockmode, lockmode))
6122+
if (!DoLockModesConflict(memlockmode, wanted))
61216123
continue;
61226124

61236125
/* ignore members from current xact */

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy