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
raftstore: make apply before persist compatible with online unsafe recovery #16651
Conversation
[REVIEW NOTIFICATION] This pull request has been approved by:
To complete the pull request process, please ask the reviewers in the list to review by filling The full list of commands accepted by this bot can be found here. Reviewer can indicate their review by submitting an approval review. |
Signed-off-by: glorv <glorvs@163.com>
@@ -1647,6 +1652,26 @@ where | |||
return; | |||
} | |||
|
|||
// apply is ahead of raft, need to force raft commit to applied index. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can you please add a comment that explains under what circumstances, applied index could be larger than last commit?
Signed-off-by: glorv <glorvs@163.com>
@@ -4365,6 +4386,30 @@ where | |||
} | |||
} | |||
|
|||
fn force_compact(&mut self, ctx: &mut ApplyContext<EK>, term: u64, compact_index: u64) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
maybe call it unsafe_force_compact
@@ -4365,6 +4386,30 @@ where | |||
} | |||
} | |||
|
|||
fn force_compact(&mut self, ctx: &mut ApplyContext<EK>, term: u64, compact_index: u64) { | |||
assert_eq!(self.delegate.apply_state.applied_index, compact_index); | |||
if self.delegate.apply_state.get_truncated_state().index != compact_index { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
!=
-> <
?
let raft_engine = self.fsm.peer.get_store().raft_engine(); | ||
let mut batch = raft_engine.log_batch(2); | ||
raft_engine | ||
.gc(self.region_id(), first_index, last_index, &mut batch) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't introduce other io operation in raftstore thread
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After discussing offline, we decide to keep the current code to make the logic simpler. We maybe enhance it in the future if this operation is still a thing.
Signed-off-by: glorv <glorvs@163.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Signed-off-by: glorv <glorvs@163.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
/merge |
@glorv: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
This pull request has been accepted and is ready to merge. Commit hash: 36581b3
|
In response to a cherrypick label: new pull request created to branch |
@glorv: new pull request could not be created: failed to create pull request against tikv/tikv#release-8.1 from head ti-chi-bot:cherry-pick-16651-to-release-8.1: status code 422 not one of [201], body: {"message":"Validation Failed","errors":[{"resource":"PullRequest","code":"custom","message":"A pull request already exists for ti-chi-bot:cherry-pick-16651-to-release-8.1."}],"documentation_url":"https://docs.github.com/rest/pulls/pulls#create-a-pull-request"} In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the ti-community-infra/tichi repository. |
…covery (#16651) (#16801) ref #16717, close #16796 Before enter force-leader, if local applied_index > last_index, first force commit and truncate raft index to applied index. This can ensure the raft state is compatible with apply_state. Signed-off-by: glorv <glorvs@163.com> Co-authored-by: glorv <glorvs@163.com>
What is changed and how it works?
Issue Number: ref #16717, close #16796
The unit test in this pr depends on #16626
What's Changed:
Related changes
pingcap/docs
/pingcap/docs-cn
:Check List
Tests
Side effects
Release note