Skip to content
This repository was archived by the owner on Jun 28, 2023. It is now read-only.

Commit c73d72d

Browse files
authored
bugfix: fix GlobalStatus=9 can't be cleared in DB storage mode (apache#5523)
1 parent 83493d9 commit c73d72d

5 files changed

Lines changed: 10 additions & 4 deletions

File tree

changes/en-us/2.0.0.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ The version is updated as follows:
4949
- [[#5478](https://github.com/seata/seata/pull/5478)] fix finished transaction swallows exception when committing
5050
- [[#5491](https://github.com/seata/seata/pull/5491)] fix method name not print in logs
5151
- [[#5449](https://github.com/seata/seata/pull/5449)] fix Oracle XA transaction reentrant issues
52+
- [[#5523](https://github.com/seata/seata/pull/5523)] fix GlobalStatus=9 can't be cleared in DB storage mode
5253

5354
### optimize:
5455
- [[#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
@@ -47,6 +47,7 @@ Seata 是一款开源的分布式事务解决方案,提供高性能和简单
4747
- [[#5478](https://github.com/seata/seata/pull/5478)] 修复提交事务时事务已完成不抛出异常问题
4848
- [[#5491](https://github.com/seata/seata/pull/5491)] 修复日志中不打印方法名的问题
4949
- [[#5449](https://github.com/seata/seata/pull/5449)] 修复Oracle XA模式 start 重入问题
50+
- [[#5523](https://github.com/seata/seata/pull/5523)] 修复 GlobalStatus=9 在DB存储模式无法清除的问题
5051

5152
### optimize:
5253
- [[#5208](https://github.com/seata/seata/pull/5208)] 优化多次重复获取Throwable#getCause问题

server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -170,8 +170,7 @@ public class DefaultCoordinator extends AbstractTCInboundHandler implements Tran
170170
private final GlobalStatus[] rollbackingStatuses = new GlobalStatus[] {GlobalStatus.TimeoutRollbacking,
171171
GlobalStatus.TimeoutRollbackRetrying, GlobalStatus.RollbackRetrying, GlobalStatus.Rollbacking};
172172

173-
private final GlobalStatus[] retryCommittingStatuses =
174-
new GlobalStatus[] {GlobalStatus.Committing, GlobalStatus.CommitRetrying};
173+
private final GlobalStatus[] retryCommittingStatuses = new GlobalStatus[] {GlobalStatus.Committing, GlobalStatus.CommitRetrying, GlobalStatus.Committed};
175174

176175
private final ThreadPoolExecutor branchRemoveExecutor;
177176

@@ -411,8 +410,7 @@ protected void handleRetryCommitting() {
411410
SessionHelper.forEach(committingSessions, committingSession -> {
412411
try {
413412
// prevent repeated commit
414-
if (committingSession.getStatus() == GlobalStatus.Committing
415-
&& !committingSession.isDeadSession()) {
413+
if (GlobalStatus.Committing.equals(committingSession.getStatus()) && !committingSession.isDeadSession()) {
416414
// The function of this 'return' is 'continue'.
417415
return;
418416
}
@@ -424,6 +422,10 @@ protected void handleRetryCommitting() {
424422
//The function of this 'return' is 'continue'.
425423
return;
426424
}
425+
if (GlobalStatus.Committed.equals(committingSession.getStatus())
426+
&& committingSession.getBranchSessions().isEmpty()) {
427+
SessionHelper.endCommitted(committingSession,true);
428+
}
427429
core.doGlobalCommit(committingSession, true);
428430
} catch (TransactionException ex) {
429431
LOGGER.error("Failed to retry committing [{}] {} {}", committingSession.getXid(), ex.getCode(), ex.getMessage());

server/src/main/java/io/seata/server/session/GlobalSession.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -246,6 +246,7 @@ public void close() throws TransactionException {
246246
@Override
247247
public void end() throws TransactionException {
248248
if (GlobalStatus.isTwoPhaseSuccess(status)) {
249+
// TODO: Non AT mode does not need to be unlocked
249250
// Clean locks first
250251
clean();
251252
SessionHolder.getRootSessionManager().onSuccessEnd(this);

server/src/main/java/io/seata/server/session/SessionHelper.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -132,6 +132,7 @@ public static void endCommitted(GlobalSession globalSession, boolean retryGlobal
132132
if (retryGlobal || !DELAY_HANDLE_SESSION) {
133133
long beginTime = System.currentTimeMillis();
134134
boolean retryBranch = globalSession.getStatus() == GlobalStatus.CommitRetrying;
135+
// TODO: If the globalSession status in the database is Committed, don't set status again
135136
globalSession.changeGlobalStatus(GlobalStatus.Committed);
136137
globalSession.end();
137138
if (!DELAY_HANDLE_SESSION) {

0 commit comments

Comments
 (0)