Skip to content

Commit c235a6a

Browse files
committed
Don't try to set InvalidXid as page pruning hint
If a transaction updates/deletes a tuple just before aborting, and a concurrent transaction tries to prune the page concurrently, the pruner may see HeapTupleSatisfiesVacuum return HEAPTUPLE_DELETE_IN_PROGRESS, but a later call to HeapTupleGetUpdateXid() return InvalidXid. This would cause an assertion failure in development builds, but would be otherwise Mostly Harmless. Fix by checking whether the updater Xid is valid before trying to apply it as page prune point. Reported by Andres in 20131124000203.GA4403@alap2.anarazel.de
1 parent e518fa7 commit c235a6a

File tree

1 file changed

+15
-6
lines changed

1 file changed

+15
-6
lines changed

src/backend/access/heap/pruneheap.c

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -479,13 +479,22 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum,
479479
break;
480480

481481
case HEAPTUPLE_DELETE_IN_PROGRESS:
482+
{
483+
TransactionId xmax;
484+
485+
/*
486+
* This tuple may soon become DEAD. Update the hint field
487+
* so that the page is reconsidered for pruning in future.
488+
* If there was a MultiXactId updater, and it aborted after
489+
* HTSV checked, then we will get an invalid Xid here.
490+
* There is no need for future pruning of the page in that
491+
* case, so skip it.
492+
*/
493+
xmax = HeapTupleHeaderGetUpdateXid(htup);
494+
if (TransactionIdIsValid(xmax))
495+
heap_prune_record_prunable(prstate, xmax);
496+
}
482497

483-
/*
484-
* This tuple may soon become DEAD. Update the hint field so
485-
* that the page is reconsidered for pruning in future.
486-
*/
487-
heap_prune_record_prunable(prstate,
488-
HeapTupleHeaderGetUpdateXid(htup));
489498
break;
490499

491500
case HEAPTUPLE_LIVE:

0 commit comments

Comments
 (0)