Skip to content
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-856 Fix race between server selection and server monitoring #460

Merged

Conversation

patrickfreed
Copy link
Contributor

RUST-856

This PR fixes a race between server selection requesting an update to the topology and a monitor subscribing to those requests, which occasionally would result in the min_heartbeat_frequency test failing.

if self.check_server(&topology, &server).await {
topology.notify_topology_changed();
}

let mut topology_check_requests_subscriber =
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My theory is that the following sequence happens:

  • check completes
  • monitor notifies that topology changed
  • operation sleeping in server selection gets notification and quickly fails server selection, requesting another check
  • monitor starts subscribing to request checks, missing the previous one
  • monitor sleeps until heartbeatFrequencyMS is hit

This fixes that by ensuring any requests that come in after the check will be recorded too, hopefully fixing this case.

@patrickfreed patrickfreed marked this pull request as ready for review September 10, 2021 22:31
@patrickfreed patrickfreed merged commit 81f1602 into mongodb:master Sep 13, 2021
awitten1 pushed a commit to awitten1/mongo-rust-driver that referenced this pull request Sep 21, 2021
patrickfreed added a commit to patrickfreed/mongo-rust-driver that referenced this pull request Oct 12, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants