-
Notifications
You must be signed in to change notification settings - Fork 163
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
Connecting to MongDB Atlas seems to take ~40s every time #1112
Comments
Alright looks like the default timeout on trust-dns is 5 seconds and it'll try a bunch of things sequentially. Changing pub(crate) async fn new(config: Option<ResolverConfig>) -> Result<Self> {
let resolver = match config {
Some(config) => {
let mut opts = trust_dns_resolver::config::ResolverOpts::default();
opts.timeout = std::time::Duration::from_millis(100); // the change
trust_dns_resolver::TokioAsyncResolver::tokio(config, opts).map_err(Error::from_resolve_error)?
}
None => trust_dns_resolver::TokioAsyncResolver::tokio_from_system_conf() // need to bypass this since it's using default values
.map_err(Error::from_resolve_error)?,
};
Ok(Self { resolver })
}
} |
Yup, this is unfortunately a known issue in |
Thanks for linking the readme, I couldn't an actual issue for this when looking so it appears its mostly untracked on the mongodb side. Can we work with the trust-dns community to fix this? It seems like it would hamper prototyping and development quite a bit? One of the questions that they had, that I can't answer for them, is where the 8x multiplier comes from. Their timeout is 5 seconds, yet with mongodb its 40s. Additionally, why are we even running into timeout situations. If we feed this information back into trust-dns maybe we can make that crate slightly better for everyone. |
Versions/Environment
cargo pkgid mongodb
&cargo pkgid bson
) 2.8.2, problem persists on main branchdb.version()
) 7.3.2Describe the bug
When using this crate with
mongodb+srv://
makes theClientOptions::parse
function take ~40s. Additionally, when connecting withmongodb://
it connects nearly instantly, but then fails with the following error messages (unclear if related).When connecting through MongoDB Compass it connects near instantly, when connecting through nodejs it connects near instantly.
Digging in with the profiler it's showing something interesting:
Tokio seems to be mostly doing nothing for ~5 seconds in between bursts in which it's trying to do some DNS related activity for ~1ms
Data captured with Superluminal Profiler, red indicates "thread is stalling" and specifically in this case it's in SwapContext (win32)
If we zoom in a bit more we can see there are distinc sections of "nothing" for 5 seconds:
If we zoom in to what's going on inbetween these 5 seconds it becomes a bit clear:
Here we see that we end up in small calls to
trust_dns
. Right now for me it's unclear if this is a problem with trust-dns or if this is related to something this crate is doing. However the fact that nodejs and Compass don't have this behavior definitely seems to indicate that something is going wrong on the Rust side of things.The text was updated successfully, but these errors were encountered: