incubator-seata-go icon indicating copy to clipboard operation
incubator-seata-go copied to clipboard

【WIP】feat: saga's tcc-like mode

Open kaori-seasons opened this issue 1 year ago • 7 comments

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:

  • [x] 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.
  • [x] 2. Added saga annotation CompensationBusinessAction, Add this annotation to the branch transaction service interface or implementation that needs to use the saga mode.
  • [x] 3. Because it is similar to the tcc process, the saga-annotation mode reuses most of the tcc process. Special aspects have been rewritten.
  • [x] 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.
  • [x] 6. Comparing the action information with tcc, the actions of tcc are prepare, commit, rollback, saga is action, compensationAction
  • [x] 7.Improve testing

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


kaori-seasons avatar Jan 24 '24 00:01 kaori-seasons

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

ptyin avatar Jan 24 '24 06:01 ptyin

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

ptyin avatar Jan 24 '24 06:01 ptyin

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.

kaori-seasons avatar Jan 28 '24 03:01 kaori-seasons