Skip to content

Commit

Permalink
chore: apply suggestions from CR
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Jun 25, 2024
1 parent d57668e commit 25eb3c9
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 21 deletions.
10 changes: 1 addition & 9 deletions src/meta-srv/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -848,13 +848,6 @@ pub enum Error {
#[snafu(source(from(common_config::error::Error, Box::new)))]
source: Box<common_config::error::Error>,
},

#[snafu(display("Region: {} leader peer is not found", region_id))]
RegionLeaderNotFound {
#[snafu(implicit)]
location: Location,
region_id: RegionId,
},
}

impl Error {
Expand Down Expand Up @@ -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(),
Expand Down
6 changes: 4 additions & 2 deletions src/meta-srv/src/metasrv/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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};
Expand Down Expand Up @@ -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) =
Expand Down
2 changes: 1 addition & 1 deletion src/meta-srv/src/region/failure_detector.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
24 changes: 15 additions & 9 deletions src/meta-srv/src/region/supervisor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down Expand Up @@ -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;
}
}
Expand Down Expand Up @@ -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::<Vec<_>>()
);
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
Expand Down

0 comments on commit 25eb3c9

Please sign in to comment.