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: TwoPhaseBusinessAction coexist with GlobalTransactional #6331

Merged
merged 8 commits into from
Feb 28, 2024

Conversation

leezongjie
Copy link
Contributor

@leezongjie leezongjie commented Feb 5, 2024

当参与者使用tcc注解@TwoPhaseBusinessAction时,同时添加@GlobalTransactional,比如在使用嵌套事务的场景下,目前2.x从1.x改造完tcc去spring后,无法同时添加两个注解切面。

  1. 本pr修复了该问题,修复方案为遍历所有的InterfaceParser全部做解析,解析完成拿到ProxyInvocationHandler后,根据指定排序组织成一个代理链,执行调用时,按序进入多个切面。
  2. 修复后支持添加多种类型的注解,比如@GlobalTransactional和@TwoPhaseBusinessAction为两类,可以同时添加。@TwoPhaseBusinessAction和saga注解化@CompensationBusinessAction是同一类,只允许添加一种,重复添加时启动阶段报错。
  3. 切面进入顺序,@GlobalTransactional优先@TwoPhaseBusinessAction,即@GlobalTransactional会管理被标准的一阶段事务。

@funky-eyes funky-eyes added this to the 2.1.0 milestone Feb 5, 2024
@funky-eyes funky-eyes added type: bug Category issues or prs related to bug. module/tcc tcc module module/intergration-tx-api intergration-tx-api labels Feb 5, 2024
@funky-eyes funky-eyes changed the title 修复TCC嵌套事务不能同时添加TwoPhaseBusinessAction和GlobalTransactional两个注解的问题 bugfix: TwoPhaseBusinessAction coexist with GlobalTransactional Feb 5, 2024
@leezongjie
Copy link
Contributor Author

image

主要改动:
原parserInterfaceToProxy切面解析部分保持返回一个ProxyInvocationHandler,内部解析过程将会创建ProxyInvocationHandler拦截器链。
支持添加多个拦截器,可以通过{@link ProxyInvocationHandler#order()}指定切面的进入顺序。
不允许加载多个同类型的拦截器,如tcc和saga的二阶段注解不能同时存在,通过{@link ProxyInvocationHandler#type()}指定类型。

# Conflicts:
#	changes/en-us/2.x.md
#	changes/zh-cn/2.x.md
#	integration-tx-api/src/main/java/org/apache/seata/integration/tx/api/interceptor/handler/GlobalTransactionalInterceptorHandler.java
@codecov-commenter
Copy link

codecov-commenter commented Feb 28, 2024

Codecov Report

Attention: Patch coverage is 42.42424% with 19 lines in your changes are missing coverage. Please review.

Project coverage is 52.53%. Comparing base (3c98058) to head (ea2b18a).

❗ Current head ea2b18a differs from pull request most recent head eefd4bb. Consider uploading reports for the commit eefd4bb to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6331      +/-   ##
============================================
+ Coverage     52.40%   52.53%   +0.12%     
- Complexity     5244     5262      +18     
============================================
  Files           924      926       +2     
  Lines         32066    32097      +31     
  Branches       3833     3839       +6     
============================================
+ Hits          16805    16861      +56     
+ Misses        13607    13568      -39     
- Partials       1654     1668      +14     
Files Coverage Δ
...handler/GlobalTransactionalInterceptorHandler.java 30.89% <100.00%> (+0.36%) ⬆️
...r/parser/GlobalTransactionalInterceptorParser.java 28.57% <ø> (ø)
...m/tcc/interceptor/TccActionInterceptorHandler.java 68.85% <100.00%> (+4.44%) ⬆️
...interceptor/parser/TccActionInterceptorParser.java 64.28% <ø> (ø)
...pi/interceptor/handler/ProxyInvocationHandler.java 0.00% <0.00%> (ø)
...ceptor/handler/AbstractProxyInvocationHandler.java 25.00% <0.00%> (-12.50%) ⬇️
...api/interceptor/parser/DefaultInterfaceParser.java 63.88% <68.75%> (+13.88%) ⬆️
...api/interceptor/NestInterceptorHandlerWrapper.java 0.00% <0.00%> (ø)

... and 8 files with indirect coverage changes

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
image
image
image

@funky-eyes funky-eyes merged commit 1939a9f into apache:2.x Feb 28, 2024
5 of 6 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
module/intergration-tx-api intergration-tx-api module/tcc tcc module type: bug Category issues or prs related to bug.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants