diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md index 31a412600d8..cdad0716b84 100644 --- a/changes/en-us/develop.md +++ b/changes/en-us/develop.md @@ -11,6 +11,7 @@ Add changes here for all PR submitted to the develop branch. ### bugfix: +- [[#4780](https://github.com/seata/seata/pull/4780)] fix can't post TimeoutRollbacked event after a successful timeout rollback - [[#4954](https://github.com/seata/seata/pull/4954)] fix output expression incorrectly throws npe - [[#4817](https://github.com/seata/seata/pull/4817)] fix in high version springboot property not Standard - [[#4838](https://github.com/seata/seata/pull/4838)] fix when use Statement.executeBatch() can not generate undo log @@ -23,6 +24,7 @@ Add changes here for all PR submitted to the develop branch. - [[#4953](https://github.com/seata/seata/pull/4953)] fix InsertOnDuplicateUpdate bypass modify pk - [[#4978](https://github.com/seata/seata/pull/4978)] fix kryo support circular reference + ### optimize: - [[#4774](https://github.com/seata/seata/pull/4774)] optimize mysql8 dependencies for seataio/seata-server image - [[#4790](https://github.com/seata/seata/pull/4790)] Add a github action to publish Seata to OSSRH @@ -58,6 +60,7 @@ Thanks to these contributors for their code commits. Please report an unintended - [slievrly](https://github.com/slievrly) +- [tuwenlin](https://github.com/tuwenlin) - [lcmvs](https://github.com/lcmvs) - [wangliang181230](https://github.com/wangliang181230) - [a364176773](https://github.com/a364176773) diff --git a/changes/zh-cn/develop.md b/changes/zh-cn/develop.md index 6aa6e8bd69c..7d4d3b68986 100644 --- a/changes/zh-cn/develop.md +++ b/changes/zh-cn/develop.md @@ -11,6 +11,7 @@ ### bugfix: +- [[#4780](https://github.com/seata/seata/pull/4780)] 修复超时回滚成功后无法发送TimeoutRollbacked事件 - [[#4954](https://github.com/seata/seata/pull/4954)] 修复output表达式错误时,保存执行结果空指针异常 - [[#4817](https://github.com/seata/seata/pull/4817)] 修复高版本springboot配置不标准的问题 - [[#4838](https://github.com/seata/seata/pull/4838)] 修复使用 Statement.executeBatch() 时无法生成undo log 的问题 @@ -24,6 +25,7 @@ - [[#4978](https://github.com/seata/seata/pull/4978)] 修复 kryo 支持循环依赖 - [[#4985](https://github.com/seata/seata/pull/4985)] 修复 undo_log id重复的问题 + ### optimize: - [[#4774](https://github.com/seata/seata/pull/4774)] 优化 seataio/seata-server 镜像中的 mysql8 依赖 - [[#4750](https://github.com/seata/seata/pull/4750)] 优化AT分支释放全局锁不使用xid @@ -57,6 +59,7 @@ - [slievrly](https://github.com/slievrly) +- [tuwenlin](https://github.com/tuwenlin) - [lcmvs](https://github.com/lcmvs) - [wangliang181230](https://github.com/wangliang181230) - [a364176773](https://github.com/a364176773) diff --git a/server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java b/server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java index 1cb710d0674..c8625c5e69e 100644 --- a/server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java +++ b/server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java @@ -366,7 +366,7 @@ protected void handleRetryRollbacking() { SessionHelper.forEach(rollbackingSessions, rollbackingSession -> { try { // prevent repeated rollback - if (rollbackingSession.getStatus().equals(GlobalStatus.Rollbacking) + if (rollbackingSession.getStatus() == GlobalStatus.Rollbacking && !rollbackingSession.isDeadSession()) { // The function of this 'return' is 'continue'. return; @@ -410,7 +410,7 @@ protected void handleRetryCommitting() { SessionHelper.forEach(committingSessions, committingSession -> { try { // prevent repeated commit - if (committingSession.getStatus().equals(GlobalStatus.Committing) + if (committingSession.getStatus() == GlobalStatus.Committing && !committingSession.isDeadSession()) { // The function of this 'return' is 'continue'. return; diff --git a/server/src/main/java/io/seata/server/session/SessionHelper.java b/server/src/main/java/io/seata/server/session/SessionHelper.java index 9d144445720..59dc3bb7464 100644 --- a/server/src/main/java/io/seata/server/session/SessionHelper.java +++ b/server/src/main/java/io/seata/server/session/SessionHelper.java @@ -164,26 +164,27 @@ public static void endCommitFailed(GlobalSession globalSession, boolean retryGlo public static void endRollbacked(GlobalSession globalSession, boolean retryGlobal) throws TransactionException { if (retryGlobal || !DELAY_HANDLE_SESSION) { long beginTime = System.currentTimeMillis(); + boolean timeoutDone = false; GlobalStatus currentStatus = globalSession.getStatus(); + if (currentStatus == GlobalStatus.TimeoutRollbacking) { + MetricsPublisher.postSessionDoneEvent(globalSession, GlobalStatus.TimeoutRollbacked, false, false); + timeoutDone = true; + } boolean retryBranch = - currentStatus == GlobalStatus.TimeoutRollbackRetrying || currentStatus == GlobalStatus.RollbackRetrying; + currentStatus == GlobalStatus.TimeoutRollbackRetrying || currentStatus == GlobalStatus.RollbackRetrying; if (SessionStatusValidator.isTimeoutGlobalStatus(currentStatus)) { globalSession.changeGlobalStatus(GlobalStatus.TimeoutRollbacked); } else { globalSession.changeGlobalStatus(GlobalStatus.Rollbacked); } globalSession.end(); - if (!DELAY_HANDLE_SESSION) { + if (!DELAY_HANDLE_SESSION && !timeoutDone) { MetricsPublisher.postSessionDoneEvent(globalSession, false, false); } MetricsPublisher.postSessionDoneEvent(globalSession, IdConstants.STATUS_VALUE_AFTER_ROLLBACKED_KEY, true, - beginTime, retryBranch); + beginTime, retryBranch); } else { - if (SessionStatusValidator.isTimeoutGlobalStatus(globalSession.getStatus())) { - MetricsPublisher.postSessionDoneEvent(globalSession, GlobalStatus.TimeoutRollbacked, false, false); - } else { - MetricsPublisher.postSessionDoneEvent(globalSession, GlobalStatus.Rollbacked, false, false); - } + MetricsPublisher.postSessionDoneEvent(globalSession, GlobalStatus.Rollbacked, false, false); } } diff --git a/server/src/test/java/io/seata/server/coordinator/DefaultCoordinatorTest.java b/server/src/test/java/io/seata/server/coordinator/DefaultCoordinatorTest.java index 5d86fe1250b..39ae7873c02 100644 --- a/server/src/test/java/io/seata/server/coordinator/DefaultCoordinatorTest.java +++ b/server/src/test/java/io/seata/server/coordinator/DefaultCoordinatorTest.java @@ -172,7 +172,7 @@ public void test_handleRetryRollbackingTimeOut() throws TransactionException, In ReflectionUtil.modifyStaticFinalField(defaultCoordinator.getClass(), "MAX_ROLLBACK_RETRY_TIMEOUT", Duration.ofMillis(10)); ReflectionUtil.modifyStaticFinalField(defaultCoordinator.getClass(), "ROLLBACK_RETRY_TIMEOUT_UNLOCK_ENABLE", false); TimeUnit.MILLISECONDS.sleep(100); - defaultCoordinator.timeoutCheck(); + globalSession.queueToRetryRollback(); defaultCoordinator.handleRetryRollbacking(); int lockSize = globalSession.getBranchSessions().get(0).getLockHolder().size(); try { @@ -200,7 +200,7 @@ public void test_handleRetryRollbackingTimeOut_unlock() throws TransactionExcept ReflectionUtil.modifyStaticFinalField(defaultCoordinator.getClass(), "ROLLBACK_RETRY_TIMEOUT_UNLOCK_ENABLE", true); TimeUnit.MILLISECONDS.sleep(100); - defaultCoordinator.timeoutCheck(); + globalSession.queueToRetryRollback(); defaultCoordinator.handleRetryRollbacking(); int lockSize = globalSession.getBranchSessions().get(0).getLockHolder().size();