mirror of
https://github.com/postgres/postgres.git
synced 2025-08-18 12:22:09 +03:00
Avoid uselessly looking up old LOCK_ONLY multixacts
Commit 0ac5ad5134
removed an optimization in multixact.c that skipped
fetching members of MultiXactId that were older than our
OldestVisibleMXactId value. The reason this was removed is that it is
possible for multixacts that contain updates to be older than that
value. However, if the caller is certain that the multi does not
contain an update (because the infomask bits say so), it can pass this
info down to GetMultiXactIdMembers, enabling it to use the old
optimization.
Pointed out by Andres Freund in 20131121200517.GM7240@alap2.anarazel.de
This commit is contained in:
@@ -607,7 +607,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
|
||||
*/
|
||||
if ((tuple->t_infomask & (HEAP_XMAX_EXCL_LOCK |
|
||||
HEAP_XMAX_KEYSHR_LOCK)) &&
|
||||
MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple)))
|
||||
MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), true))
|
||||
return HeapTupleBeingUpdated;
|
||||
|
||||
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, InvalidTransactionId);
|
||||
@@ -615,6 +615,11 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
|
||||
}
|
||||
|
||||
xmax = HeapTupleGetUpdateXid(tuple);
|
||||
if (!TransactionIdIsValid(xmax))
|
||||
{
|
||||
if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
|
||||
return HeapTupleBeingUpdated;
|
||||
}
|
||||
|
||||
/* not LOCKED_ONLY, so it has to have an xmax */
|
||||
Assert(TransactionIdIsValid(xmax));
|
||||
@@ -627,7 +632,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
|
||||
return HeapTupleInvisible; /* updated before scan started */
|
||||
}
|
||||
|
||||
if (TransactionIdIsInProgress(xmax))
|
||||
if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
|
||||
return HeapTupleBeingUpdated;
|
||||
|
||||
if (TransactionIdDidCommit(xmax))
|
||||
@@ -638,7 +643,7 @@ HeapTupleSatisfiesUpdate(HeapTuple htup, CommandId curcid,
|
||||
* what about the other members?
|
||||
*/
|
||||
|
||||
if (!MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple)))
|
||||
if (!MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
|
||||
{
|
||||
/*
|
||||
* There's no member, even just a locker, alive anymore, so we can
|
||||
@@ -1240,7 +1245,8 @@ HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin,
|
||||
*/
|
||||
if ((tuple->t_infomask & (HEAP_XMAX_EXCL_LOCK |
|
||||
HEAP_XMAX_KEYSHR_LOCK)) &&
|
||||
MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple)))
|
||||
MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple),
|
||||
true))
|
||||
return HEAPTUPLE_LIVE;
|
||||
SetHintBits(tuple, buffer, HEAP_XMAX_INVALID, InvalidTransactionId);
|
||||
|
||||
@@ -1267,7 +1273,7 @@ HeapTupleSatisfiesVacuum(HeapTuple htup, TransactionId OldestXmin,
|
||||
{
|
||||
TransactionId xmax;
|
||||
|
||||
if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple)))
|
||||
if (MultiXactIdIsRunning(HeapTupleHeaderGetRawXmax(tuple), false))
|
||||
{
|
||||
/* already checked above */
|
||||
Assert(!HEAP_XMAX_IS_LOCKED_ONLY(tuple->t_infomask));
|
||||
|
Reference in New Issue
Block a user