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

Race condition in MongoCluster when using lazy connection to SRV hostname #310

Closed
Obbut opened this issue Jun 28, 2023 · 0 comments · Fixed by #311
Closed

Race condition in MongoCluster when using lazy connection to SRV hostname #310

Obbut opened this issue Jun 28, 2023 · 0 comments · Fixed by #311
Assignees
Labels

Comments

@Obbut
Copy link
Collaborator

Obbut commented Jun 28, 2023

Describe the bug

In MongoCluster, resolving of SRV hostnames is kicked off in .init(lazyConnectingTo:logger:eventLoopGroup:). This happens in asynchronously in a task:

Task {
// Kick off the connection process
try await resolveSettings()
scheduleDiscovery()
}

Because the result of this (which happens in resolveSettings) is not awaited before creating connections, a race condition exists: connections that are lazily created before the hostname resolution is complete, will connect to the wrong hostname.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants