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

optimize: optimize transaction context switch logic when transaction mode switching #2307

Merged
merged 12 commits into from
Mar 12, 2020

Conversation

booogu
Copy link
Contributor

@booogu booogu commented Feb 26, 2020

Ⅰ. Describe what this PR did

Optimize transaction context behavior when transaction mode is switched:
1.remove interceptorType context variable.
2.add branchType context variable and use it to distinguish different branch transaction modes.(distinguish TCC Mode and AT Mode)

Ⅱ. Does this pull request fix one issue?

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@booogu booogu changed the title optimize: optimize transaction context behavior when transaction mode… optimize: optimize transaction context switch logic when transaction mode switching Feb 26, 2020
@codecov-io
Copy link

codecov-io commented Feb 26, 2020

Codecov Report

Merging #2307 into develop will increase coverage by 0.04%.
The diff coverage is 48.38%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #2307      +/-   ##
=============================================
+ Coverage      51.78%   51.83%   +0.04%     
- Complexity      2698     2701       +3     
=============================================
  Files            517      517              
  Lines          16767    16776       +9     
  Branches        2034     2033       -1     
=============================================
+ Hits            8683     8695      +12     
+ Misses          7275     7271       -4     
- Partials         809      810       +1     
Impacted Files Coverage Δ Complexity Δ
...c/main/java/io/seata/core/context/RootContext.java 40.00% <0.00%> (+7.39%) 9.00 <0.00> (ø)
...ing/annotation/GlobalTransactionalInterceptor.java 9.45% <0.00%> (-0.13%) 2.00 <0.00> (ø)
...java/io/seata/spring/tcc/TccActionInterceptor.java 13.51% <0.00%> (+0.35%) 2.00 <0.00> (ø)
...java/io/seata/tm/api/GlobalTransactionContext.java 100.00% <ø> (ø) 6.00 <0.00> (ø)
...a/io/seata/rm/datasource/exec/ExecuteTemplate.java 9.37% <16.66%> (+1.96%) 3.00 <2.00> (+1.00)
...in/java/io/seata/tm/api/TransactionalTemplate.java 66.08% <71.42%> (-0.58%) 25.00 <0.00> (+1.00) ⬇️
...java/io/seata/tm/api/DefaultGlobalTransaction.java 75.78% <100.00%> (+1.34%) 22.00 <1.00> (ø)
...a/io/seata/tm/api/transaction/TransactionInfo.java 89.65% <100.00%> (+1.19%) 16.00 <2.00> (+2.00)
...o/seata/server/coordinator/DefaultCoordinator.java 54.35% <0.00%> (-0.52%) 28.00% <0.00%> (-1.00%)
...in/java/io/seata/server/session/GlobalSession.java 84.00% <0.00%> (-0.45%) 72.00% <0.00%> (-1.00%)
... and 1 more

return false;
}

if (RootContext.inGlobalTransaction() && !RootContext.getBranchType().equals(String.valueOf(BranchType.AT.ordinal()))) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Thoughtful point

@zjinlei
Copy link
Contributor

zjinlei commented Mar 6, 2020

@q294881866 PTAL tcc

Copy link
Contributor

@q294881866 q294881866 left a comment

Choose a reason for hiding this comment

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

大部分代码是 tx-xid-interceptor-type 改成了根据 BranchType 来处理,确保新的属性生效即可。

Copy link
Contributor

@zjinlei zjinlei 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.

I remain neutral cause I think when begin transaction need branch type for figure out tcc interceptor problem. Just a little bit wired. But I could not find a better way :).

@zjinlei zjinlei added this to the 1.2.0 milestone Mar 12, 2020
Copy link
Member

@jsbxyyx jsbxyyx left a comment

Choose a reason for hiding this comment

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

LGTM

@zjinlei zjinlei merged commit b1a19a3 into apache:develop Mar 12, 2020
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 added a commit that referenced this pull request Mar 14, 2020
@slievrly slievrly mentioned this pull request Mar 14, 2020
zjinlei pushed a commit that referenced this pull request Mar 15, 2020
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.

7 participants