Skip to content

Commit

Permalink
chore: add log for converting region to follower (#5222)
Browse files Browse the repository at this point in the history
* chore: add log for converting region to follower

* chore: apply suggestions from CR
  • Loading branch information
WenyXu authored Dec 25, 2024
1 parent 267941b commit f33b378
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/mito2/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -447,7 +447,26 @@ impl ManifestContext {
pub(crate) fn set_role(&self, next_role: RegionRole, region_id: RegionId) {
match next_role {
RegionRole::Follower => {
self.state.store(RegionRoleState::Follower);
match self.state.fetch_update(|state| {
if !matches!(state, RegionRoleState::Follower) {
Some(RegionRoleState::Follower)
} else {
None
}
}) {
Ok(state) => info!(
"Convert region {} to follower, previous role state: {:?}",
region_id, state
),
Err(state) => {
if state != RegionRoleState::Follower {
warn!(
"Failed to convert region {} to follower, current role state: {:?}",
region_id, state
)
}
}
}
}
RegionRole::Leader => {
match self.state.fetch_update(|state| {
Expand Down

0 comments on commit f33b378

Please sign in to comment.