Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@WangzJi
Copy link
Contributor

@WangzJi WangzJi commented Jun 16, 2025

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

This PR implements a dedicated @SagaTransactional annotation to decouple Saga transaction mode from the TCC-specific @LocalTCC annotation, addressing the semantic confusion in Saga scenarios.

Key Changes:

  1. New @SagaTransactional Annotation

    • Created in saga-annotation module for semantic clarity
    • Designed specifically for Saga transaction participants
    • Supports both interface and implementation class annotation
    • Includes comprehensive JavaDoc with usage examples
  2. Dedicated SagaTransactionalRemotingParser

    • Independent parser handling only @SagaTransactional annotations
    • Registered separately via SPI mechanism
    • Optimized for Saga-specific processing logic
  3. SPI Integration

    • Added META-INF/services/org.apache.seata.integration.tx.api.remoting.RemotingParser
    • Enables automatic discovery and registration of the Saga parser
  4. Enhanced Documentation

    • Detailed usage patterns and best practices
    • Clear migration guidance for existing users
    • Comprehensive API documentation
  5. Backward Compatibility

    • All existing @LocalTCC functionality remains unchanged
    • Both annotations can coexist in the same application
    • Zero breaking changes for existing implementations

Ⅱ. Does this pull request fix one issue?

Closes #7439

Ⅲ. Why don't you add test cases (unit test/integration test)?

Ⅳ. Describe how to verify it

  1. Run the test suite:
./mvnw test -Dtest=SagaTransactionalTest,SagaTransactionalRemotingParserTest -pl saga/seata-saga-annotation
  1. Verify backward compatibility:
  • Existing @LocalTCC services continue to work unchanged
  • New services can use @SagaTransactional for better semantic clarity
  • Both annotations can coexist without conflicts

Ⅴ. Special notes for reviews

  1. Backward Compatibility:

    • Maintains 100% compatibility with existing @LocalTCC usage
    • No breaking changes to existing services
  2. Code Quality:

    • All tests pass
    • Follows project coding standards
  3. Documentation:

    • Added clear documentation for @LocalTransactional usage
    • Updated migration guide for existing users

WangzJi added 3 commits June 15, 2025 15:44
…endency-7439' into fix-saga-annotation-localtcc-dependency-7439

# Conflicts:
#	integration-tx-api/src/test/java/org/apache/seata/integration/tx/api/remoting/parser/TransactionParticipantIntegrationTest.java
#	tcc/src/main/java/org/apache/seata/rm/tcc/remoting/parser/LocalTCCRemotingParser.java
#	tcc/src/test/java/org/apache/seata/rm/tcc/remoting/parser/LocalTCCRemotingParserTest.java
#	test/src/test/java/org/apache/seata/saga/annotation/AnnotationConflictTest.java
@codecov
Copy link

codecov bot commented Jun 16, 2025

Codecov Report

❌ Patch coverage is 85.36585% with 6 lines in your changes missing coverage. Please review.
✅ Project coverage is 61.04%. Comparing base (edacdd7) to head (8dd1230).
⚠️ Report is 2 commits behind head on 2.x.

Files with missing lines Patch % Lines
...moting/parser/SagaTransactionalRemotingParser.java 87.50% 2 Missing and 2 partials ⚠️
...rm/tcc/remoting/parser/LocalTCCRemotingParser.java 77.77% 1 Missing and 1 partial ⚠️
Additional details and impacted files
@@             Coverage Diff              @@
##                2.x    #7443      +/-   ##
============================================
- Coverage     61.20%   61.04%   -0.17%     
- Complexity      652      666      +14     
============================================
  Files          1310     1316       +6     
  Lines         49587    49800     +213     
  Branches       5837     5855      +18     
============================================
+ Hits          30349    30398      +49     
- Misses        16526    16694     +168     
+ Partials       2712     2708       -4     
Files with missing lines Coverage Δ
...rm/tcc/remoting/parser/LocalTCCRemotingParser.java 0.00% <ø> (ø)
...rm/tcc/remoting/parser/LocalTCCRemotingParser.java 87.50% <77.77%> (+37.50%) ⬆️
...moting/parser/SagaTransactionalRemotingParser.java 87.50% <87.50%> (ø)

... and 13 files with indirect coverage changes

Impacted file tree graph

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@Retention(RetentionPolicy.RUNTIME)
@Target(ElementType.TYPE)
@Inherited
public @interface TransactionParticipant {
Copy link
Contributor

Choose a reason for hiding this comment

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

Firstly, it is only applied in the TCC and SAGA annotation modes. Secondly, this naming is rather ambiguous and doesn't clearly relate to its functionality.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@funky-eyes, thanks for your review! I'd like to address your concerns:

Regarding " it is only applied in the TCC and SAGA annotation modes":

The annotation aims to solve this limitation by being more generic. Here are the location options:

Option A: Current location common/transaction/api

