-
-
Notifications
You must be signed in to change notification settings - Fork 55
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
balancer: unload duplicate rooms #1131
Conversation
Codecov Report
@@ Coverage Diff @@
## master #1131 +/- ##
===========================================
Coverage 60.4202% 60.4202%
===========================================
Files 115 115
Lines 9280 9280
Branches 1131 1131
===========================================
Hits 5607 5607
Misses 3673 3673 |
2 failed tests on run #678 ↗︎
Details:
client/tests/e2e/component/ShareInvite.cy.ts • 1 failed test • Component - electron
tests/e2e/integration/playback.spec.ts • 1 failed test • E2E - electron
Review all test suite changes for PR #1131 ↗︎ |
|
||
let recv = m2.collect_recv(); | ||
assert_eq!(recv.len(), 1); | ||
assert!(matches!(recv[0], MsgB2M::Unload(B2MUnload { .. }))); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in general what does the exclamation point after certain functions mean?
Couple questions for this line:
- what's stored in recv[0]
- What does the { .. } statement do
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- The exclamation point indicates that the function is actually a macro.
recv
is aVec<MsgB2M>
- The
MsgB2M::Unload(B2MUnload { .. }))
is pattern matching syntax. https://doc.rust-lang.org/book/ch18-03-pattern-syntax.html
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()) | ||
self.unload_room(locator.monolith_id(), metadata.name.clone()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
difference between unload_room() and remove_room()?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
unload_room
sends a message to the monolith that the room should be unloaded
remove_room
modifies BalancerContext
to remove the room from the balancer's state but doesn't send a message.
@@ -343,12 +345,15 @@ impl BalancerContext { | |||
match locator.load_epoch().cmp(&load_epoch) { | |||
std::cmp::Ordering::Less => { | |||
// we already have an older version of this room | |||
self.unload_room(monolith_id, metadata.name.clone()).await?; | |||
return Err(anyhow::anyhow!("room already loaded")); | |||
} | |||
std::cmp::Ordering::Greater => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are rooms ordered by id?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No, this code compares the load_epoch
of the room. Only the room with the lowest load_epoch
should be loaded, as specified in our spec doc.
closes #1130