diff --git a/changes/en-us/develop.md b/changes/en-us/develop.md index 636a07fba5a..ae17be31a24 100644 --- a/changes/en-us/develop.md +++ b/changes/en-us/develop.md @@ -17,6 +17,7 @@ Add changes here for all PR submitted to the develop branch. - [[#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 +- [[#4533](https://github.com/seata/seata/pull/4533)] fix rollback event repeated and some event status not correct - [[#4779](https://github.com/seata/seata/pull/4779)] fix and support Apache Dubbo 3 - [[#4912](https://github.com/seata/seata/pull/4912)] fix mysql InsertOnDuplicateUpdate column case is different and cannot be matched - [[#4543](https://github.com/seata/seata/pull/4543)] fix support Oracle nclob types diff --git a/changes/zh-cn/develop.md b/changes/zh-cn/develop.md index cf3d78867f5..18687d9cf1f 100644 --- a/changes/zh-cn/develop.md +++ b/changes/zh-cn/develop.md @@ -18,6 +18,7 @@ - [[#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 的问题 +- [[#4533](https://github.com/seata/seata/pull/4533)] 修复handleRetryRollbacking的event重复导致的指标数据不准确 - [[#4779](https://github.com/seata/seata/pull/4779)] 修复支持 Apache Dubbo 3 版本 - [[#4912](https://github.com/seata/seata/pull/4912)] 修复mysql InsertOnDuplicateUpdate 列名大小写不一致无法正确匹配 - [[#4543](https://github.com/seata/seata/pull/4543)] 修复对 Oracle 数据类型nclob的支持 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 c8625c5e69e..4c50f19ce50 100644 --- a/server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java +++ b/server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java @@ -379,10 +379,7 @@ protected void handleRetryRollbacking() { SessionHolder.getRetryRollbackingSessionManager().removeGlobalSession(rollbackingSession); LOGGER.error("Global transaction rollback retry timeout and has removed [{}]", rollbackingSession.getXid()); - SessionHelper.endRollbackFailed(rollbackingSession, true); - - // rollback retry timeout event - MetricsPublisher.postSessionDoneEvent(rollbackingSession, GlobalStatus.RollbackRetryTimeout, true, false); + SessionHelper.endRollbackFailed(rollbackingSession, true, true); //The function of this 'return' is 'continue'. return; @@ -421,7 +418,7 @@ protected void handleRetryCommitting() { LOGGER.error("Global transaction commit retry timeout and has removed [{}]", committingSession.getXid()); // commit retry timeout event - MetricsPublisher.postSessionDoneEvent(committingSession, GlobalStatus.CommitRetryTimeout, true, false); + SessionHelper.endCommitFailed(committingSession, true, true); //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 59dc3bb7464..f1c85975a9d 100644 --- a/server/src/main/java/io/seata/server/session/SessionHelper.java +++ b/server/src/main/java/io/seata/server/session/SessionHelper.java @@ -146,7 +146,24 @@ public static void endCommitted(GlobalSession globalSession, boolean retryGlobal * @throws TransactionException the transaction exception */ public static void endCommitFailed(GlobalSession globalSession, boolean retryGlobal) throws TransactionException { - globalSession.changeGlobalStatus(GlobalStatus.CommitFailed); + endCommitFailed(globalSession, retryGlobal, false); + } + + /** + * End commit failed. + * + * @param globalSession the global session + * @param retryGlobal the retry global + * @param isRetryTimeout is retry timeout + * @throws TransactionException the transaction exception + */ + public static void endCommitFailed(GlobalSession globalSession, boolean retryGlobal, boolean isRetryTimeout) + throws TransactionException { + if (isRetryTimeout) { + globalSession.changeGlobalStatus(GlobalStatus.CommitRetryTimeout); + } else { + globalSession.changeGlobalStatus(GlobalStatus.CommitFailed); + } LOGGER.error("The Global session {} has changed the status to {}, need to be handled it manually.", globalSession.getXid(), globalSession.getStatus()); @@ -196,8 +213,22 @@ public static void endRollbacked(GlobalSession globalSession, boolean retryGloba * @throws TransactionException the transaction exception */ public static void endRollbackFailed(GlobalSession globalSession, boolean retryGlobal) throws TransactionException { + endRollbackFailed(globalSession, retryGlobal, false); + } + + /** + * End rollback failed. + * + * @param globalSession the global session + * @param retryGlobal the retry global + * @param isRetryTimeout is retry timeout + * @throws TransactionException the transaction exception + */ + public static void endRollbackFailed(GlobalSession globalSession, boolean retryGlobal, boolean isRetryTimeout) throws TransactionException { GlobalStatus currentStatus = globalSession.getStatus(); - if (SessionStatusValidator.isTimeoutGlobalStatus(currentStatus)) { + if (isRetryTimeout) { + globalSession.changeGlobalStatus(GlobalStatus.RollbackRetryTimeout); + } else if (SessionStatusValidator.isTimeoutGlobalStatus(currentStatus)) { globalSession.changeGlobalStatus(GlobalStatus.TimeoutRollbackFailed); } else { globalSession.changeGlobalStatus(GlobalStatus.RollbackFailed);