-
Notifications
You must be signed in to change notification settings - Fork 8.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
bugfix: global session is always begin in saga mode #5145
Conversation
Codecov Report
📣 This organization is not using Codecov’s GitHub App Integration. We recommend you install it so Codecov can continue to function properly for your repositories. Learn more @@ Coverage Diff @@
## develop #5145 +/- ##
=============================================
- Coverage 48.79% 48.69% -0.11%
- Complexity 4176 4189 +13
=============================================
Files 743 743
Lines 26617 26652 +35
Branches 3327 3330 +3
=============================================
- Hits 12989 12977 -12
- Misses 12225 12280 +55
+ Partials 1403 1395 -8
|
server/src/main/java/io/seata/server/transaction/saga/SagaCore.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM @slievrly
@tuwenlin Pls add change. |
@@ -194,12 +194,12 @@ public boolean doGlobalRollback(GlobalSession globalSession, boolean retrying) t | |||
public void doGlobalReport(GlobalSession globalSession, String xid, GlobalStatus globalStatus) throws TransactionException { | |||
if (GlobalStatus.Committed.equals(globalStatus)) { | |||
SessionHelper.removeAllBranch(globalSession, false); | |||
SessionHelper.endCommitted(globalSession,false); | |||
SessionHelper.endSagaGlobalSession(globalSession, GlobalStatus.Committing); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why Committed -> Committing -> Committed ?
LOGGER.info("Global[{}] committed", globalSession.getXid()); | ||
} else if (GlobalStatus.Rollbacked.equals(globalStatus) | ||
|| GlobalStatus.Finished.equals(globalStatus)) { | ||
SessionHelper.removeAllBranch(globalSession, false); | ||
SessionHelper.endRollbacked(globalSession, false); | ||
SessionHelper.endSagaGlobalSession(globalSession, GlobalStatus.Rollbacking); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same above.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same above.
I decide to end the GlobalSession when tc report Committed or Rollbacked
done |
@@ -201,6 +205,10 @@ public static void endRollbacked(GlobalSession globalSession, boolean retryGloba | |||
MetricsPublisher.postSessionDoneEvent(globalSession, IdConstants.STATUS_VALUE_AFTER_ROLLBACKED_KEY, true, | |||
beginTime, retryBranch); | |||
} else { | |||
if (globalSession.isSaga()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM. This PR satisfies the functional requirements, but the common method to future designs should be decoupled from the transaction mode.
Saga mode can consider switch globalReport to commit/rollback,makes it consistent, reduce the judgment like |
fixes #5045
#5050 can not fix this bug,because in saga mode,when a global transactional end , TM report the global session status to TC rather than do commit or do rollback