Skip to content

Race condition bugfix in the dnscache.#6586

Merged
fulmicoton-dd merged 4 commits into
mainfrom
paul.masurel/dnscache-bugfix
Jul 13, 2026
Merged

Race condition bugfix in the dnscache.#6586
fulmicoton-dd merged 4 commits into
mainfrom
paul.masurel/dnscache-bugfix

Conversation

@fulmicoton

Copy link
Copy Markdown
Collaborator

I ended up not using hickory for the cache
in order to support all of the libc subtleties (resolv.conf)

Unfortunately, upon expiration, and until the dns entry is updated, all new connection create triggers a DNS update.

Because our DNS is slightly slow, this was causing a significantly inflated (and confusing) number of DNS calls.

The hickory approach on this was to block all callers.

I am not fond of this solution either: it would synchronize GET for no reason at all, and our TTL is pretty arbitrary. There is no need to pay for DNS latency at all.

This PR chooses to run DNS refresh asynchronously when the TTL is expired and the entry is stale.

I ended up not using hickory for the cache
in order to support all of the libc subtleties (resolv.conf)

Unfortunately, upon expiration, and until the dns entry is updated, all new connection create triggers a DNS update.

Because our DNS is slightly slow, this was causing a significantly inflated (and confusing) number of DNS calls.

The hickory approach on this was to block all callers.

I am not fond of this solution either: it would synchronize GET for no reason at all, and our TTL is pretty arbitrary. There is no need to pay for DNS latency at all.

This PR chooses to run DNS refresh asynchronously when the TTL is expired and the entry is stale.
@fulmicoton fulmicoton requested review from a team as code owners July 9, 2026 22:00
@fulmicoton fulmicoton requested a review from trinity-1686a July 9, 2026 22:00

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

💡 Codex Review

Here are some automated review suggestions for this pull request.

Reviewed commit: f7482d6769

ℹ️ About Codex in GitHub

Codex has been enabled to automatically review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

If Codex has suggestions, it will comment; otherwise it will react with 👍.

When you sign up for Codex through ChatGPT, Codex can also answer questions or update the PR, like "@codex address that feedback".

Comment thread quickwit/quickwit-aws/src/dns.rs
Comment thread quickwit/quickwit-aws/src/dns.rs
tokio::task::spawn(async move {
let Ok(socket_addrs) = tokio::net::lookup_host((host.as_str(), 0)).await else {
quickwit_common::rate_limited_error!(limit_per_min = 10, %host, "failed to refresh DNS");
return;

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

P2 Badge Retry uncached hosts after a failed DNS lookup

When an uncached lookup reaches this error path, should_resolve() has already pushed next_resolve_attempt five seconds into the future while the cached value is still empty. Any application retry during that cooldown therefore does not run lookup_host again and only waits for an update that no task is producing, so a transient first DNS failure can turn several quick retries into guaranteed timeout failures.

Useful? React with 👍 / 👎.

Comment thread quickwit/quickwit-aws/src/dns.rs Outdated
Comment thread quickwit/quickwit-aws/src/dns.rs
Comment thread quickwit/quickwit-aws/src/dns.rs Outdated
@fulmicoton-dd fulmicoton-dd force-pushed the paul.masurel/dnscache-bugfix branch from 3cae4f6 to 1378be6 Compare July 13, 2026 17:13
@fulmicoton-dd fulmicoton-dd merged commit fd4d507 into main Jul 13, 2026
9 checks passed
@fulmicoton-dd fulmicoton-dd deleted the paul.masurel/dnscache-bugfix branch July 13, 2026 18:10
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