Skip to content
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: fix rollback event repeated and some event status not correct #4533

Merged
merged 17 commits into from Oct 31, 2022
Merged
Show file tree
Hide file tree
Changes from 12 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -370,10 +370,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 @@ -412,7 +409,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
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 @@ -191,8 +208,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 (isTimeoutGlobalStatus(currentStatus)) {
if (isRetryTimeout) {
globalSession.changeGlobalStatus(GlobalStatus.RollbackRetryTimeout);
} else if (isTimeoutGlobalStatus(currentStatus)) {
globalSession.changeGlobalStatus(GlobalStatus.TimeoutRollbackFailed);
} else {
globalSession.changeGlobalStatus(GlobalStatus.RollbackFailed);
Expand Down