Skip to content

Commit

Permalink
fix a typo in load epoch check (#1115)
Browse files Browse the repository at this point in the history
  • Loading branch information
dyc3 authored Oct 23, 2023
1 parent ebd43cc commit 1c46815
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions crates/ott-balancer-bin/src/balancer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -340,13 +340,17 @@ impl BalancerContext {
metadata.name, monolith_id, load_epoch
);
if let Some(locator) = self.rooms_to_monoliths.get(&metadata.name) {
if locator.load_epoch() < load_epoch {
// we already have an older version of this room
return Err(anyhow::anyhow!("room already loaded"));
} else if locator.monolith_id() > monolith_id {
// we have an newer version of this room, remove it
self.remove_room(&metadata.name, locator.monolith_id())
.await?;
match locator.load_epoch().cmp(&load_epoch) {
std::cmp::Ordering::Less => {
// we already have an older version of this room
return Err(anyhow::anyhow!("room already loaded"));
}
std::cmp::Ordering::Greater => {
// we have an newer version of this room, remove it
self.remove_room(&metadata.name, locator.monolith_id())
.await?;
}
_ => {}
}
}
let monolith = self.monoliths.get_mut(&monolith_id).unwrap();
Expand Down

0 comments on commit 1c46815

Please sign in to comment.