【bugfix】 修复主机重启场景,两阶段事务卡住的情况
This commit is contained in:
@ -1019,6 +1019,10 @@ bool SSCanFetchLocalSnapshotTxnRelatedInfo()
|
||||
return false;
|
||||
}
|
||||
|
||||
if (SS_IN_REFORM && t_thrd.role == STARTUP) {
|
||||
return true;
|
||||
}
|
||||
|
||||
if (SS_NORMAL_PRIMARY) {
|
||||
return true;
|
||||
} else if (SS_PERFORMING_SWITCHOVER) {
|
||||
@ -1033,8 +1037,6 @@ bool SSCanFetchLocalSnapshotTxnRelatedInfo()
|
||||
bool snap_available = xmin_info->snapshot_available;
|
||||
SpinLockRelease(&xmin_info->snapshot_available_lock);
|
||||
return snap_available;
|
||||
} else if (SS_STANDBY_FAILOVER && t_thrd.role == STARTUP) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@ -3121,6 +3121,9 @@ TransactionId PrescanPreparedTransactions(TransactionId **xids_p, int *nxids_p)
|
||||
char *buf = NULL;
|
||||
GlobalTransaction gxact = currentStatePtr->prepXacts[i];
|
||||
|
||||
if (!gxact->inredo && SS_PERFORMING_SWITCHOVER) {
|
||||
continue;
|
||||
}
|
||||
Assert(gxact->inredo);
|
||||
|
||||
xid = gxact->xid;
|
||||
@ -3238,6 +3241,10 @@ void RecoverPreparedTransactions(void)
|
||||
TransactionId xid;
|
||||
char *buf = NULL;
|
||||
GlobalTransaction gxact = currentStatePtr->prepXacts[i];
|
||||
|
||||
if (!gxact->inredo && SS_PERFORMING_SWITCHOVER) {
|
||||
continue;
|
||||
}
|
||||
char *bufptr = NULL;
|
||||
TwoPhaseFileHeader *hdr = NULL;
|
||||
TransactionId *subxids = NULL;
|
||||
@ -3698,7 +3705,7 @@ void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
|
||||
|
||||
/* unfortunately we can't check if the lock is held exclusively */
|
||||
Assert(LWLockHeldByMe(TwoPhaseStateMappingPartitionLock(hdr->xid)));
|
||||
Assert(RecoveryInProgress());
|
||||
Assert(RecoveryInProgress() || SS_PERFORMING_SWITCHOVER);
|
||||
|
||||
gid = hdr->gid;
|
||||
|
||||
@ -3708,6 +3715,9 @@ void PrepareRedoAdd(char *buf, XLogRecPtr start_lsn, XLogRecPtr end_lsn)
|
||||
gxact = currentStatePtr->prepXacts[i];
|
||||
|
||||
if (gxact->xid == hdr->xid) {
|
||||
if (!gxact->inredo && SS_PERFORMING_SWITCHOVER) {
|
||||
return;
|
||||
}
|
||||
Assert(gxact->inredo);
|
||||
ereport(LOG, (errmsg("2PC data xid : " XID_FMT " has already existed", gxact->xid)));
|
||||
return;
|
||||
|
||||
Reference in New Issue
Block a user