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

feature: TCC mode support idempotent and anti hanging #3545

Merged
merged 21 commits into from
May 23, 2021

Conversation

kaka2code
Copy link
Contributor

@kaka2code kaka2code commented Feb 24, 2021

Ⅰ. Describe what this PR did

tcc support idempotent、anti-hanging and empty-roll-back

Ⅱ. Does this pull request fix one issue?

fixes #3490
fixes #2421

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

实现思路:

新增了一张tcc的状态控制表;

在执行一阶段方法前会在该控制表中新增一条记录,状态为初始化;

在执行二阶段方法时会根据该控制表中状态来决定是否继续执行,并对防悬挂和空回滚的异常请求进行处理;

一二阶段可以通过该表中是否存在相应记录来进行幂等控制;

@funky-eyes
Copy link
Contributor

粗略看了下没有代理数据源,无法保证本地事务和状态控制表的原子性和排他性,无法保证幂等和防悬挂,我们内部在做的也是基于tcc状态表,但是需要让业务的1阶段和2阶段的本地事务和seata做tcc幂等和防悬挂的sql处于一个本地事务中

@caohdgege
Copy link
Contributor

是否方便加个钉钉群沟通一下?
image

@funky-eyes
Copy link
Contributor

connection没有使用与业务同一个connection,如何保证本地流程控制表提交后,本地事务也提交,或本地流程控制表提交后,本地事务异常,导致二阶段重试时,发现流程控制表已经更新认为事务已经完成的问题?
根本原因是目前pr的实现无法保证本地事务与防悬挂幂等的connection为一个原子性操作

@codecov-io
Copy link

codecov-io commented Mar 15, 2021

Codecov Report

Merging #3545 (5731155) into develop (2dac3a5) will decrease coverage by 0.72%.
The diff coverage is 1.22%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3545      +/-   ##
=============================================
- Coverage      52.12%   51.39%   -0.73%     
- Complexity      3502     3505       +3     
=============================================
  Files            638      647       +9     
  Lines          21108    21419     +311     
  Branches        2618     2648      +30     
=============================================
+ Hits           11003    11009       +6     
- Misses          9016     9323     +307     
+ Partials        1089     1087       -2     
Impacted Files Coverage Δ Complexity Δ
.../src/main/java/io/seata/common/util/DateUtils.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...src/main/java/io/seata/rm/tcc/TCCFenceHandler.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
tcc/src/main/java/io/seata/rm/tcc/TCCResource.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
.../main/java/io/seata/rm/tcc/TCCResourceManager.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...in/java/io/seata/rm/tcc/config/TCCFenceConfig.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...va/io/seata/rm/tcc/constant/TCCFenceCleanMode.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ava/io/seata/rm/tcc/constant/TCCFenceConstant.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...a/io/seata/rm/tcc/exception/TCCFenceException.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...a/rm/tcc/interceptor/ActionInterceptorHandler.java 22.66% <0.00%> (-2.34%) 7.00 <0.00> (ø)
.../rm/tcc/remoting/parser/DefaultRemotingParser.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
... and 15 more

@funky-eyes funky-eyes added this to the 1.5.0 milestone Apr 12, 2021
@funky-eyes funky-eyes added mode: TCC TCC transaction mode module/tcc tcc module type: feature Category issues or prs related to feature request. first-time contributor first-time contributor labels Apr 12, 2021
@codecov-commenter
Copy link

codecov-commenter commented May 14, 2021

Codecov Report

Merging #3545 (45f07f0) into develop (49b4665) will decrease coverage by 0.49%.
The diff coverage is 1.71%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3545      +/-   ##
=============================================
- Coverage      41.32%   40.82%   -0.50%     
  Complexity      2947     2947              
=============================================
  Files            654      663       +9     
  Lines          21982    22261     +279     
  Branches        2726     2757      +31     
=============================================
+ Hits            9084     9089       +5     
- Misses         12052    12326     +274     
  Partials         846      846              
Impacted Files Coverage Δ Complexity Δ
...ommon/src/main/java/io/seata/common/Constants.java 100.00% <ø> (ø) 1.00 <0.00> (ø)
.../autoconfigure/SeataTCCFenceAutoConfiguration.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ta/spring/boot/autoconfigure/StarterConstants.java 0.00% <ø> (ø) 0.00 <0.00> (ø)
...src/main/java/io/seata/rm/tcc/TCCFenceHandler.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
.../main/java/io/seata/rm/tcc/TCCResourceManager.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...in/java/io/seata/rm/tcc/config/TCCFenceConfig.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...va/io/seata/rm/tcc/constant/TCCFenceCleanMode.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ava/io/seata/rm/tcc/constant/TCCFenceConstant.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...a/io/seata/rm/tcc/exception/TCCFenceException.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...a/rm/tcc/interceptor/ActionInterceptorHandler.java 20.45% <0.00%> (-2.34%) 7.00 <0.00> (ø)
... and 13 more

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

@wangliang181230
Copy link
Contributor

有个疑问:
目前prepareFence方法包含在本地事务内了,当二阶段回滚请求先于一阶段本地事务提交之前先到达了,此时二阶段回滚请求获取不到fence数据,那么如何判断是一阶段未执行完还是一阶段回滚了

@wangliang181230
Copy link
Contributor

有个疑问:
目前prepareFence方法包含在本地事务内了,当二阶段回滚请求先于一阶段本地事务提交之前先到达了,此时二阶段回滚请求获取不到fence数据,那么如何判断是一阶段未执行完还是一阶段回滚了

哦,有for update哦,那没问题。

Copy link
Contributor

@wangliang181230 wangliang181230 left a comment

Choose a reason for hiding this comment

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

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
first-time contributor first-time contributor mode: TCC TCC transaction mode module/tcc tcc module type: feature Category issues or prs related to feature request.
Projects
None yet
8 participants