aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlvaro Herrera <alvherre@alvh.no-ip.org>2013-08-02 14:34:56 -0400
committerAlvaro Herrera <alvherre@alvh.no-ip.org>2013-08-02 17:02:36 -0400
commit706f9dd914c64a41e06b5fbfd62d6d6dab43eeb8 (patch)
tree396c3ad6d2ab202b85a7cbbab433b5a1cf4a8a86
parent88c556680ca3faa40f7428c7705455d744a9859e (diff)
downloadpostgresql-706f9dd914c64a41e06b5fbfd62d6d6dab43eeb8.tar.gz
postgresql-706f9dd914c64a41e06b5fbfd62d6d6dab43eeb8.zip
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 3f7fbf85dc5b42, 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
-rw-r--r--src/backend/utils/time/tqual.c3
1 files changed, 2 insertions, 1 deletions
diff --git a/src/backend/utils/time/tqual.c b/src/backend/utils/time/tqual.c
index 38bb704a4d8..ed66c49a91f 100644
--- a/src/backend/utils/time/tqual.c
+++ b/src/backend/utils/time/tqual.c
@@ -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;
}