Skip to content

Comments

Saga end-to-end verification#897

Merged
Code-Fight merged 2 commits intoapache:feature/sagafrom
Code-Fight:feature/saga
Dec 6, 2025
Merged

Saga end-to-end verification#897
Code-Fight merged 2 commits intoapache:feature/sagafrom
Code-Fight:feature/saga

Conversation

@Code-Fight
Copy link
Contributor

What this PR does:

  1. Saga end-to-end verification
  2. bug fix

Which issue(s) this PR fixes:

Fixes #

Special notes for your reviewer:
e2e sample : apache/incubator-seata-go-samples#74
How to use, refer to : https://github.com/apache/incubator-seata-go-samples/pull/74/files#diff-24b8938589c9efcf1440e59602b467825c27716546e285b617d61650cf77486aR18

In addition to the e2e sample I provided, I hope you can perform detailed verification according to your own ideas. If you find any issues, please share with me your test cases and state machine definition diagram. Thank you very much.

除了我提供的e2e sample 希望能按照你的想法进行详细的验证,若发现有问题,请提供给我你的测试例子和状态机定义图,非常感谢

Does this PR introduce a user-facing change?:


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 implements Saga end-to-end verification functionality with comprehensive improvements to the state machine engine, including enhanced branch registration, compensation logic, status decision mechanisms, and extensive test coverage with store-backed persistence.

  • Adds end-to-end Saga state machine verification with DB-backed state logging and transaction management
  • Implements comprehensive compensation logic with proper status reconciliation aligned to Java semantics
  • Enhances branch registration and reporting mechanisms with proper error handling and transaction coordination

Reviewed Changes

Copilot reviewed 78 out of 79 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
pkg/saga/statemachine/store/db/statelog.go Core state logging implementation with enhanced branch registration, compensation status reconciliation, and transaction management
pkg/saga/statemachine/store/db/statelog_test.go Extensive test coverage for state logging with mock configurations and comprehensive scenario validation
pkg/saga/statemachine/engine/pcext/state_router_impl.go Enhanced state routing with improved compensation triggering and stack management logic
pkg/saga/statemachine/engine/config/default_statemachine_config.go Configuration enhancements supporting async operations, store setup, and TC integration
pkg/saga/statemachine/engine/core/process_ctrl_statemachine_engine.go Engine improvements with async support validation and better error handling
Multiple other files Import formatting fixes, license header additions, and minor code organization improvements
Comments suppressed due to low confidence (1)

pkg/saga/statemachine/store/db/statelog.go:1

  • Mixed language comment contains Chinese text that should be translated to English: 'If final status is not SU, normalize to FA and clear compensation status.'
