Commit c235a6a5 authored by Alvaro Herrera's avatar Alvaro Herrera

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
parent e518fa7a
...@@ -479,13 +479,22 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum, ...@@ -479,13 +479,22 @@ heap_prune_chain(Relation relation, Buffer buffer, OffsetNumber rootoffnum,
break; break;
case HEAPTUPLE_DELETE_IN_PROGRESS: case HEAPTUPLE_DELETE_IN_PROGRESS:
{
TransactionId xmax;
/* /*
* This tuple may soon become DEAD. Update the hint field so * This tuple may soon become DEAD. Update the hint field
* that the page is reconsidered for pruning in future. * so that the page is reconsidered for pruning in future.
* If there was a MultiXactId updater, and it aborted after
* HTSV checked, then we will get an invalid Xid here.
* There is no need for future pruning of the page in that
* case, so skip it.
*/ */
heap_prune_record_prunable(prstate, xmax = HeapTupleHeaderGetUpdateXid(htup);
HeapTupleHeaderGetUpdateXid(htup)); if (TransactionIdIsValid(xmax))
heap_prune_record_prunable(prstate, xmax);
}
break; break;
case HEAPTUPLE_LIVE: case HEAPTUPLE_LIVE:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment