incubator-seata icon indicating copy to clipboard operation
incubator-seata copied to clipboard

bugfix: TwoPhaseBusinessAction coexist with GlobalTransactional

Open leezongjie opened this issue 1 year ago • 1 comments

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

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

leezongjie avatar Feb 05 '24 06:02 leezongjie

image

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

leezongjie avatar Feb 05 '24 08:02 leezongjie

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).

:exclamation: 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%) :arrow_up:
...r/parser/GlobalTransactionalInterceptorParser.java 28.57% <ø> (ø)
...m/tcc/interceptor/TccActionInterceptorHandler.java 68.85% <100.00%> (+4.44%) :arrow_up:
...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%) :arrow_down:
...api/interceptor/parser/DefaultInterfaceParser.java 63.88% <68.75%> (+13.88%) :arrow_up:
...api/interceptor/NestInterceptorHandlerWrapper.java 0.00% <0.00%> (ø)

... and 8 files with indirect coverage changes

codecov-commenter avatar Feb 28 '24 07:02 codecov-commenter