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: share TCC's business action context to phase 2 with api #3642

Merged
merged 19 commits into from
May 13, 2021

Conversation

tanzzj
Copy link
Contributor

@tanzzj tanzzj commented Apr 16, 2021

Ⅰ. Describe what this PR did

feature: provide an api to share TCC's business action context to phase 2
新功能: 为TCC二阶段传参提供api接口

主要思路:
在TCC一阶段过程中,提供给用户API接口io.seata.rm.tcc.api.BusinessActionContextUtil#addContext,此接口包装branchReport()方法,TC侧的branchReport接口支持application_data的更新。用户在一阶段过程中可以操控此接口完成分支信息上报(即业务参数上报到TC侧),二阶段再由TC下发给RM完成数据传递。此实现的二阶段参数传递不依赖rm数据源。

主要变更说明:

  1. 增加context传递api接口:io.seata.rm.tcc.api.BusinessActionContextUtil#addContext
  2. TC侧branch report 支持更新app_data (db/redis)
  3. 支持延迟report, 在TwoPhaseBusinessAction中开启isDelayReport后,用户调用(多次)addContext并不会马上进行report,而是在一阶段方法执行完成后统一上报以提高性能
  4. 一阶段businessContext传参使用线程本地变量进行传参,使得一阶段定义更加明确(即一阶段定义时不再需要传入null值的BusinessContext)
    image
    优化为
    image

Ⅱ. Does this pull request fix one issue?

fixes #3150

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

@codecov-commenter
Copy link

codecov-commenter commented Apr 16, 2021

Codecov Report

Merging #3642 (91ffbf9) into develop (965a48d) will decrease coverage by 0.22%.
The diff coverage is 22.58%.

Impacted file tree graph

@@              Coverage Diff              @@
##             develop    #3642      +/-   ##
=============================================
- Coverage      51.56%   51.33%   -0.23%     
- Complexity      3564     3575      +11     
=============================================
  Files            641      645       +4     
  Lines          21624    21798     +174     
  Branches        2710     2738      +28     
=============================================
+ Hits           11150    11190      +40     
- Misses          9342     9470     +128     
- Partials        1132     1138       +6     
Impacted Files Coverage Δ Complexity Δ
...seata/core/store/db/sql/log/MysqlLogStoreSqls.java 88.88% <0.00%> (-11.12%) 7.00 <0.00> (ø)
...eata/core/store/db/sql/log/OracleLogStoreSqls.java 88.88% <0.00%> (-11.12%) 7.00 <0.00> (ø)
.../core/store/db/sql/log/PostgresqlLogStoreSqls.java 88.88% <0.00%> (-11.12%) 7.00 <0.00> (ø)
...ing/boot/autoconfigure/SeataAutoConfiguration.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...ion/scannercheckers/ConfigBeansScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...otation/scannercheckers/PackageScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...tion/scannercheckers/ScopeBeansScannerChecker.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ava/io/seata/rm/tcc/api/BusinessActionContext.java 0.00% <0.00%> (ø) 0.00 <0.00> (ø)
...io/seata/rm/tcc/api/BusinessActionContextUtil.java 0.00% <0.00%> (ø) 0.00 <0.00> (?)
...ta/spring/annotation/GlobalTransactionScanner.java 28.71% <9.67%> (-3.60%) 18.00 <4.00> (+1.00) ⬇️
... and 20 more

@tanzzj tanzzj marked this pull request as ready for review April 16, 2021 16:00
@funky-eyes funky-eyes added this to the 1.5.0 milestone Apr 16, 2021
@funky-eyes funky-eyes added 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. labels Apr 16, 2021
@tanzzj tanzzj changed the title feature: share TCC's business action context to phase 2 feature: share TCC's business action context to phase 2 with api Apr 29, 2021
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 changes 1.5.0md

@wangliang181230
Copy link
Contributor

之前 @slievrly 提到的一个功能点:
@TwoPhaseBusinessAction注解,添加一个boolean isDelayReport() default false属性,用于控制一阶段内容是否在方法结束之后一起上报。

@tanzzj
Copy link
Contributor Author

tanzzj commented May 6, 2021

之前 @slievrly 提到的一个功能点:
@TwoPhaseBusinessAction注解,添加一个boolean isDelayReport() default false属性,用于控制一阶段内容是否在方法结束之后一起上报。

done, PTAL

1. move isDelayReport to BusinessActionContext
2. add a new params to judge whether actionContext has changed or not
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.

1.5.0.md文件里加一下你的PR吧。

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
Development

Successfully merging this pull request may close these issues.

Seata TCC mode value transfer problem
5 participants