Skip to content

Commit

Permalink
bugfix: can't post TimeoutRollbacked event (#4780)
Browse files Browse the repository at this point in the history
  • Loading branch information
tuwenlin committed Oct 20, 2022
1 parent 7f55c26 commit f56b02c
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 12 deletions.
3 changes: 3 additions & 0 deletions changes/en-us/develop.md
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -58,6 +60,7 @@ Thanks to these contributors for their code commits. Please report an unintended

<!-- Please make sure your Github ID is in the list below -->
- [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)
Expand Down
3 changes: 3 additions & 0 deletions changes/zh-cn/develop.md
Expand Up @@ -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 的问题
Expand All @@ -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
Expand Down Expand Up @@ -57,6 +59,7 @@

<!-- 请确保您的 GitHub ID 在以下列表中 -->
- [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)
Expand Down
Expand Up @@ -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;
Expand Down Expand Up @@ -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;
Expand Down
17 changes: 9 additions & 8 deletions server/src/main/java/io/seata/server/session/SessionHelper.java
Expand Up @@ -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);
}
}

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

0 comments on commit f56b02c

Please sign in to comment.