-
Notifications
You must be signed in to change notification settings - Fork 180
RUST-1047 Ensure TopologyClosedEvent is the last SDAM event emitted #485
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
RUST-1047 Ensure TopologyClosedEvent is the last SDAM event emitted #485
Conversation
@@ -169,21 +173,6 @@ impl Topology { | |||
|
|||
pub(crate) fn close(&self) { | |||
self.common.is_alive.store(false, Ordering::SeqCst); | |||
if let Some(ref handler) = self.common.options.sdam_event_handler { |
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.
This logic was moved to the drop of TopologyState
, so it's guaranteed to come after any work the monitor does because the monitor holds onto a strong reference to the topology (Topology
) while it's performing a heartbeat.
src/is_master.rs
Outdated
/// Execute an isMaster command, emiting events if a reference to the topology and a handler are provided. | ||
/// | ||
/// A strong reference to the topology is used here to ensure it is still in scope and has not yet emitted a | ||
/// `TopologyClosedEvent`. |
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.
We have to pass the Topology
down through this similar to how we were doing it with WeakTopology
before. It's a bit hairy right now, but I imagine this will all become a lot more straightforward and cleaned up once we do the topology refactor.
src/is_master.rs
Outdated
cmap::{Command, Connection}, | ||
error::Result, | ||
event::sdam::{ | ||
}, cmap::{Command, Connection}, error::Result, event::sdam::{ |
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.
Nit: did rustfmt change logic for use clauses? The grouping here looks odd.
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.
Good catch! Based on the way check-rustfmt.sh
was written, files in src
but not in a subdirectory (like is_master.rs
) weren't getting linted for formatting. I've reformated this file and also updated check-rustfmt.sh
to account for these files too.
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.
LGTM!
RUST-1047
This PR fixes a race between server monitoring and topology closing that would occasionally result in heartbeat events being emitted after the final TopologyClosedEvent.