修复事务并发bug
This commit is contained in:
@ -427,11 +427,6 @@ static bool UBTreeVisibilityCheckWrap(IndexScanDesc scan, Page page, OffsetNumbe
|
||||
*/
|
||||
TransactionIdStatus UBTreeCheckXid(TransactionId xid)
|
||||
{
|
||||
if (xid == FrozenTransactionId || (TransactionIdIsNormal(xid) &&
|
||||
TransactionIdPrecedes(xid, pg_atomic_read_u64(&g_instance.undo_cxt.globalRecycleXid)) &&
|
||||
!RecoveryInProgress())) {
|
||||
return XID_COMMITTED;
|
||||
}
|
||||
TransactionIdStatus ts = TransactionIdGetStatus(xid);
|
||||
/* Please refer to HeapTupleSatisfiesVaccum */
|
||||
if (ts == XID_INPROGRESS) {
|
||||
|
@ -531,6 +531,7 @@ void UHeapPagePruneFSM(Relation relation, Buffer buffer, TransactionId fxid, Pag
|
||||
static ShortTransactionId UHeapTupleSetModifiedXid(Relation relation,
|
||||
Buffer buffer, UHeapTuple utuple, TransactionId xid)
|
||||
{
|
||||
Assert(!UHEAP_XID_IS_LOCK(utuple->disk_tuple->flag));
|
||||
TransactionId xidbase = InvalidTransactionId;
|
||||
ShortTransactionId tupleXid = 0;
|
||||
UHeapTupleCopyBaseFromPage(utuple, BufferGetPage(buffer));
|
||||
@ -3106,10 +3107,8 @@ check_tup_satisfies_update:
|
||||
/* oldtup should be pointing to right place in page */
|
||||
Assert(oldtup.disk_tuple == (UHeapDiskTuple)UPageGetRowData(page, lp));
|
||||
|
||||
int16 tmpLockInfo = oldtup.disk_tuple->flag & SINGLE_LOCKER_INFOMASK;
|
||||
UHeapTupleHeaderSetTDSlot(oldtup.disk_tuple, oldtupNewTransSlot);
|
||||
oldtup.disk_tuple->flag &= ~UHEAP_VIS_STATUS_MASK;
|
||||
oldtup.disk_tuple->flag |= tmpLockInfo;
|
||||
oldtup.disk_tuple->flag |= infomaskOldTuple;
|
||||
tupleXid = UHeapTupleSetModifiedXid(relation, buffer, &oldtup, fxid);
|
||||
|
||||
@ -3119,6 +3118,7 @@ check_tup_satisfies_update:
|
||||
uheaptup->disk_tuple->flag |= infomaskNewTuple;
|
||||
uheaptup->xc_node_id = u_sess->pgxc_cxt.PGXCNodeIdentifier;
|
||||
if (buffer == newbuf) {
|
||||
Assert(!UHEAP_XID_IS_LOCK(uheaptup->disk_tuple->flag));
|
||||
uheaptup->disk_tuple->flag |= SINGLE_LOCKER_XID_IS_TRANS;
|
||||
UHeapTupleSetRawXid(uheaptup, tupleXid);
|
||||
} else {
|
||||
|
@ -73,6 +73,7 @@ static UHeapTupleStatus UHeapTupleGetStatus(const UHeapTuple utup)
|
||||
return UHEAPTUPLESTATUS_MULTI_LOCKED;
|
||||
} else if ((SINGLE_LOCKER_XID_IS_EXCL_LOCKED(infomask) || SINGLE_LOCKER_XID_IS_SHR_LOCKED(infomask)) &&
|
||||
TransactionIdIsNormal(locker) && !TransactionIdOlderThanFrozenXid(locker)) {
|
||||
Assert(!UHEAP_XID_IS_TRANS(utuple->flag));
|
||||
return UHEAPTUPLESTATUS_LOCKED; // locked by select-for-update or select-for-share
|
||||
} else if (infomask & UHEAP_INPLACE_UPDATED) {
|
||||
return UHEAPTUPLESTATUS_INPLACE_UPDATED; // modified or locked by lock-for-update
|
||||
@ -243,6 +244,7 @@ bool UHeapTupleSatisfiesVisibility(UHeapTuple uhtup, Snapshot snapshot, Buffer b
|
||||
if (utuple != NULL && TransactionIdIsNormal(fxid) && IsMVCCSnapshot(snapshot) &&
|
||||
SINGLE_LOCKER_XID_IS_EXCL_LOCKED(utuple->disk_tuple->flag)) {
|
||||
Assert(UHEAP_XID_IS_EXCL_LOCKED(utuple->disk_tuple->flag));
|
||||
Assert(!UHEAP_XID_IS_TRANS(utuple->disk_tuple->flag));
|
||||
lockerXid = UHeapTupleGetRawXid(utuple);
|
||||
tupleIsExclusivelyLocked = true;
|
||||
}
|
||||
@ -1261,6 +1263,7 @@ TM_Result UHeapTupleSatisfiesUpdate(Relation rel, Snapshot snapshot, ItemPointer
|
||||
UHeapTupleStatus tupleStatus = UHeapTupleGetStatus(utuple);
|
||||
/* tuple is no longer locked by a single locker */
|
||||
if (tupleStatus != UHEAPTUPLESTATUS_LOCKED && SINGLE_LOCKER_XID_IS_EXCL_LOCKED(tupleData->flag)) {
|
||||
Assert(!UHEAP_XID_IS_TRANS(utuple->disk_tuple->flag));
|
||||
UHeapTupleHeaderClearSingleLocker(tupleData);
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user