Fix old visibility bug in HeapTupleSatisfiesDirty

If a tuple is locked but not updated by a concurrent transaction,
HeapTupleSatisfiesDirty would return that transaction's Xid in xmax,
causing callers to wait on it, when it is not necessary (in fact, if the
other transaction had used a multixact instead of a plain Xid to mark
the tuple, HeapTupleSatisfiesDirty would have behave differently and
*not* returned the Xmax).

This bug was introduced in commit 3f7fbf85dc, dated December 1998,
so it's almost 15 years old now.  However, it's hard to see this
misbehave, because before we had NOWAIT the only consequence of this is
that transactions would wait for slightly more time than necessary; so
it's not surprising that this hasn't been reported yet.

Craig Ringer and Andres Freund
This commit is contained in:
Alvaro Herrera 2013-08-02 14:34:56 -04:00
parent 88c556680c
commit 706f9dd914
1 changed files with 2 additions and 1 deletions

View File

@ -803,7 +803,8 @@ HeapTupleSatisfiesDirty(HeapTuple htup, Snapshot snapshot,
if (TransactionIdIsInProgress(HeapTupleHeaderGetRawXmax(tuple)))
{
snapshot->xmax = HeapTupleHeaderGetRawXmax(tuple);
if (!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask))
snapshot->xmax = HeapTupleHeaderGetRawXmax(tuple);
return true;
}