Skip to content

Commit b1236f4

Browse files
committed
Move multixid allocation out of critical section.
It can fail if you run out of memory. This call was added in 9.3, so backpatch to 9.3 only.
1 parent d9e7873 commit b1236f4

File tree

1 file changed

+15
-15
lines changed

1 file changed

+15
-15
lines changed

src/backend/access/heap/heapam.c

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,6 +2814,21 @@ heap_delete(Relation relation, ItemPointer tid,
28142814
*/
28152815
old_key_tuple = ExtractReplicaIdentity(relation, &tp, true, &old_key_copied);
28162816

2817+
/*
2818+
* If this is the first possibly-multixact-able operation in the current
2819+
* transaction, set my per-backend OldestMemberMXactId setting. We can be
2820+
* certain that the transaction will never become a member of any older
2821+
* MultiXactIds than that. (We have to do this even if we end up just
2822+
* using our own TransactionId below, since some other backend could
2823+
* incorporate our XID into a MultiXact immediately afterwards.)
2824+
*/
2825+
MultiXactIdSetOldestMember();
2826+
2827+
compute_new_xmax_infomask(HeapTupleHeaderGetRawXmax(tp.t_data),
2828+
tp.t_data->t_infomask, tp.t_data->t_infomask2,
2829+
xid, LockTupleExclusive, true,
2830+
&new_xmax, &new_infomask, &new_infomask2);
2831+
28172832
START_CRIT_SECTION();
28182833

28192834
/*
@@ -2833,21 +2848,6 @@ heap_delete(Relation relation, ItemPointer tid,
28332848
vmbuffer);
28342849
}
28352850

2836-
/*
2837-
* If this is the first possibly-multixact-able operation in the current
2838-
* transaction, set my per-backend OldestMemberMXactId setting. We can be
2839-
* certain that the transaction will never become a member of any older
2840-
* MultiXactIds than that. (We have to do this even if we end up just
2841-
* using our own TransactionId below, since some other backend could
2842-
* incorporate our XID into a MultiXact immediately afterwards.)
2843-
*/
2844-
MultiXactIdSetOldestMember();
2845-
2846-
compute_new_xmax_infomask(HeapTupleHeaderGetRawXmax(tp.t_data),
2847-
tp.t_data->t_infomask, tp.t_data->t_infomask2,
2848-
xid, LockTupleExclusive, true,
2849-
&new_xmax, &new_infomask, &new_infomask2);
2850-
28512851
/* store transaction information of xact deleting the tuple */
28522852
tp.t_data->t_infomask &= ~(HEAP_XMAX_BITS | HEAP_MOVED);
28532853
tp.t_data->t_infomask2 &= ~HEAP_KEYS_UPDATED;

0 commit comments

Comments
 (0)