raftstore: Wait ticks for hibernated peer when doing force leader#12364
raftstore: Wait ticks for hibernated peer when doing force leader#12364ti-chi-bot merged 9 commits intotikv:masterfrom
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. DetailsReviewer can indicate their review by submitting an approval review. |
|
PTAL @v01dstar |
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
23a9a75 to
5ab3918
Compare
| ); | ||
| if *ticks == 0 { | ||
| let s = mem::take(failed_stores); | ||
| self.on_enter_pre_force_leader(s); |
There was a problem hiding this comment.
Instead of calling back on on_enter_pre_force_leader() maybe it looks cleaner if we separate the on_enter_pre_force_leader() into several functions like
SignificantMsg::EnterForceLeaderState => {
self.on_enter_force_leader();
}
fn on_enter_force_leader() {
if state.is_some() {
...
}
if is_leader || (promotable && has_leader){
self.leader_absence_check()
} else {
self.voter_liveness_check()
}
}
fn check_force_leader() {
if leader_absence_check_passes {
self.voter_liveness_check()
}
if voter_liveness_check_passes {
...
}
}
There was a problem hiding this comment.
After waiting ticks, we need to re-check all the conditions in on_enter_pre_force_leader. It may still be the leader due to it doesn't lose the quorum. Reusing is straightforward.
There was a problem hiding this comment.
That's also something we can optimize here, instead of waiting for certain ticks, and then check the leader absence in the on_enter_pre_force_leader(), maybe we can proactively check whether the leader is absent or not in each tick at check_force_leader()?
There was a problem hiding this comment.
Can't. For leader, CheckQuorum needs to wait for a round to see if peers are recent active; for follower, only after an election timeout, it can make sure the leader lease is expired. Anyway, both of them need to wait for some ticks to get the correct information.
67ec4bf to
a41677f
Compare
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
There was a problem hiding this comment.
It would be better if we assert the target region is hibernated here. Something like assert_eq!(is_hibernated(region.get_id()), ture);
There was a problem hiding this comment.
can't, it's not exported
Signed-off-by: Connor1996 <zbk602423539@gmail.com>
9be6b92 to
94449b7
Compare
|
@v01dstar: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments. DetailsIn 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. |
|
/merge |
|
@Connor1996: It seems you want to merge this PR, I will help you trigger all the tests: /run-all-tests You only need to trigger If you have any questions about the PR merge process, please refer to pr process. DetailsInstructions 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. DetailsCommit hash: 94449b7 |
|
@Connor1996: Your PR was out of date, I have automatically updated it for you. At the same time I will also trigger all tests for you: /run-all-tests If the CI test fails, you just re-trigger the test that failed and the bot will merge the PR for you after the CI passes. DetailsInstructions 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. |
…kv#12364) ref tikv#10483 Force leader is rejected on a peer who is already a leader. For the hibernated leader, it doesn't step down to follower when quorum is missing due to not ticking election. So wait ticks in force leader process for hibernated peers to make sure election ticking is performed. Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
…kv#12364) ref tikv#10483 Force leader is rejected on a peer who is already a leader. For the hibernated leader, it doesn't step down to follower when quorum is missing due to not ticking election. So wait ticks in force leader process for hibernated peers to make sure election ticking is performed. Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
* raftstore: Introduce force leader state (tikv#11932) close tikv#6107, ref tikv#10483 Signed-off-by: Connor1996 <zbk602423539@gmail.com> * raftstore: Wait ticks for hibernated peer when doing force leader (tikv#12364) ref tikv#10483 Force leader is rejected on a peer who is already a leader. For the hibernated leader, it doesn't step down to follower when quorum is missing due to not ticking election. So wait ticks in force leader process for hibernated peers to make sure election ticking is performed. Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> * raftstore: Make unsafe recovery wait apply cover snapshot apply cases ref tikv#10483 (tikv#12308) ref tikv#10483 Signed-off-by: v01dstar <yang.zhang@pingcap.com> * raftstore: Execute recovery plan via raft (tikv#12022) Signed-off-by: Connor1996 <zbk602423539@gmail.com> Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io> Co-authored-by: Yang Zhang <yang.zhang@pingcap.com>
What is changed and how it works?
Issue Number: Ref #10483
What's Changed:
Check List
Tests
Release note