Skip to content

Commit

Permalink
bugfix: fix rollback event repeated and some event status not correct (
Browse files Browse the repository at this point in the history
  • Loading branch information
Bughue authored Oct 31, 2022
1 parent 6d6eb2e commit 84e8756
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 7 deletions.
1 change: 1 addition & 0 deletions changes/en-us/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions changes/zh-cn/develop.md
Original file line number Diff line number Diff line change
Expand Up @@ -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的支持
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
35 changes: 33 additions & 2 deletions server/src/main/java/io/seata/server/session/SessionHelper.java
Original file line number Diff line number Diff line change
Expand Up @@ -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());

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit 84e8756

Please sign in to comment.