mirror of
https://github.com/GreptimeTeam/greptimedb.git
synced 2025-12-27 08:29:59 +00:00
fix: determine region role by using is_readonly (#4725)
fix: correct `is_writable` behavior
This commit is contained in:
@@ -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
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -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()
|
||||
|
||||
Reference in New Issue
Block a user