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 16 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.60%. Comparing base (34990eb) to head (097dd3a).

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.60%   -0.02%     
+ Complexity     6590     6579      -11     
============================================
  Files          1126     1124       -2     
  Lines         40004    39969      -35     
  Branches       4696     4688       -8     
============================================
- Hits          21050    21024      -26     
+ Misses        16946    16938       -8     
+ Partials       2008     2007       -1     
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 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.

org.apache.seata.saga.rm.SagaAnnotationResourceManager
Copy link
Member

Choose a reason for hiding this comment

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

whether the SPI interface in the compatibility package are no longer supported?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, we hope to upgrade to the Apache package to use the new features. The compatibility package is not a long solution.

Copy link
Contributor Author

@wt-better wt-better Nov 26, 2024

Choose a reason for hiding this comment

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

RegisterResourceParser design is too complex, currently only used in tcc proxy registry, and there are few scenarios for extended use, so it is decide not compatible

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.

5 participants