v2-0002-Fix-the-bug-with-priorXmax.patch
application/octet-stream
Filename: v2-0002-Fix-the-bug-with-priorXmax.patch
Type: application/octet-stream
Part: 0
Message:
Re: Visibility bug in tuple lock
Patch
Same data as JSON:
GET /api/v1/attachments/:id/patch
the parsed metadata as JSON — format, series position, per-file stats; never the diff bytes.
API reference →
Format: format-patch
Series: patch v2-0002
Subject: Fix the bug with priorXmax
| File | + | − |
|---|---|---|
| src/backend/access/heap/heapam.c | 5 | 3 |
From 544ba4fbd94619f34d1a2746e9cff6ec7e24236b Mon Sep 17 00:00:00 2001
From: Jasper Smit <jasper.smit@servicenow.com>
Date: Fri, 12 Dec 2025 13:40:36 +0100
Subject: [PATCH 2/2] Fix the bug with priorXmax
---
src/backend/access/heap/heapam.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/src/backend/access/heap/heapam.c b/src/backend/access/heap/heapam.c
index a69df8bd431..41e963a21a8 100644
--- a/src/backend/access/heap/heapam.c
+++ b/src/backend/access/heap/heapam.c
@@ -5721,7 +5721,8 @@ test_lockmode_for_conflict(MultiXactStatus status, TransactionId xid,
* version as well.
*/
static TM_Result
-heap_lock_updated_tuple_rec(Relation rel, const ItemPointerData *tid, TransactionId xid,
+heap_lock_updated_tuple_rec(Relation rel, TransactionId priorXmax,
+ const ItemPointerData *tid, TransactionId xid,
LockTupleMode mode)
{
TM_Result result;
@@ -5734,7 +5735,6 @@ heap_lock_updated_tuple_rec(Relation rel, const ItemPointerData *tid, Transactio
old_infomask2;
TransactionId xmax,
new_xmax;
- TransactionId priorXmax = InvalidTransactionId;
bool cleared_all_frozen = false;
bool pinned_desired_page;
Buffer vmbuffer = InvalidBuffer;
@@ -6078,6 +6078,7 @@ heap_lock_updated_tuple(Relation rel, HeapTuple tuple, const ItemPointerData *ct
if (!HeapTupleHeaderIndicatesMovedPartitions(tuple->t_data) &&
!ItemPointerEquals(&tuple->t_self, ctid))
{
+ TransactionId priorXmax;
/*
* If this is the first possibly-multixact-able operation in the
* current transaction, set my per-backend OldestMemberMXactId
@@ -6089,7 +6090,8 @@ heap_lock_updated_tuple(Relation rel, HeapTuple tuple, const ItemPointerData *ct
*/
MultiXactIdSetOldestMember();
- return heap_lock_updated_tuple_rec(rel, ctid, xid, mode);
+ priorXmax = HeapTupleHeaderGetUpdateXid(tuple->t_data);
+ return heap_lock_updated_tuple_rec(rel, priorXmax, ctid, xid, mode);
}
/* nothing to lock */
--
2.39.5