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

Open
wants to merge 8 commits into
base: 2.x
Choose a base branch
from

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.57%. Comparing base (dbe095a) to head (8332b88).

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.61%   52.57%   -0.05%     
+ Complexity     6579     6563      -16     
============================================
  Files          1126     1124       -2     
  Lines         39928    39893      -35     
  Branches       4680     4674       -6     
============================================
- Hits          21010    20974      -36     
- Misses        16916    16921       +5     
+ Partials       2002     1998       -4     
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 4 files with indirect coverage changes

test/pom.xml Outdated
<dependency>
<groupId>org.apache.seata</groupId>
<artifactId>seata-saga-annotation</artifactId>
<version>2.3.0-SNAPSHOT</version>
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
<version>2.3.0-SNAPSHOT</version>
<version>${project.version}</version>

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok

/**
* 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

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.

2 participants