/*

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

"github.com/seata/seata-go/pkg/util/errors"
)

func TestStartAsyncDisabled(t *testing.T) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Can we add some real simple state machine tests here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@Code-Fight Code-Fight merged commit 1503f5f into apache:feature/saga Dec 6, 2025
1 check passed
Code-Fight added a commit to Code-Fight/seata-go that referenced this pull request Dec 14, 2025
Code-Fight added a commit that referenced this pull request Dec 18, 2025
* feature: init saga framework (#635)

init saga framework

* refactor: refactor saga scaffold to break import cycles (#647)

* feature: add serverice task parse in statelang (#650)

* feature: add saga persistence layer (#649)

* feat: add grpc invoker in saga mode (#668)

* feat: add grpc invoker in saga mode

* fix: fix some chores

* feature: add default implementation for StateMachineConfig (#669)

* feature saga :support generate id by Snowflake (#670)

* feature: sequential execution of state machine in Saga (#681)

* feat: add func invoker (#744)

* add func task state

* [to-reply] feature: support saga multi type config (#741)

* added yaml format of statelang related test data

* feature: implement multi type config parser

* adjust statemachine_json_parser to suit config parser

* bugfix: fix the problem of failure to parse "ServiceName"

* adjust statemachine_parser to be compatible with yaml

* add apache License, add some comments, and make some logical adjustments

* update state_machine_new_designer.yaml

* optimize and improve the unit test of config parser

* refactor config parser

* add apache License

* update

* [Refactor] Migrate StateMachineObject to client/config and unify config parsing with koanf (#785)

* optimize saga config reuse

* upd-test

* Modularize SagaConfig into independent configuration structure

* feat: HttpServiceTaskState Support (#769)

* support http invoker for sage engine

* fix comment language

* Feature: Database persistence for seata-go Saga state machine (#794)

* implement state machine repository

* temporary recording

* temporary recording

* temporary storage

* Supplementary test

* feat: Supplement the statelog_repository section in Database persistence for Saga state machine (#800)

* fix: Wrong commit

* feat:add state_log_repository

* fix: conflicts and wrong commit

* fix: delete Remove redundant singleton patterns

* Feature/saga interface optimization (#778)

feature: saga Interface optimization

* refactor: implement pending TODOs in machine status_decision logic (#808)

* refactor: implement pending TODOs in machine status_decision logic

* feat(status-decision): add detailed logs to methods for better debugging

* Feat cel expression (#788)

* implement cel expression

* move sequence expression into a new file

* mv expression factory into a new file

* move expression factory manager into a new file

* implement cel expression factory and add test

* move expression resolver into a new file

* add parse expression struct test

* update

* update go.mod

---------

Co-authored-by: FengZhang <[email protected]>

* change the StateLangStore type (#812)

* Revert "bugfix:Remove issue translation workflow as usthe/[email protected] does not allow issues in apache/incubator-seata-go" (#822)

Revert "bugfix:Remove issue translation workflow as usthe/issues-translate-ac…"

This reverts commit 0184869.

* refactor-engine/core (#838)

* refactor-engine/core

* Decouple the core package

* Feature: finish implementation for StateMachineConfig  (#805)

* finish implementation for StateMachineConfig

* reuse the exiting logic from statemachine_config_parser.go

* add_license&change_cn_to_en&fix_logic

* sort imports & rename struct & change the visbility

* Merge feature/saga into feature/saga-config-selection-and-loading

* fix_conflict_from_expression-pr

* fix_test&Lock-logic_from_invoker.go

* change_method_name

* add-seqGenerator_init

* add-event_bus&event_publiser-init

* add-status_desicion-init & enhence-validate_method

* refactor: move error_expression-about to expr

* fix: stateMachineResources-load

* fix - test

* Optimize the judgment of persistence-related components.

* Optimize the logic of loadconfig and statemachineresource.

* add-store-init

* refactor-engine/core

* Decouple the core package

* Update default_statemachine_config_test.go

---------

Co-authored-by: FengZhang <[email protected]>

* Decouple the transaction from the statelog (#841)

* Decouple the transaction from the statelog

* Decouple the transaction from the statelog

* Decouple the transaction from the statelog

* Resolve Merge Conflicts, Add Persistence Initialization, and Optimize Tests (#847)

* fix-conflict&add-store-component-init&fix-test

* Update process_ctrl_statemachine_engine.go

* Feature/add script manager&actuator (#868)

* add script manager & actuator

* Otto package replaces Goja package

* Resolve the issues raised by Copilot

* add test for vm-pool

* update GetServiceInvoker method

* Implement SagaResource and SagaResourceManager (#855)

* feat : impl SagaResource #843

* feat : impl SagaResource #843

* feat : impl SagaResourceManager #843

* feat : impl SagaResourceManager BranchRollback #843

* feat : impl handler_saga #843

* feat : impl invalid_exception_test #843

* update #843

* update:elegant code #843

* abstracting tm branch registration out to rm and add test #846

* test #846

* add licensed  #846

* replace panic to return #843

* update  #843

* update init and handler_saga  #843

---------

Co-authored-by: FengZhang <[email protected]>

* Support Saga mode config initialization (#871)

* remove redundant logic and methods

Make the loadconfig method only responsible for loading static parameters and remove redundant memory storage

* add the init method and refine other logic

* remove redundant logic and methods

Make the loadconfig method only responsible for loading static parameters and remove redundant memory storage

* add the init method and refine other logic

* update

* upd

---------

Co-authored-by: FengZhang <[email protected]>

* Saga end-to-end verification (#897)

* saga support

* fix bug

* merge code

* format

* fix vet

* fix vet

* fix vet and lincese checker

* fix lincese chekcer

---------

Co-authored-by: wt_better <[email protected]>
Co-authored-by: Xiangkun Yin <[email protected]>
Co-authored-by: Jingliu Xiong <[email protected]>
Co-authored-by: FanOne <[email protected]>
Co-authored-by: marsevilspirit <[email protected]>
Co-authored-by: FinnTew <[email protected]>
Co-authored-by: flypiggy <[email protected]>
Co-authored-by: lxfeng1997 <[email protected]>
Co-authored-by: 1kasa <[email protected]>
Co-authored-by: 深几许 <[email protected]>
Co-authored-by: Wiggins <[email protected]>
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.

3 participants