Skip to content

Commit

Permalink
fix: deregister failure detector in region migration (#4293)
Browse files Browse the repository at this point in the history
* fix: deregister failure detector in region migration

* chore: apply suggestions from CR
  • Loading branch information
WenyXu committed Jul 7, 2024
1 parent a710676 commit 58f991b
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
16 changes: 15 additions & 1 deletion src/meta-srv/src/procedure/region_migration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ impl Context {
/// Notifies the RegionSupervisor to register failure detectors of failed region.
///
/// The original failure detector was removed once the procedure was triggered.
/// Now, we need to register the failure detector for the failed region.
/// Now, we need to register the failure detector for the failed region again.
pub async fn register_failure_detectors(&self) {
let cluster_id = self.persistent_ctx.cluster_id;
let datanode_id = self.persistent_ctx.from_peer.id;
Expand All @@ -256,6 +256,20 @@ impl Context {
.await;
}

/// Notifies the RegionSupervisor to deregister failure detectors.
///
/// The original failure detectors was removed once the procedure was triggered.
/// However, the `from_peer` may still send the heartbeats contains the failed region.
pub async fn deregister_failure_detectors(&self) {
let cluster_id = self.persistent_ctx.cluster_id;
let datanode_id = self.persistent_ctx.from_peer.id;
let region_id = self.persistent_ctx.region_id;

self.region_failure_detector_controller
.deregister_failure_detectors(vec![(cluster_id, datanode_id, region_id)])
.await;
}

/// Removes the `table_route` of [VolatileContext], returns true if any.
pub fn remove_table_route_value(&mut self) -> bool {
let value = self.volatile_ctx.table_route.take();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ impl UpdateMetadata {
};

ctx.remove_table_route_value();
ctx.deregister_failure_detectors().await;
// Consumes the guard.
ctx.volatile_ctx.opening_region_guard.take();

Expand Down

0 comments on commit 58f991b

Please sign in to comment.