mirror of
https://github.com/postgres/postgres.git
synced 2025-04-27 22:56:53 +03:00
Fix bugs in SSI tuple locking.
1. In heap_hot_search_buffer(), the PredicateLockTuple() call is passed wrong offset number. heapTuple->t_self is set to the tid of the first tuple in the chain that's visited, not the one actually being read. 2. CheckForSerializableConflictIn() uses the tuple's t_ctid field instead of t_self to check for exiting predicate locks on the tuple. If the tuple was updated, but the updater rolled back, t_ctid points to the aborted dead tuple. Reported by Hannu Krosing. Backpatch to 9.1.
This commit is contained in:
parent
0b109c822b
commit
81fbbfe335
@ -1688,6 +1688,8 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
|
||||
at_chain_start = first_call;
|
||||
skip = !first_call;
|
||||
|
||||
heapTuple->t_self = *tid;
|
||||
|
||||
/* Scan through possible multiple members of HOT-chain */
|
||||
for (;;)
|
||||
{
|
||||
@ -1717,7 +1719,7 @@ heap_hot_search_buffer(ItemPointer tid, Relation relation, Buffer buffer,
|
||||
heapTuple->t_data = (HeapTupleHeader) PageGetItem(dp, lp);
|
||||
heapTuple->t_len = ItemIdGetLength(lp);
|
||||
heapTuple->t_tableOid = RelationGetRelid(relation);
|
||||
heapTuple->t_self = *tid;
|
||||
ItemPointerSetOffsetNumber(&heapTuple->t_self, offnum);
|
||||
|
||||
/*
|
||||
* Shouldn't see a HEAP_ONLY tuple at chain start.
|
||||
|
@ -4279,8 +4279,8 @@ CheckForSerializableConflictIn(Relation relation, HeapTuple tuple,
|
||||
SET_PREDICATELOCKTARGETTAG_TUPLE(targettag,
|
||||
relation->rd_node.dbNode,
|
||||
relation->rd_id,
|
||||
ItemPointerGetBlockNumber(&(tuple->t_data->t_ctid)),
|
||||
ItemPointerGetOffsetNumber(&(tuple->t_data->t_ctid)));
|
||||
ItemPointerGetBlockNumber(&(tuple->t_self)),
|
||||
ItemPointerGetOffsetNumber(&(tuple->t_self)));
|
||||
CheckTargetForConflictsIn(&targettag);
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user