Skip to content

Commit 4ed0640

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 fbface6 commit 4ed0640

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
@@ -466,13 +466,22 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum,
466466
break;
467467

468468
case HEAPTUPLE_DELETE_IN_PROGRESS:
469+
{
470+
TransactionId xmax;
471+
472+
/*
473+
* This tuple may soon become DEAD. Update the hint field
474+
* so that the page is reconsidered for pruning in future.
475+
* If there was a MultiXactId updater, and it aborted after
476+
* HTSV checked, then we will get an invalid Xid here.
477+
* There is no need for future pruning of the page in that
478+
* case, so skip it.
479+
*/
480+
xmax = HeapTupleHeaderGetUpdateXid(htup);
481+
if (TransactionIdIsValid(xmax))
482+
heap_prune_record_prunable(prstate, xmax);
483+
}
469484

470-
/*
471-
* This tuple may soon become DEAD. Update the hint field so
472-
* that the page is reconsidered for pruning in future.
473-
*/
474-
heap_prune_record_prunable(prstate,
475-
HeapTupleHeaderGetUpdateXid(htup));
476485
break;
477486

478487
case HEAPTUPLE_LIVE:

0 commit comments

Comments
 (0)