Skip to content

Commit 5aa6c29

Browse files
authored
bugfix: fix transaction timeout on client side not execute hook and failureHandler (#5373)
1 parent a7685fb commit 5aa6c29

3 files changed

Lines changed: 5 additions & 3 deletions

File tree

changes/en-us/2.0.0.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ The version is updated as follows:
4040
- [[#5347](https://github.com/seata/seata/pull/5347)] Fix console print `unauthorized error`
4141
- [[#5355](https://github.com/seata/seata/pull/5355)] fix bug when customizing context-path
4242
- [[#5362](https://github.com/seata/seata/pull/5362)] fix When the rollback logic on the TC side returns RollbackFailed, the custom FailureHandler is not executed
43-
43+
- [[#5372](https://github.com/seata/seata/pull/5372)] fix transaction timeout on client side not execute hook and failureHandler
4444

4545
### optimize:
4646
- [[#5208](https://github.com/seata/seata/pull/5208)] optimize throwable getCause once more

changes/zh-cn/2.0.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
3939
- [[#5347](https://github.com/seata/seata/pull/5347)] 修复控制台打印 `unauthorized error` 问题
4040
- [[#5355](https://github.com/seata/seata/pull/5355)] 修复自定义context-path时的问题
4141
- [[#5362](https://github.com/seata/seata/pull/5362)] 修复当TC端回滚返回RollbackFailed时,自定义FailureHandler的方法未执行
42+
- [[#5372](https://github.com/seata/seata/pull/5372)] 修复客户侧事务提交前超时未执行hook和failureHandler的问题
4243

4344

4445
### optimize:

tm/src/main/java/io/seata/tm/api/TransactionalTemplate.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -202,8 +202,9 @@ private void commitTransaction(GlobalTransaction tx, TransactionInfo txInfo)
202202
throws TransactionalExecutor.ExecutionException, TransactionException {
203203
if (isTimeout(tx.getCreateTime(), txInfo)) {
204204
// business execution timeout
205-
LOGGER.info("TM detected timeout, xid = {}", tx.getXid());
206-
tx.rollback();
205+
Exception exx = new TmTransactionException(TransactionExceptionCode.TransactionTimeout,
206+
String.format("client detected transaction timeout before commit, so change to rollback, xid = %s", tx.getXid()));
207+
rollbackTransaction(tx, exx);
207208
return;
208209
}
209210

0 commit comments

Comments
 (0)