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 transaction metrics are inaccurate #4662

Merged
merged 16 commits into from Jun 14, 2022
Merged

bugfix: fix rollback transaction metrics are inaccurate #4662

merged 16 commits into from Jun 14, 2022

Conversation

tuwenlin
Copy link
Contributor

@tuwenlin tuwenlin commented Jun 6, 2022

事务回滚的时候,为了防止分支和锁的残留,现状是2分钟后在进行清理,在此期间,事务的状态是Rollbacking,实际上已经回滚成功了,这样在控制台上看起来很奇怪。
另外,在prometheus中,不会统计rollbacked的事务数和TPS
解决方案:新增两个状态:WaitingCommittedFinished表示事务已经提交成功,等待2分钟后清理,为Committed和AfterCommited中间状态,表示事务已经提交成功,在做扫尾工作;WaitingRollbackedFinished,同理,为Rollbacked和AfterRollbacked的中间状态,表示事务已经回滚成功,在做扫尾工作
测试线程组如下:
Jmeter
1.场景1:两个微服务,都执行插入操作,AT模式测试回滚:
修改之前的Prometheus中rollbacked事务数,一直都为0:
修改前prometheus_rollback_count
修改前的Prometheus中rollbacked的TPS,一直为0:
修改前prometheus_rollback_tps
修改前的Prometheus中afterRollbacked的数量正常:
修改前_prometheus_afterrollback_count
修改后的Prometheus中rollbacked事务数,正常:
修改后prometheus_rollback_count
修改后Prometheus中rollbacked的TPS正常,和Jmeter中基本一致:
修改后prometheus_rollback_tps
修改后jemeter_rollback_tps
修改后,从时间可以看出,开始测试后2分钟,rometheus中afterRollbacked的数量正常:
修改后prometheus_afterrollback_count
2.场景2:TCC模式下提交,成功提交的事务修改前和修改后没有变化,不再详细展示

@codecov-commenter
Copy link

codecov-commenter commented Jun 6, 2022

Codecov Report

Merging #4662 (329c52e) into develop (abc1b8b) will increase coverage by 0.17%.
The diff coverage is 0.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #4662      +/-   ##
=============================================
+ Coverage      48.43%   48.61%   +0.17%     
- Complexity      4035     4054      +19     
=============================================
  Files            735      735              
  Lines          25614    25616       +2     
  Branches        3162     3163       +1     
=============================================
+ Hits           12406    12452      +46     
+ Misses         11869    11826      -43     
+ Partials        1339     1338       -1     
Impacted Files Coverage Δ
...in/java/io/seata/server/session/SessionHelper.java 65.62% <0.00%> (-1.40%) ⬇️
...er/src/main/java/io/seata/server/ServerRunner.java 50.00% <0.00%> (ø)
...rage/redis/store/RedisTransactionStoreManager.java 66.85% <0.00%> (+3.68%) ⬆️
...java/io/seata/server/storage/SessionConverter.java 89.09% <0.00%> (+9.09%) ⬆️
...va/io/seata/server/console/vo/GlobalSessionVO.java 55.88% <0.00%> (+33.82%) ⬆️

@@ -135,6 +135,7 @@ public static void endCommitted(GlobalSession globalSession, boolean retryGlobal
beginTime, retryBranch);
} else {
MetricsPublisher.postSessionDoneEvent(globalSession, false, false);
globalSession.changeGlobalStatus(GlobalStatus.WaitingCommittedFinished);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

之所以之前没有加状态的原因1.是因为锁和分支可能残留 2.是为了少二次网络io+磁盘io消耗(changestatus为committed和delete)使二阶段提交/回滚的效率加快,现在加了个新状态是把2带来的好处给去掉了,需要想一下是否有别的方式既可以记录,又可以解决这种情况的

@slievrly
Copy link
Member

@tuwenlin isTimeoutGlobalStatus has been removed into SessionStatusValidator class.

@slievrly slievrly changed the title optimize rollback transaction metrics bugfix: fix rollback transaction metrics are inaccurate Jun 14, 2022
@slievrly slievrly added this to the 1.5.2 milestone Jun 14, 2022
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@slievrly slievrly merged commit 4567b27 into apache:develop Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants