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

Refactor: add defensive check to state machine replies #972

Merged
merged 1 commit into from
Dec 19, 2023

Conversation

drmingdrmer
Copy link
Member

@drmingdrmer drmingdrmer commented Dec 19, 2023

Changelog

Refactor: add defensive check to state machine replies

When implementing the RaftStateMachine::apply method, if the user
fails to return a number of replies that corresponds to the number of
input entries, OpenRaft will panic, often without providing helpful
diagnostic information.

To address this issue, this commit introduces an assertion immediately
after the apply() method returns its replies. This assertion checks
that the quantity of replies is equal to the number of input entries,
ensuring consistency.

Additionally, new test cases focusing on the apply() method have been
added into the test suites provided by OpenRaft, enhancing the
robustness of the implementation.


This change is Reviewable

When implementing the `RaftStateMachine::apply` method, if the user
fails to return a number of replies that corresponds to the number of
input entries, OpenRaft will panic, often without providing helpful
diagnostic information.

To address this issue, this commit introduces an assertion immediately
after the `apply()` method returns its replies. This assertion checks
that the quantity of replies is equal to the number of input entries,
 ensuring consistency.

Additionally, new test cases focusing on the `apply()` method have been
added into the test suites provided by OpenRaft, enhancing the
robustness of the implementation.
Copy link
Member Author

@drmingdrmer drmingdrmer left a comment

Choose a reason for hiding this comment

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

Reviewed 2 of 2 files at r1, all commit messages.
Reviewable status: :shipit: complete! all files reviewed, all discussions resolved (waiting on @ariesdevil and @lichuang)

@drmingdrmer drmingdrmer merged commit aebd390 into databendlabs:main Dec 19, 2023
25 of 26 checks passed
@drmingdrmer drmingdrmer deleted the release-0.9 branch December 19, 2023 01:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant