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-v2: support tablet split #13709
Conversation
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
[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: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
//! - todo | ||
//! On Apply Result: | ||
//! - on_ready_split_region: Update the relevant in memory meta info of the | ||
//! parent peer, and wrap and send to the store the relevant info needed to |
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.
//! parent peer, and wrap and send to the store the relevant info needed to | |
//! parent peer, then send to the store the relevant info needed to |
@@ -63,14 +72,23 @@ pub struct SplitResult { | |||
pub derived_index: usize, | |||
pub tablet_index: u64, | |||
} | |||
pub struct SplitInit { | |||
/// Split region | |||
pub region: metapb::Region, |
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.
Why need to be public?
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.
It's accessed in life.rs
ER: RaftEngine, | ||
{ | ||
let region_id = msg.as_ref().region.id; | ||
let mut raft_msg = RaftMessage::default(); |
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.
You can put it into Box directly.
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.
Any difference?
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.
Avoid copy.
// difference is due to v2 only performs read by local reader and | ||
// raftstore is just a place to renew the lease. If the lease in raftstore is | ||
// not expired, it may not renew lease. | ||
self.leader_lease.expire(); |
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.
No, v2 should be the same as v1. expire
is just used to forbid on-going read. All local reader should use the new lease as the epoch change.
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
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.
Overall workflow LGTM
@@ -195,6 +202,7 @@ impl fmt::Debug for StoreMsg { | |||
fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { | |||
match *self { | |||
StoreMsg::RaftMessage(_) => write!(fmt, "Raft Message"), | |||
StoreMsg::SplitInit(_) => write!(fmt, "Peer Creation"), |
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.
Wrong message.
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.
Good catch.
@@ -167,6 +170,9 @@ impl fmt::Debug for PeerMsg { | |||
}, | |||
PeerMsg::ApplyRes(res) => write!(fmt, "ApplyRes {:?}", res), | |||
PeerMsg::Start => write!(fmt, "Startup"), | |||
PeerMsg::SplitInit(_) => { | |||
write!(fmt, "Across peer msg") |
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.
Wrong message.
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.
Good catch.
raft_msg.set_region_epoch(msg.region.get_region_epoch().clone()); | ||
// Set the peer_id be INVALID_ID so that the message will not be sent to the | ||
// peer after the creation. | ||
raft_msg.mut_from_peer().set_id(raft::INVALID_ID); |
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.
Why not just raft_msg.take_from_peer();
?
ctx.router | ||
.force_send(region_id, PeerMsg::SplitInit(msg)) | ||
.unwrap_or_else(|e| { | ||
panic!( |
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.
It's OK to return error. It's possible the peer is destroyed right before force send.
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.
Good catch.
region: &metapb::Region, | ||
key: &[u8], | ||
) -> RaftCmdResponse { | ||
let mut req = RaftCmdRequest::default(); |
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.
Why not router.new_request_for
?
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.
Done
assert!(!resp.get_header().has_error(), "{:?}", resp); | ||
} | ||
|
||
fn must_put_error(store_id: u64, router: &mut TestRouter, region: &metapb::Region, key: &[u8]) { |
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.
Better implement these inline, it's hard to read to jump back and forth.
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.
Done
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
/// | ||
/// This will update the region of the peer, caller must ensure the region | ||
/// has been preserved in a durable device. | ||
pub fn set_region( |
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.
Is this supposed to be put here? Seems only simple getter/setters are placed in this file.
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.
So, which file you think is better?
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.
I don't know really, just a thought.
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
pub fn reset_region_buckets(&mut self) { | ||
if self.region_buckets.is_some() { | ||
self.last_region_buckets = self.region_buckets.take(); | ||
self.region_buckets = None; |
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.
unnecessary.
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.
Good catch.
Signed-off-by: SpadeA-Tang <u6748471@anu.edu.au>
/merge |
@tabokie: 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. 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: 2bc0a98
|
What is changed and how it works?
Issue Number: Ref #12842
What's Changed:
Todo:
Check List
Tests
Release note