  • ✅ Generic design - not limited to specific transaction modes
  • ✅ Future extensibility for other transaction patterns
  • ✅ Resolves the scope limitation you mentioned

Option B: More focused location integration-tx-api/annotation

  • ✅ Co-located with other transaction annotations like AspectTransactional
  • ✅ More focused on annotation-based transaction integration
  • ✅ Still maintains proper module dependencies

Regarding the naming:
How about LocalTransactionResource provides clearer semantics than TransactionParticipant:

  • "Local" - clearly indicates it's for local (non-remote) resources
  • "TransactionResource" - directly relates to its functionality
  • Avoids the ambiguity you pointed out

Which approach do you prefer? Or do you have other suggestions for the design?

Copy link
Contributor

Choose a reason for hiding this comment

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

@funky-eyes, thanks for your review! I'd like to address your concerns:

Regarding " it is only applied in the TCC and SAGA annotation modes":

The annotation aims to solve this limitation by being more generic. Here are the location options:

Option A: Current location common/transaction/api

  • ✅ Generic design - not limited to specific transaction modes
  • ✅ Future extensibility for other transaction patterns
  • ✅ Resolves the scope limitation you mentioned

Option B: More focused location integration-tx-api/annotation

  • ✅ Co-located with other transaction annotations like AspectTransactional
  • ✅ More focused on annotation-based transaction integration
  • ✅ Still maintains proper module dependencies

Regarding the naming: How about LocalTransactionResource provides clearer semantics than TransactionParticipant:

  • "Local" - clearly indicates it's for local (non-remote) resources
  • "TransactionResource" - directly relates to its functionality
  • Avoids the ambiguity you pointed out

Which approach do you prefer? Or do you have other suggestions for the design?

Regarding the naming, I lean towards TransactionParticipant instead of LocalTransactionResource. We could enhance TransactionParticipant with a parameter for the transaction mode. This would also allow it to handle more common settings in the future, like AT mode's isolation level. Consequently, configuring the lock retry interval via @GlobalTransaction would become unnecessary, since @GlobalTransaction is primarily for TM, not for RM. This new annotation could also enable local transaction features, like connection reuse until the aspect finishes and a unified commit. Or could it be changed to LocalTransactional? Or SeataLocalTransactional?
@slievrly @xingfudeshi @YongGoose @xjlgod PTAL

Copy link
Member

Choose a reason for hiding this comment

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

If it can also enable local transaction features like a unified commit, I'd cast my vote for LocalTransactional.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@funky-eyes @YongGoose Thanks for the feedback! I've adopted the @LocalTransactional naming as suggested by @YongGoose.

Regarding transaction mode parameters:
@funky-eyes Your suggestion about enhancing with transaction mode parameters and AT isolation levels is excellent for future iterations. For this PR, I focused on the core issue #7439 - removing Saga's semantic dependency on @LocalTCC. The current simple annotation provides a clean foundation that can be enhanced later.
This keeps the current PR focused while leaving room for those valuable enhancements in follow-up work.

Copy link
Contributor

Choose a reason for hiding this comment

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

@funky-eyes @YongGoose Thanks for the feedback! I've adopted the @LocalTransactional naming as suggested by @YongGoose.

Regarding transaction mode parameters: @funky-eyes Your suggestion about enhancing with transaction mode parameters and AT isolation levels is excellent for future iterations. For this PR, I focused on the core issue #7439 - removing Saga's semantic dependency on @LocalTCC. The current simple annotation provides a clean foundation that can be enhanced later. This keeps the current PR focused while leaving room for those valuable enhancements in follow-up work.

I agree with your opinion. However, the name of this annotation may need to be approved by the majority of the community at the next weekly meeting before this PR can be merged.

Copy link
Contributor

Choose a reason for hiding this comment

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

The community's final decision is to separate the Saga annotation mode into a distinct annotation similar to LocalTCC, which will be dedicated exclusively to the Saga annotation mode.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thank you for the clarification!

I understand the community's decision to create a dedicated annotation for Saga mode. I can easily adapt my current @LocalTransactional implementation to create a Saga-specific annotation.

What do you think about @SagaTransactional as the naming?

WangzJi added 6 commits June 20, 2025 22:15
- Add new @LocalTransactional annotation to replace @TransactionParticipant
- Update all test files to use new annotation names
- Fix comments and documentation to reflect naming changes
- Maintain backward compatibility with @LocalTCC
- Add new @LocalTransactional annotation in common module for general transaction participation
- Update LocalTCCRemotingParser to support both @LocalTCC and @LocalTransactional annotations
- Maintain backward compatibility with existing @LocalTCC usage
- Optimize method naming and code structure for better maintainability
- Simplify JavaDoc comments using plain text format
- Fix annotation detection priority: interface annotations take precedence over implementation class annotations

Resolves apache#7439: Remove the dependency of Saga annotations on @LocalTCC
…endency-7439' into fix-saga-annotation-localtcc-dependency-7439
# Conflicts:
#	tcc/src/test/java/org/apache/seata/rm/tcc/remoting/parser/LocalTCCRemotingParserTest.java
@WangzJi
Copy link
Contributor Author

WangzJi commented Jul 2, 2025

Hi all,@funky-eyes @YongGoose @pengten.
Based on community feedback, I propose the following approach for decoupling Saga annotation from TCC:

