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: support saga annotation #6973

Merged
merged 17 commits into from
Dec 1, 2024

Conversation

wt-better
Copy link
Contributor

@wt-better wt-better commented Nov 2, 2024

Support the two-phase transaction of saga annotation.

  1. Saga branch transactions are divided into two phases. Unlike tcc, the first phase is directly submitted without the second phase. It is a degenerate tcc.
  2. Add the annotation CompensationBusinessAction, which needs to be added to the service interface or implementation of the saga mode branch transaction
  3. Compared with the state machine, the saga annotation mode currently does not support the forward retry function.
  4. The saga annotation mode currently does not support the anti-hanging function.

In order to support the above functions, we have also made the following changes/optimizations:

  1. The historical implementation of DefaultResouecePasser will cause a resource to be registered multiple times; in order to avoid excessive abstraction and reduce the complexity of parsing cost, i was removed it.

@wt-better
Copy link
Contributor Author

link: #5300

Changes:

  1. Remove the dependency of saga annotation on tcc. This method is heavy, and tcc has more customized logic, such as tccHook. Independent development is a better solution

  2. Fix the duplication of saga annotation interfacerparser type

  3. Remove DefaultResouecePasser and corresponding implementation to avoid over-abstraction and time-consuming parsing

  4. Resolve conflicts with the latest branch

Copy link

codecov bot commented Nov 2, 2024

Codecov Report

Attention: Patch coverage is 65.09434% with 37 lines in your changes missing coverage. Please review.

Project coverage is 52.77%. Comparing base (70b4fc0) to head (16a7888).
Report is 1 commits behind head on 2.x.

Files with missing lines Patch % Lines
...egration/tx/api/interceptor/ActionContextUtil.java 6.25% 15 Missing ⚠️
...a/org/apache/seata/common/util/ReflectionUtil.java 0.00% 11 Missing ⚠️
...interceptor/parser/TccActionInterceptorParser.java 86.48% 2 Missing and 3 partials ⚠️
...interceptor/parser/TccActionInterceptorParser.java 85.71% 3 Missing and 2 partials ⚠️
...ta/server/transaction/saga/SagaAnnotationCore.java 75.00% 1 Missing ⚠️
Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #6973      +/-   ##
============================================
- Coverage     52.83%   52.77%   -0.06%     
+ Complexity     6659     6636      -23     
============================================
  Files          1128     1126       -2     
  Lines         40142    40107      -35     
  Branches       4705     4699       -6     
============================================
- Hits          21210    21168      -42     
- Misses        16920    16929       +9     
+ Partials       2012     2010       -2     
Files with missing lines Coverage Δ
...n/java/org/apache/seata/core/model/BranchType.java 80.00% <100.00%> (+1.42%) ⬆️
...tion/tx/api/interceptor/InvocationHandlerType.java 100.00% <100.00%> (ø)
...ta/server/transaction/saga/SagaAnnotationCore.java 75.00% <75.00%> (ø)
...interceptor/parser/TccActionInterceptorParser.java 87.50% <86.48%> (-7.96%) ⬇️
...interceptor/parser/TccActionInterceptorParser.java 72.72% <85.71%> (+8.44%) ⬆️
...a/org/apache/seata/common/util/ReflectionUtil.java 69.03% <0.00%> (-4.09%) ⬇️
...egration/tx/api/interceptor/ActionContextUtil.java 30.47% <6.25%> (-3.94%) ⬇️

... and 2 files with indirect coverage changes

test/pom.xml Outdated Show resolved Hide resolved
/**
* The interface saga action.
*/
@LocalTCC
Copy link
Contributor

Choose a reason for hiding this comment

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

为什么还要用@LocalTCC,注解化saga应该跟TCC有明显的类名和注解的区分
Why use @LocalTCC? Annotated saga should be clearly distinguished from TCC by class names and annotations

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Saga annotation is generally used for rpc, localTcc will be parsed into remote bean, for the convenience of testing

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed, use class annotation instead.

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

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
I have checked the seata-samples and it works as expected.

@slievrly slievrly changed the title feature: saga annotation feature: support saga annotation Dec 1, 2024
@slievrly slievrly merged commit db1567c into apache:2.x Dec 1, 2024
7 checks passed
@slievrly slievrly added this to the 2.3.0 milestone Dec 1, 2024
@slievrly slievrly added the mode: SAGA SAGA transaction mode label Dec 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
mode: SAGA SAGA transaction mode
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants