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

Loop wait if TiKV store is not bootstrapped when detect raftstore version #347

Merged
merged 2 commits into from
Jul 31, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
40 changes: 35 additions & 5 deletions proxy_components/proxy_ffi/src/raftstore_proxy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,11 +141,41 @@ impl RaftStoreProxy {

// We don't use information stored in `GlobalReplicationState` to decouple.
*self.cluster_raftstore_ver.write().unwrap() = RaftstoreVer::Uncertain;
let stores = match self.pd_client.as_ref().unwrap().get_all_stores(false) {
Ok(stores) => stores,
Err(e) => {
tikv_util::info!("get_all_stores error {:?}", e);
return false;
let mut retry_count: u64 = 0;
const RETRY_LIMIT: u64 = 15;
let stores = loop {
match self.pd_client.as_ref().unwrap().get_all_stores(false) {
Ok(stores) => break stores,
Err(e) => {
if retry_count >= RETRY_LIMIT {
tikv_util::error!(
"get_all_stores error {:?} after {}/{} retries, quit",
e,
retry_count,
RETRY_LIMIT
);
return false;
} else {
match e {
pd_client::Error::ClusterNotBootstrapped(_) => {
tikv_util::info!(
"get_all_stores error {:?} after {}/{} retries",
e,
retry_count,
RETRY_LIMIT
);
// For ClusterNotBootstrapped, we should wait for the bootstrap.
std::thread::sleep(std::time::Duration::from_millis(1000))
}
_ => {
// For other error, we don't wait.
tikv_util::error!("get_all_stores error {:?}", e,);
return false;
}
}
}
retry_count += 1
}
}
};

Expand Down
Loading