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

feat: saga's tcc-like mode #651

Open
wants to merge 6 commits into
base: feature/saga
Choose a base branch
from

Conversation

kaori-seasons
Copy link
Contributor

@kaori-seasons kaori-seasons commented Jan 24, 2024

BackGround

The seata saga mode will support multiple usage methods in the future.

  1. State machine json: json
  2. Streaming orchestration: saga.task(xxx).build().start()
  3. TCC-like mode

The saga in seata java is implemented based on the state machine.
1) 2) are all implemented based on the state machine engine, 3) can exist independently of the state machine engine. It is completely independent coding of the business and does not require understanding of the state machine process.

The intention of this PR is to support 3) mode

Equivalent to the Saga state machine mode (1), no matter if the user writes a transaction operation, it will always only include ordinary transaction operations based on the transaction type (ServiceTask, choice action)
And compensation transaction operation (compensation), so the tcc-like mode is equivalent to the degraded version of tcc, without the prepare process.
In the first stage, positive/negative transaction operations are directly submitted without waiting. In the second stage, transaction compensation operations will only occur during rollback.

What this PR does:

  • 1. The saga branch transaction is also divided into two phases, similar to tcc. The difference is that when the saga transaction is submitted, the first phase is submitted directly.
    There is no need for two-phase submission, which means that the two-phase commit of tcc is degraded and will only be executed when the transaction needs to be rolled back.
    The second phase compensates the transaction data submitted in the first phase.
  • 2. Added saga annotation CompensationBusinessAction,
    Add this annotation to the branch transaction service interface or implementation that needs to use the saga mode.
  • 3. Because it is similar to the tcc process, the saga-annotation mode reuses most of the tcc process.
    Special aspects have been rewritten.
  • 4. Compared with the state machine, the saga annotation mode does not currently support the forward retry capability.
  • 5. Anti-suspension can be reused with tcc anti-suspension.
  • 6. Comparing the action information with tcc, the actions of tcc are prepare, commit, rollback,
    saga is action, compensationAction
  • 7.Improve testing

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


@ptyin
Copy link
Member

ptyin commented Jan 24, 2024

Have we ever discussed about this feature anywhere? I think we should launch a review meeting to discuss about it.

@ptyin
Copy link
Member

ptyin commented Jan 24, 2024

BTW, code comments should be re-written in English. Plz check.

@kaori-seasons
Copy link
Contributor Author

kaori-seasons commented Jan 28, 2024

Have we ever discussed about this feature anywhere? I think we should launch a review meeting to discuss about it.

@ptyin
Sorry, this is my oversight. This requirement was discussed with @wt-better, but was not recorded in the meeting or issue. I will try my best to take time to prepare for this design discussion at the next weekly meeting to achieve consensus.

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.

2 participants