  1. Create SagaTransactional annotation in saga-annotation module (independent from @LocalTCC)
  2. Implement SagaTransactionalRemotingParser to handle only SagaTransactional
  3. Register parser separately via SPI

Does this approach look good to the community? I'll proceed with implementation once confirmed.
Thanks!

@pengten
Copy link
Contributor

pengten commented Jul 2, 2025

Hi all,@funky-eyes @YongGoose @pengten. Based on community feedback, I propose the following approach for decoupling Saga annotation from TCC:

  1. Create SagaTransactional annotation in saga-annotation module (independent from @LocalTCC)
  2. Implement SagaTransactionalRemotingParser to handle only SagaTransactional
  3. Register parser separately via SPI

Does this approach look good to the community? I'll proceed with implementation once confirmed. Thanks!

Sounds good to me.

WangzJi and others added 2 commits July 3, 2025 15:45
- Add @SagaTransactional annotation in saga-annotation module
- Implement SagaTransactionalRemotingParser for Saga-specific handling
- Register SagaTransactionalRemotingParser via SPI
- Remove dependency on @LocalTCC for Saga scenarios
- Add comprehensive test coverage for new annotation
- Maintain backward compatibility with existing @LocalTCC usage
@funky-eyes funky-eyes added this to the 2.6.0 milestone Aug 15, 2025
@funky-eyes
Copy link
Contributor

Hi all,@funky-eyes @YongGoose @pengten. Based on community feedback, I propose the following approach for decoupling Saga annotation from TCC:

  1. Create SagaTransactional annotation in saga-annotation module (independent from @LocalTCC)
  2. Implement SagaTransactionalRemotingParser to handle only SagaTransactional
  3. Register parser separately via SPI

Does this approach look good to the community? I'll proceed with implementation once confirmed. Thanks!

Hi all,@funky-eyes @YongGoose @pengten. Based on community feedback, I propose the following approach for decoupling Saga annotation from TCC:

  1. Create SagaTransactional annotation in saga-annotation module (independent from @LocalTCC)
  2. Implement SagaTransactionalRemotingParser to handle only SagaTransactional
  3. Register parser separately via SPI

Does this approach look good to the community? I'll proceed with implementation once confirmed. Thanks!

I agree

@funky-eyes funky-eyes requested a review from Copilot September 2, 2025 05:43
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR introduces a dedicated @SagaTransactional annotation to decouple Saga transaction mode from the TCC-specific @LocalTCC annotation, addressing semantic confusion in Saga scenarios while maintaining full backward compatibility.

  • Creates a new @SagaTransactional annotation specifically designed for Saga transaction participants
  • Implements SagaTransactionalRemotingParser to handle the new annotation independently from TCC
  • Adds comprehensive SPI integration for automatic parser discovery and registration

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
SagaTransactional.java New annotation with comprehensive documentation for Saga scenarios
SagaTransactionalRemotingParser.java Dedicated parser handling @SagaTransactional annotations with optimized logic
META-INF/services/RemotingParser SPI registration enabling automatic discovery
LocalTCC.java Enhanced documentation clarifying usage patterns and relationship with Saga
Test files Comprehensive test coverage for new functionality and dual parser integration
Comments suppressed due to low confidence (1)

tcc/src/main/java/org/apache/seata/rm/tcc/api/LocalTCC.java:1

  • The guidance 'Generic transaction participants (non-TCC specific)' under @SagaTransactional usage is confusing since @SagaTransactional is specifically for Saga scenarios, not for generic cases. Consider clarifying this point or removing it to avoid confusion.
/*

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

…s/org.apache.seata.integration.tx.api.remoting.RemotingParser

Co-authored-by: Copilot <[email protected]>
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.

@WangzJi
Copy link
Contributor Author

WangzJi commented Sep 2, 2025

@WangzJi WangzJi changed the title optimize: remove Saga annotation dependency on @LocalTCC optimize: Replace @LocalTCC with @SagaTransactional in the saga annotation pattern Sep 2, 2025
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

@funky-eyes funky-eyes merged commit d859fef into apache:2.x Sep 3, 2025
16 of 18 checks passed
slievrly pushed a commit to slievrly/fescar that referenced this pull request Oct 21, 2025
YvCeung pushed a commit to YvCeung/incubator-seata that referenced this pull request Dec 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Remove the dependency of Saga annotations on @LocalTCC

4 participants