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

optimize: add saga statelang semantic validation #5928

Merged
merged 7 commits into from
Oct 24, 2023

Conversation

ptyin
Copy link
Member

@ptyin ptyin commented Oct 12, 2023

  • I have registered the PR changes.

Ⅰ. Describe what this PR did

To avoid throwing exception in Saga runtime, I added Saga statelang semantic validation phase. Validation rules include:

  • FiniteTerminationRule: Rule to check if the state machine can terminate in finite time, i.e. if there is an infinite loop.
  • NoRecursiveSubStateMachineRule: Rule to check if all SubStateMachines has no recursive call.
  • StateNameExistsRule: Rule to check if all the state names exist.

Users can add more validation rules using SPI.

Ⅱ. Does this pull request fix one issue?

Related to #5904

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

Ⅳ. Describe how to verify it

Ⅴ. Special notes for reviews

Notes for FiniteTerminationRule: the main idea is to find all cycles in the graph. And if there is a cycle without outgoing flow, it means the state machine can definitely not stop.


FiniteTerminationRule的备注:核心思想是找到图中的所有环。如果有任何一个环没有连向非环的出边,则意味着状态机肯定不能停止。

@codecov
Copy link

codecov bot commented Oct 12, 2023

Codecov Report

Merging #5928 (b7bef33) into 2.x (2626f24) will decrease coverage by 0.82%.
The diff coverage is 85.38%.

❗ Current head b7bef33 differs from pull request most recent head 92cbdf2. Consider uploading reports for the commit 92cbdf2 to get more accurate results

Additional details and impacted files

Impacted file tree graph

@@             Coverage Diff              @@
##                2.x    #5928      +/-   ##
============================================
- Coverage     49.78%   48.96%   -0.82%     
+ Complexity     4545     4524      -21     
============================================
  Files           854      846       -8     
  Lines         29883    28904     -979     
  Branches       3660     3619      -41     
============================================
- Hits          14877    14154     -723     
+ Misses        13516    13275     -241     
+ Partials       1490     1475      -15     
Files Coverage Δ
.../statelang/parser/impl/StateMachineParserImpl.java 67.21% <100.00%> (+7.89%) ⬆️
...ta/saga/statelang/validator/impl/AbstractRule.java 100.00% <100.00%> (ø)
...validator/impl/NoRecursiveSubStateMachineRule.java 100.00% <100.00%> (ø)
.../statelang/validator/impl/StateNameExistsRule.java 100.00% <100.00%> (ø)
...saga/statelang/parser/utils/StateMachineUtils.java 91.66% <91.66%> (ø)
...io/seata/saga/statelang/validator/RuleFactory.java 66.66% <66.66%> (ø)
...aga/statelang/validator/StateMachineValidator.java 81.81% <81.81%> (ø)
.../saga/statelang/validator/ValidationException.java 62.50% <62.50%> (ø)
...tatelang/validator/impl/FiniteTerminationRule.java 83.33% <83.33%> (ø)

... and 35 files with indirect coverage changes

@slievrly slievrly added this to the 2.0.0 milestone Oct 18, 2023
@slievrly slievrly modified the milestones: 2.0.0, Summer Code 2023 Oct 19, 2023
@ptyin ptyin changed the base branch from 2.x to summer-code_sagas October 21, 2023 00:36
Copy link
Member

@slievrly slievrly left a comment

Choose a reason for hiding this comment

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

good job.

1.Rule is implemented by SPI
2. Abstract verification rules
3. Implement common rules

@slievrly
Copy link
Member

@ptyin add change in 2.0.0.md.

@ptyin ptyin changed the base branch from summer-code_sagas to 2.x October 24, 2023 04:25
@ptyin
Copy link
Member Author

ptyin commented Oct 24, 2023

@ptyin add change in 2.0.0.md.

done

@slievrly slievrly merged commit f99a3dd into apache:2.x Oct 24, 2023
7 checks passed
@slievrly slievrly modified the milestones: Summer Code 2023, 2.0.0 Oct 24, 2023
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