Skip to content

Commit

Permalink
bugfix: When the rollback logic on the TC side returns RollbackFailed…
Browse files Browse the repository at this point in the history
…, the custom FailureHandler is not executed. (apache#5311)
  • Loading branch information
ZhangShiYeChina committed Feb 9, 2023
1 parent eab8c9a commit 55ba4d0
Showing 1 changed file with 23 additions and 3 deletions.
26 changes: 23 additions & 3 deletions tm/src/main/java/io/seata/tm/api/TransactionalTemplate.java
Original file line number Diff line number Diff line change
Expand Up @@ -239,9 +239,29 @@ private void rollbackTransaction(GlobalTransaction tx, Throwable originalExcepti
TransactionalExecutor.Code.RollbackFailure, originalException);
}

// 3.1 Successfully rolled back
throw new TransactionalExecutor.ExecutionException(tx, GlobalStatus.RollbackRetrying.equals(tx.getLocalStatus())
? TransactionalExecutor.Code.RollbackRetrying : TransactionalExecutor.Code.RollbackDone, originalException);
//# fix #5231
TransactionalExecutor.Code code;
switch(tx.getLocalStatus()) {
case RollbackFailed:
case TimeoutRollbackFailed:
code = TransactionalExecutor.Code.RollbackFailure;
break;
case Rollbacking:
case RollbackRetrying:
code = TransactionalExecutor.Code.RollbackRetrying;
break;
case TimeoutRollbacking:
case TimeoutRollbackRetrying:
case TimeoutRollbacked:
case RollbackRetryTimeout:
code = TransactionalExecutor.Code.TimeoutRollback;
break;
case Rollbacked:
default:
code = TransactionalExecutor.Code.RollbackDone;
}
throw new TransactionalExecutor.ExecutionException(tx, code, originalException);

}

private void beginTransaction(TransactionInfo txInfo, GlobalTransaction tx) throws TransactionalExecutor.ExecutionException {
Expand Down

0 comments on commit 55ba4d0

Please sign in to comment.