diff --git a/src/mito2/src/engine.rs b/src/mito2/src/engine.rs index 62912b8ffb10..c0655eb6905c 100644 --- a/src/mito2/src/engine.rs +++ b/src/mito2/src/engine.rs @@ -462,10 +462,10 @@ impl EngineInner { fn role(&self, region_id: RegionId) -> Option { self.workers.get_region(region_id).map(|region| { - if region.is_writable() { - RegionRole::Leader - } else { + if region.is_readonly() { RegionRole::Follower + } else { + RegionRole::Leader } }) } diff --git a/src/mito2/src/region.rs b/src/mito2/src/region.rs index 086fbef7d02f..e2a4801643a1 100644 --- a/src/mito2/src/region.rs +++ b/src/mito2/src/region.rs @@ -174,6 +174,11 @@ impl MitoRegion { self.manifest_ctx.state.load() == RegionState::Writable } + /// Returns whether the region is readonly. + pub(crate) fn is_readonly(&self) -> bool { + self.manifest_ctx.state.load() == RegionState::ReadOnly + } + /// Returns the state of the region. pub(crate) fn state(&self) -> RegionState { self.manifest_ctx.state.load()