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: can't post TimeoutRollbacked event #4780
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #4780 +/- ##
==========================================
Coverage 48.62% 48.62%
- Complexity 4052 4053 +1
==========================================
Files 732 732
Lines 25773 25775 +2
Branches 3173 3173
==========================================
+ Hits 12532 12534 +2
+ Misses 11909 11908 -1
- Partials 1332 1333 +1
|
server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.java
Outdated
Show resolved
Hide resolved
…meout_metrics # Conflicts: # changes/en-us/develop.md # changes/zh-cn/develop.md
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
@@ -331,6 +332,8 @@ protected void timeoutCheck() { | |||
|
|||
// transaction timeout and start rollbacking event | |||
MetricsPublisher.postSessionDoingEvent(globalSession, GlobalStatus.TimeoutRollbacking.name(), false, false); | |||
// do rollback | |||
core.doGlobalRollback(globalSession, false); |
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.
timeoutCheck
as mark thread, don't add time-consuming operations to it.
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.
I have moved the operation to 'retryRollbacking' thread and change the status to 'Rollbacking' after the first successful rollback
@@ -180,6 +180,7 @@ public static void endRollbacked(GlobalSession globalSession, boolean retryGloba | |||
beginTime, retryBranch); | |||
} else { | |||
if (SessionStatusValidator.isTimeoutGlobalStatus(globalSession.getStatus())) { | |||
globalSession.changeGlobalStatus(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.
已经是rollbacking status的是否会进这里?如果会是否存在重复修改?
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.
进到这个满足几个条件,retry是false,且stauts是TimeoutRollbacked,TimeoutRollbackFailed,TimeoutRollbacking,TimeoutRollbackRetrying,也就是说,只有因为超时回滚的相关status且非重试才会走到这,只有TimeoutRollbacking的情况下,retry才是false,其他情况下都是true(至少我没发现其他超时相关status且retry是false的情况,DefaultCoordinator的382行做了限制),应该不会存在重复修改
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.
how to remove the globalSession(status=TimeoutRollbacking)?
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.
在SessionHelper的183行,TimeoutRollbacking的session被改成了Rollbacking,2分30秒后被handleRetryCommitting删掉
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.
Is the flow of transaction state reasonable?
TimeoutRollbacking -> Rollbacking Because you want to delete it?
server/src/main/java/io/seata/server/coordinator/DefaultCoordinator.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
} else { | ||
MetricsPublisher.postSessionDoneEvent(globalSession, GlobalStatus.Rollbacked, false, false); | ||
} | ||
MetricsPublisher.postSessionDoneEvent(globalSession, GlobalStatus.Rollbacked, false, false); |
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.
comment: retryGlobal of TimeoutXXX must be true.
if status=TimeoutRollbacked there is no need to print the metric again
if status=TimeoutRollbackFailed will call endRollbackFailed
if status=TimeoutRollbackRetrying will step into https://github.com/seata/seata/pull/4780/files#diff-9a05c8e25f5cbde274749846da97233df30a162a9dd93078d4e41738a948a09eR165
当出现超时回滚时,由timeoutCheck线程把事务状态修改为TimeoutRollbacking,随后由handleRetryRollbacking去处理回滚,而在handleRetryRollbacking中的回滚,retry的值是true,在SessionHelper中,如果是非file模式,在endRollbacked方法中走不到else逻辑,不会发出TimeoutRollbacked事件,且在retryGlobal为true的逻辑中,直接在GlobalSession被remove后发出了AfterRollbacked事件,也没有发出TimeoutRollbacked事件