From 0ad8aad161de3bdb985e3b49b22f8df10b105972 Mon Sep 17 00:00:00 2001 From: WenyXu Date: Fri, 29 Dec 2023 03:57:41 +0000 Subject: [PATCH] feat: skip peer available check by default --- src/meta-srv/src/error.rs | 6 +--- .../src/service/admin/region_migration.rs | 30 +++++++++++-------- 2 files changed, 18 insertions(+), 18 deletions(-) diff --git a/src/meta-srv/src/error.rs b/src/meta-srv/src/error.rs index 530fba83aa2e..92d7249e33ca 100644 --- a/src/meta-srv/src/error.rs +++ b/src/meta-srv/src/error.rs @@ -32,9 +32,6 @@ use crate::pubsub::Message; #[snafu(visibility(pub))] #[stack_trace_debug] pub enum Error { - #[snafu(display("The target peer is unavailable temporally: {}", peer_id))] - PeerUnavailable { location: Location, peer_id: u64 }, - #[snafu(display("Another migration procedure is running for region: {}", region_id))] MigrationRunning { location: Location, @@ -653,8 +650,7 @@ impl ErrorExt for Error { | Error::Join { .. } | Error::WeightArray { .. } | Error::NotSetWeightArray { .. } - | Error::Unsupported { .. } - | Error::PeerUnavailable { .. } => StatusCode::Internal, + | Error::Unsupported { .. } => StatusCode::Internal, Error::TableAlreadyExists { .. } => StatusCode::TableAlreadyExists, Error::EmptyKey { .. } | Error::MissingRequiredParameter { .. } diff --git a/src/meta-srv/src/service/admin/region_migration.rs b/src/meta-srv/src/service/admin/region_migration.rs index 79a4caf2d2ec..84891f307380 100644 --- a/src/meta-srv/src/service/admin/region_migration.rs +++ b/src/meta-srv/src/service/admin/region_migration.rs @@ -17,9 +17,10 @@ use std::num::ParseIntError; use std::str::FromStr; use std::sync::Arc; +use common_meta::peer::Peer; use common_meta::ClusterId; use serde::Serialize; -use snafu::{OptionExt, ResultExt}; +use snafu::ResultExt; use store_api::storage::RegionId; use tonic::codegen::http; @@ -110,18 +111,21 @@ impl SubmitRegionMigrationTaskHandler { to_peer_id, } = task; - let from_peer = self.peer_lookup.peer(cluster_id, from_peer_id).context( - error::PeerUnavailableSnafu { - peer_id: from_peer_id, - }, - )?; - - let to_peer = - self.peer_lookup - .peer(cluster_id, to_peer_id) - .context(error::PeerUnavailableSnafu { - peer_id: to_peer_id, - })?; + let from_peer = self + .peer_lookup + .peer(cluster_id, from_peer_id) + .unwrap_or_else(|| Peer { + id: from_peer_id, + addr: String::new(), + }); + + let to_peer = self + .peer_lookup + .peer(cluster_id, to_peer_id) + .unwrap_or_else(|| Peer { + id: to_peer_id, + addr: String::new(), + }); let procedure_id = self .region_migration_manager