raftstore: allow leader transfer if conf change applied on transferee#17643
raftstore: allow leader transfer if conf change applied on transferee#17643ti-chi-bot[bot] merged 18 commits intotikv:masterfrom
Conversation
|
Hi @hhwyt. Thanks for your PR. I'm waiting for a tikv member to verify that this patch is reasonable to test. If it is, they should reply with Once the patch is verified, the new status will be reflected by the I understand the commands that are listed here. 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 kubernetes/test-infra repository. |
Signed-off-by: hhwyt <hhwyt1@gmail.com>
|
TODO:This issue should be verify with a manual test. |
|
/cc @glorv @Connor1996 @overvenus @LykxSassinator PTAL, thx. |
| "not ready to transfer leader; target peer has an unapplied conf change"; | ||
| "region_id" => self.region_id, | ||
| "store_id" => self.peer.get_store_id(), | ||
| "peer_id" => peer_id, |
There was a problem hiding this comment.
| "peer_id" => peer_id, | |
| "target_peer_id" => peer_id, |
"peer_id" mostly refer to the current peer.
| pd_client.region_leader_must_not_be(region_id, new_peer(3, 3)); | ||
|
|
||
| pd_client.transfer_leader(region_id, new_peer(4, 4), vec![]); | ||
| pd_client.region_leader_must_be(region_id, new_peer(4, 4)); |
There was a problem hiding this comment.
Please also test the scenario that a peer is demoting from voter to learner, and the leader tries to transfer leadership to this peer because leader's apply is block.
There was a problem hiding this comment.
Very helpful comment!
Signed-off-by: hhwyt <hhwyt1@gmail.com>
Signed-off-by: hhwyt <hhwyt1@gmail.com>
| let pending_snapshot = self.is_handling_snapshot() || self.has_pending_snapshot(); | ||
| // shouldn't transfer leader to witness peer or non-witness waiting data | ||
| if self.is_witness() || self.wait_data | ||
| if self.is_witness() || is_learner(&self.peer) || self.wait_data |
There was a problem hiding this comment.
it's checked by ready_to_transfer_leader
There was a problem hiding this comment.
If the leader hasn't applied, the check in ready_to_transfer_leader is based on stale configuration, leading in incorrect result.
Signed-off-by: hhwyt <hhwyt1@gmail.com>
Signed-off-by: hhwyt <hhwyt1@gmail.com>
Signed-off-by: hhwyt <hhwyt1@gmail.com>
Signed-off-by: hhwyt <hhwyt1@gmail.com>
There was a problem hiding this comment.
| "target_applied_index" => index | |
| "transferee_applied_index" => index |
We use the term "transferee" instead of "target".
68e4abd to
a3c3dd9
Compare
|
rest LGTM |
|
In response to a cherrypick label: new pull request created to branch |
close tikv#17363 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
|
In response to a cherrypick label: new pull request created to branch |
close tikv#17363 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
|
In response to a cherrypick label: new pull request created to branch |
|
In response to a cherrypick label: new pull request created to branch |
close tikv#17363 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
|
In response to a cherrypick label: new pull request created to branch |
close tikv#17363 Signed-off-by: ti-chi-bot <ti-community-prow-bot@tidb.io>
…#17643) (#17811) close #17363 Allow leader transfer if conf change applied on transferee. Signed-off-by: hhwyt <hhwyt1@gmail.com> Co-authored-by: hhwyt <hhwyt1@gmail.com> Co-authored-by: ti-chi-bot[bot] <108142056+ti-chi-bot[bot]@users.noreply.github.com> Co-authored-by: Bisheng Huang <hbisheng@gmail.com>
…tikv#17643) close tikv#17363 Allow leader transfer if conf change applied on transferee. Signed-off-by: hhwyt <hhwyt1@gmail.com> Co-authored-by: Bisheng Huang <hbisheng@gmail.com> (cherry picked from commit 5182652) Signed-off-by: hhwyt <hhwyt1@gmail.com>
…tikv#17643) close tikv#17363 Allow leader transfer if conf change applied on transferee. Signed-off-by: hhwyt <hhwyt1@gmail.com> Co-authored-by: Bisheng Huang <hbisheng@gmail.com> (cherry picked from commit 5182652) Signed-off-by: hhwyt <hhwyt1@gmail.com>
…tikv#17643) close tikv#17363 Allow leader transfer if conf change applied on transferee. Signed-off-by: hhwyt <hhwyt1@gmail.com> Co-authored-by: Bisheng Huang <hbisheng@gmail.com> (cherry picked from commit 5182652) Signed-off-by: hhwyt <hhwyt1@gmail.com>
…tikv#17643) close tikv#17363 Allow leader transfer if conf change applied on transferee. Signed-off-by: hhwyt <hhwyt1@gmail.com> Co-authored-by: Bisheng Huang <hbisheng@gmail.com> (cherry picked from commit 5182652) Signed-off-by: hhwyt <hhwyt1@gmail.com>
…tikv#17643) close tikv#17363 Allow leader transfer if conf change applied on transferee. Signed-off-by: hhwyt <hhwyt1@gmail.com> Co-authored-by: Bisheng Huang <hbisheng@gmail.com> (cherry picked from commit 5182652) Signed-off-by: hhwyt <hhwyt1@gmail.com>
What is changed and how it works?
Issue Number: Close #17363
What's Changed:
The purpose of this PR is to address the issue where transfer-leader can be blocked by pending conf-change or other admin commands on the current leader, even though these commands may have already been applied on the transferee. This issue is particularly critical in scenarios where the leader’s I/O operations are hung. Our goal is to ensure swift transfer-leader operations in such situations to maintain region availability.
The transfer-leader operation can be categorized into two scenarios:
ready_to_transfer_leaderfunction.propose_check_epoch->admin_cmd_epoch_lookuplogic. The transfer-leader operation will be blocked if there is a pending conflicting admin command.Scenario 2 is a subset of scenario 1. Therefore, to discuss the impact of transfer-leader, we only need to focus on scenario 1.
From a logical standpoint, transfer-leader can be viewed as an application-layer trigger of an election timeout. The raft-level correctness established in the Raft thesis implies that transfer-leader should not be blocked by any pending admin commands on the leader. So our focus is on ensuring application-level correctness. We must guarantee that the side-effects(e.g., register region-merge tick for region merge) of any admin commands are consistently applied to the new leader (transferee) compared to the old leader, and do not cause any availability issues.
Analysis of transfer-leader meets pending admin commands on the leader, yet applied on the transferee:
on_ready_split_region->maybe_campaign). This prevents the new region from initiating an election until an election timeout occurs, causing availability issues. A potential solution is to use an ExtraMessage to inform the transferee to initiate a new region election after transfer-leader (might be implemented in this PR) with election timeouts serving as a fallback in case lost this message.Finally, we conclude that the transfer-leader can safely proceed even when there are pending admin commands on the leader.
Before fix
After fix
Feel free to modify any part as per your preference!
Related changes
pingcap/docs/pingcap/docs-cn:Check List
Tests
Side effects
Release note