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: set time threshold for transactions in committing state #3560

Merged
merged 9 commits into from
Mar 10, 2021

Conversation

dmego
Copy link
Contributor

@dmego dmego commented Mar 3, 2021

Ⅰ. Describe what this PR did

当 TC 驱动 RM 提交事务时,如果在 doGlobalCommit 时数据库宕机,异常被捕获,此时会将事务添加到retry 的 sessionMenager 中,等待 retry 定时任务来处理,但是由于数据库宕机,数据库中事务的状态无法被修改,一直保持 Commiting 状态。retry 定时任务将不会处理该状态的事务。

Ⅱ. Does this pull request fix one issue?

fixes #3558

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

参考了 DefaultCoordinator#handleRetryRollbacking 中的实现。
DefaultCoordinator#handleRetryCommitting 中把 committing 状态的全局事务也查出来,然后判断是否是 isDeadSession 。判断依据是 (System.currentTimeMillis() - beginTime) > (2 * 6000);

@caohdgege
Copy link
Contributor

Rollbacking的状态下的事务,如果超过了设定的阈值,会被重试的,这里我觉得应该是只处理Commiting状态

@dmego
Copy link
Contributor Author

dmego commented Mar 4, 2021

@caohdgege 那这块是不就能照 rollbacking 的来写了,同样也设置一个阈值

@caohdgege
Copy link
Contributor

@caohdgege 那这块是不就能照 rollbacking 的来写了,同样也设置一个阈值

如果要仿照rollbacking来写的话,可以参考 DefaultCoordinator#handleRetryRollbacking 中的实现。
把rollbacking状态的全局事务查出来,然后判断是否已经isRollbackingDead了

@dmego dmego changed the title bugfix: save the global session to memory before change to the retry state bugfix: set time threshold for transactions in committing state Mar 4, 2021
@caohdgege
Copy link
Contributor

caohdgege commented Mar 4, 2021

在 changes/ 文件夹下面的两个md中登记一下自己和这个pr

@dmego
Copy link
Contributor Author

dmego commented Mar 4, 2021

@caohdgege OK🙆

@codecov-io
Copy link

codecov-io commented Mar 4, 2021

Codecov Report

Merging #3560 (ca26db1) into develop (88d938a) will decrease coverage by 0.00%.
The diff coverage is 0.00%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3560      +/-   ##
=============================================
- Coverage      51.95%   51.94%   -0.01%     
  Complexity      3481     3481              
=============================================
  Files            637      637              
  Lines          21064    21067       +3     
  Branches        2610     2611       +1     
=============================================
  Hits           10944    10944              
- Misses          9037     9040       +3     
  Partials        1083     1083              
Impacted Files Coverage Δ Complexity Δ
...o/seata/server/coordinator/DefaultCoordinator.java 52.55% <0.00%> (-0.50%) 28.00 <3.00> (ø)
...in/java/io/seata/server/session/GlobalSession.java 82.89% <ø> (ø) 75.00 <0.00> (ø)
...ver/storage/db/session/DataBaseSessionManager.java 36.84% <0.00%> (ø) 12.00 <0.00> (ø)
...ver/storage/redis/session/RedisSessionManager.java 29.82% <0.00%> (ø) 10.00 <0.00> (ø)
...m/datasource/undo/oracle/OracleUndoLogManager.java 9.09% <0.00%> (-0.29%) 1.00% <0.00%> (ø%)
...seata/rm/datasource/undo/AbstractUndoExecutor.java 66.90% <0.00%> (ø) 27.00% <0.00%> (ø%)
.../rm/datasource/undo/mysql/MySQLUndoLogManager.java 68.75% <0.00%> (ø) 6.00% <0.00%> (ø%)

Copy link
Contributor

@caohdgege caohdgege left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@funky-eyes funky-eyes left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@l81893521 l81893521 left a comment

Choose a reason for hiding this comment

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

LGTM

@l81893521 l81893521 merged commit efefd17 into apache:develop Mar 10, 2021
@funky-eyes funky-eyes added this to the 1.5.0 milestone Mar 18, 2021
@dmego dmego deleted the bugfix_3558 branch March 22, 2021 10:51
@dmego dmego restored the bugfix_3558 branch March 22, 2021 10:55
@dmego dmego deleted the bugfix_3558 branch March 22, 2021 11:04
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.

TCC模式下,TC db在二阶段宕机,一段时间后恢复,未提交的全局事务无法重试
5 participants