Skip to content
5 changes: 2 additions & 3 deletions changes/en-us/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@ Add changes here for all PR submitted to the 2.x branch.

### bugfix:

- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] fix XXX

- [[#7480](https://github.com/apache/incubator-seata/pull/7480)] fix failure to enter TimeoutRollbackRetrying state

### optimize:

Expand Down Expand Up @@ -57,7 +56,7 @@ Add changes here for all PR submitted to the 2.x branch.
<!-- 请确保您的 GitHub ID 在以下列表中 -->

- [slievrly](https://github.com/slievrly)
- [GitHubID](https://github.com/GitHubID)
- [simzyoo](https://github.com/simzyoo)


同时,我们收到了社区反馈的很多有价值的issue和建议,非常感谢大家。
5 changes: 2 additions & 3 deletions changes/zh-cn/2.x.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,7 @@

### bugfix:

- [[#PR_NO](https://github.com/seata/seata/pull/PR_NO)] 修复 XXX

- [[#7480](https://github.com/apache/incubator-seata/pull/7480)] 修复无法扭转到TimeoutRollbackRetrying状态

### optimize:

Expand Down Expand Up @@ -55,7 +54,7 @@ Thanks to these contributors for their code commits. Please report an unintended
<!-- Please make sure your Github ID is in the list below -->

- [slievrly](https://github.com/slievrly)
- [GitHubID](https://github.com/GitHubID)
- [simzyoo](https://github.com/simzyoo)


Also, we receive many valuable issues, questions and advices from our community. Thanks for you all.
Original file line number Diff line number Diff line change
Expand Up @@ -470,9 +470,7 @@ public boolean doGlobalRollback(GlobalSession globalSession, boolean retrying) t
"Rollback branch transaction fail and will retry, xid = {} branchId = {}",
globalSession.getXid(),
branchSession.getBranchId());
if (!retrying) {
globalSession.queueToRetryRollback();
}
globalSession.queueToRetryRollback();
return false;
}
} catch (Exception ex) {
Expand All @@ -486,9 +484,7 @@ public boolean doGlobalRollback(GlobalSession globalSession, boolean retrying) t
String.valueOf(retrying),
ex.getMessage()
});
if (!retrying) {
globalSession.queueToRetryRollback();
}
globalSession.queueToRetryRollback();
throw new TransactionException(ex);
}
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,9 @@ public void queueToRetryCommit() throws TransactionException {

public void queueToRetryRollback() throws TransactionException {
GlobalStatus currentStatus = this.getStatus();
if (currentStatus == GlobalStatus.StopRollbackOrRollbackRetry) {
if (currentStatus == GlobalStatus.StopRollbackOrRollbackRetry
|| currentStatus == GlobalStatus.RollbackRetrying
|| currentStatus == GlobalStatus.TimeoutRollbackRetrying) {
return;
}
GlobalStatus newStatus;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -308,6 +308,62 @@ public void doGlobalRollBackRetryableExpTest(String xid) throws Exception {
Assertions.assertEquals(globalSession.getStatus(), GlobalStatus.RollbackRetrying);
}

/**
* Do TimeoutRollbacking test.
*
* @param xid the xid
* @throws Exception the exception
*/
@ParameterizedTest
@MethodSource("xidProvider")
public void doGlobalRollbackTimeoutRollbackingRetryingTest(String xid) throws Exception {
globalSession = SessionHolder.findGlobalSession(xid);
BranchSession branchSession = SessionHelper.newBranchByGlobal(
globalSession, BranchType.AT, resourceId, applicationData, "t1:1", clientId);
globalSession.addBranch(branchSession);
globalSession.changeBranchStatus(branchSession, BranchStatus.Registered);
globalSession.changeGlobalStatus(GlobalStatus.TimeoutRollbacking);
core.mockCore(BranchType.AT, new MockCore(BranchStatus.PhaseTwo_Committed, BranchStatus.Registered));
core.doGlobalRollback(globalSession, true);
Assertions.assertEquals(GlobalStatus.TimeoutRollbackRetrying, globalSession.getStatus());
}

@ParameterizedTest
@MethodSource("xidProvider")
public void doGlobalRollbackExceptionTest(String xid) throws Exception {
globalSession = SessionHolder.findGlobalSession(xid);
BranchSession branchSession = SessionHelper.newBranchByGlobal(
globalSession, BranchType.AT, resourceId, applicationData, "t1:1", clientId);
globalSession.addBranch(branchSession);
globalSession.changeBranchStatus(branchSession, BranchStatus.Registered);
globalSession.changeGlobalStatus(GlobalStatus.TimeoutRollbacking);
// 2. mockCore让branchRollback抛出异常
core.mockCore(BranchType.AT, new AbstractCore(remotingServer) {
@Override
public BranchStatus branchCommit(GlobalSession globalSession, BranchSession branchSession) {
return BranchStatus.PhaseTwo_Committed;
}

@Override
public BranchStatus branchRollback(GlobalSession globalSession, BranchSession branchSession) {
throw new RuntimeException("mock exception for test");
}

@Override
public BranchType getHandleBranchType() {
return BranchType.AT;
}
});

// 3. 断言doGlobalRollback会抛出TransactionException
TransactionException ex = Assertions.assertThrows(TransactionException.class, () -> {
core.doGlobalRollback(globalSession, false);
});
Assertions.assertTrue(ex.getCause() instanceof RuntimeException);
Assertions.assertEquals("mock exception for test", ex.getCause().getMessage());
Assertions.assertEquals(GlobalStatus.TimeoutRollbackRetrying, globalSession.getStatus());
}

/**
* Xid provider object [ ] [ ].
*
Expand Down
Loading