Skip to content

Commit

Permalink
fix: correct is_writable behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
WenyXu committed Sep 11, 2024
1 parent f252599 commit 5ed3016
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/mito2/src/engine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -462,10 +462,10 @@ impl EngineInner {

fn role(&self, region_id: RegionId) -> Option<RegionRole> {
self.workers.get_region(region_id).map(|region| {
if region.is_writable() {
RegionRole::Leader
} else {
if region.is_readonly() {
RegionRole::Follower
} else {
RegionRole::Leader
}
})
}
Expand Down
5 changes: 5 additions & 0 deletions src/mito2/src/region.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down

0 comments on commit 5ed3016

Please sign in to comment.