Skip to content

Commit 6bfa88a

Browse files
committed
Fix WAL replay of locking an updated tuple
We were resetting the tuple's HEAP_HOT_UPDATED flag as well as t_ctid on WAL replay of a tuple-lock operation, which is incorrect when the tuple is already updated. Back-patch to 9.3. The clearing of both header elements was there previously, but since no update could be present on a tuple that was being locked, it was harmless. Bug reported by Peter Geoghegan and Greg Stark in CAM3SWZTMQiCi5PV5OWHb+bYkUcnCk=O67w0cSswPvV7XfUcU5g@mail.gmail.com and CAM-w4HPTOeMT4KP0OJK+mGgzgcTOtLRTvFZyvD0O4aH-7dxo3Q@mail.gmail.com respectively; diagnosis by Andres Freund.
1 parent 00976f2 commit 6bfa88a

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

src/backend/access/heap/heapam.c

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8016,11 +8016,19 @@ heap_xlog_lock(XLogRecPtr lsn, XLogRecord *record)
80168016

80178017
fix_infomask_from_infobits(xlrec->infobits_set, &htup->t_infomask,
80188018
&htup->t_infomask2);
8019-
HeapTupleHeaderClearHotUpdated(htup);
8019+
8020+
/*
8021+
* Clear relevant update flags, but only if the modified infomask says
8022+
* there's no update.
8023+
*/
8024+
if (HEAP_XMAX_IS_LOCKED_ONLY(htup->t_infomask))
8025+
{
8026+
HeapTupleHeaderClearHotUpdated(htup);
8027+
/* Make sure there is no forward chain link in t_ctid */
8028+
htup->t_ctid = xlrec->target.tid;
8029+
}
80208030
HeapTupleHeaderSetXmax(htup, xlrec->locking_xid);
80218031
HeapTupleHeaderSetCmax(htup, FirstCommandId, false);
8022-
/* Make sure there is no forward chain link in t_ctid */
8023-
htup->t_ctid = xlrec->target.tid;
80248032
PageSetLSN(page, lsn);
80258033
MarkBufferDirty(buffer);
80268034
UnlockReleaseBuffer(buffer);

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