diff --git a/src/meta-srv/src/error.rs b/src/meta-srv/src/error.rs index bbd93d64e870..5c38156a71f0 100644 --- a/src/meta-srv/src/error.rs +++ b/src/meta-srv/src/error.rs @@ -848,13 +848,6 @@ pub enum Error { #[snafu(source(from(common_config::error::Error, Box::new)))] source: Box, }, - - #[snafu(display("Region: {} leader peer is not found", region_id))] - RegionLeaderNotFound { - #[snafu(implicit)] - location: Location, - region_id: RegionId, - }, } impl Error { @@ -946,8 +939,7 @@ impl ErrorExt for Error { | Error::RegionOpeningRace { .. } | Error::RegionRouteNotFound { .. } | Error::MigrationAbort { .. } - | Error::MigrationRunning { .. } - | Error::RegionLeaderNotFound { .. } => StatusCode::Unexpected, + | Error::MigrationRunning { .. } => StatusCode::Unexpected, Error::TableNotFound { .. } => StatusCode::TableNotFound, Error::SaveClusterInfo { source, .. } | Error::InvalidClusterInfoFormat { source, .. } => source.status_code(), diff --git a/src/meta-srv/src/metasrv/builder.rs b/src/meta-srv/src/metasrv/builder.rs index 9dc538115202..2bbcb656010d 100644 --- a/src/meta-srv/src/metasrv/builder.rs +++ b/src/meta-srv/src/metasrv/builder.rs @@ -36,7 +36,6 @@ use common_meta::state_store::KvStateStore; use common_meta::wal_options_allocator::WalOptionsAllocator; use common_procedure::local::{LocalManager, ManagerConfig}; use common_procedure::ProcedureManagerRef; -use common_telemetry::warn; use snafu::ResultExt; use super::{SelectTarget, FLOW_ID_SEQ}; @@ -313,7 +312,10 @@ impl MetasrvBuilder { region_migration_manager.try_start()?; if !is_remote_wal && options.enable_region_failover { - warn!("Region failover is not supported in the local WAL implementation!"); + return error::UnexpectedSnafu { + violated: "Region failover is not supported in the local WAL implementation!", + } + .fail(); } let (region_failover_handler, region_supervisor_ticker) = diff --git a/src/meta-srv/src/region/failure_detector.rs b/src/meta-srv/src/region/failure_detector.rs index c24cfff5e2a7..e9c574cadd3e 100644 --- a/src/meta-srv/src/region/failure_detector.rs +++ b/src/meta-srv/src/region/failure_detector.rs @@ -70,7 +70,7 @@ impl RegionFailureDetector { /// Removes the specific [PhiAccrualFailureDetector] if exists. pub(crate) fn remove(&self, ident: &Ident) { - let _ = self.detectors.remove(ident); + self.detectors.remove(ident); } /// Removes all [PhiAccrualFailureDetector]s. diff --git a/src/meta-srv/src/region/supervisor.rs b/src/meta-srv/src/region/supervisor.rs index 534731e3e1c0..83b264eaa4ba 100644 --- a/src/meta-srv/src/region/supervisor.rs +++ b/src/meta-srv/src/region/supervisor.rs @@ -61,6 +61,18 @@ impl From<&Stat> for DatanodeHeartbeat { } } +/// `Event` represents various types of events that can be processed by the region supervisor. +/// These events are crucial for managing state transitions and handling specific scenarios +/// in the region lifecycle. +/// +/// Variants: +/// - `Tick`: This event is used to trigger region failure detection periodically. +/// - `HeartbeatArrived`: This event presents the metasrv received [`DatanodeHeartbeat`] from the datanodes. +/// - `Clear`: This event is used to reset the state of the supervisor, typically used +/// when a system-wide reset or reinitialization is needed. +/// - `Dump`: (Available only in test) This event triggers a dump of the +/// current state for debugging purposes. It allows developers to inspect the internal state +/// of the supervisor during tests. pub(crate) enum Event { Tick, HeartbeatArrived(DatanodeHeartbeat), @@ -112,8 +124,8 @@ impl RegionSupervisorTicker { } loop { interval.tick().await; - if let Err(err) = sender.send(Event::Tick).await { - warn!(err; "EventReceiver is dropped, tick loop is stopped"); + if sender.send(Event::Tick).await.is_err() { + info!("EventReceiver is dropped, tick loop is stopped"); break; } } @@ -274,13 +286,7 @@ impl RegionSupervisor { .remove(&(cluster_id, datanode_id, region_id)); } - warn!( - "Detects region failures: {:?}", - regions - .iter() - .map(|(_, datanode, region)| (datanode, region)) - .collect::>() - ); + warn!("Detects region failures: {:?}", regions); for (cluster_id, datanode_id, region_id) in regions { match self.do_failover(cluster_id, datanode_id, region_id).await { Ok(_) => self