Closed Bug 2060788 Opened 3 months ago Closed 3 months ago

Revalidate stale DNS answers in Happy Eyeballs

Categories

(Core :: Networking: HTTP, task, P3)

task

Tracking

()

RESOLVED FIXED
156 Branch
Tracking Status
firefox156 --- fixed

People

(Reporter: mail, Assigned: mail)

References

(Blocks 1 open bug)

Details

(Whiteboard: [necko-triaged])

Attachments

(3 external files)

Firefox already serves DNS answers from a cache entry's grace period (stale-while-revalidate). Teach Happy Eyeballs to notice when an answer was served stale: race it immediately, revalidate with a cache-bypassing lookup, and race the revalidated answer too.

Builds on the happy-eyeballs crate v0.11.0 stale/allow_stale API (bug 2060591)

Seed a short-TTL A record by driving one connection through Happy
Eyeballs, let it age into the grace period, then answer the name with a
working address. The stale address is raced first and its connection is
refused; Happy Eyeballs revalidates with a cache-bypassing lookup, races
the address that comes back, and the request succeeds on it.

Serving a stale entry also makes the resolver renew it in the
background, and that renewal alone is enough to reach the working
address: it updates the shared host record, so a lookup landing after it
sees the new address, and the test would pass with or without the
revalidation. DNS therefore goes through the TRR server, whose answers
can be delayed: the revalidated answer is held back until Happy Eyeballs
has consumed the stale one and failed to connect to it. TRR_ONLY mode
keeps native resolution, which answers 127.0.0.1 for everything in TRR
tests, out of the picture as well.

Firefox already serves DNS answers from a cache entry's grace period
(stale-while-revalidate). This teaches Happy Eyeballs to notice when an
answer was served stale and race it immediately while revalidating with
a fresh, cache-bypassing lookup, then race the revalidated answer too.

  • Expose nsIDNSAddrRecord::fromStaleCache, backed by the resolver's
    existing grace-period check (CheckExpiration == EXP_GRACE), rather than
    reasoning from the record's ttl and lastUpdate: lastUpdate only moves
    when the address set changes, so a repeatedly refreshed but stable host
    would otherwise look perpetually stale.
  • Plumb happy-eyeballs v0.11.0's stale/allow_stale API through the FFI
    glue and the C++ driver. Output::SendDnsQuery carries allow_stale;
    when the state machine revalidates a stale answer (allow_stale=false)
    the driver adds RESOLVE_BYPASS_CACHE | RESOLVE_REFRESH_CACHE.
  • happy_eyeballs_process_dns_response_{a,aaaa,https} carry the stale flag
    into Input::DnsResult. A/AAAA answers report fromStaleCache; HTTPS
    records do not expose grace status yet, so they are reported fresh.

The DNSRecord IPC struct carries the flag too, sampled when the lookup
completes: the receiving side holds no expiration times of its own, so
it cannot recompute grace status, and ttl plus lastUpdate is exactly the
reasoning rejected above.

The Happy Eyeballs DNS profiler markers now record two facts introduced
by Optimistic DNS: whether a query was a cache-bypassing revalidation of
a stale answer (allow_stale=false), and whether the answer it received
was served from a stale (past-TTL, grace-period) cache entry. This makes
the revalidation flow visible when profiling a connection.

Severity: -- → S3
Pushed by mail@max-inden.de: https://github.com/mozilla-firefox/firefox/commit/e89e5e69b9fb https://hg.mozilla.org/integration/autoland/rev/e59249982dd2 Test that Happy Eyeballs revalidates a stale DNS answer r=necko-reviewers,kershaw https://github.com/mozilla-firefox/firefox/commit/59fb478277e2 https://hg.mozilla.org/integration/autoland/rev/8c40d01877d1 Revalidate stale DNS answers in Happy Eyeballs r=necko-reviewers,kershaw https://github.com/mozilla-firefox/firefox/commit/4c7abb49797f https://hg.mozilla.org/integration/autoland/rev/920a2b7bbc6c Surface stale and revalidation state in Happy Eyeballs profiler markers r=necko-reviewers,jesup
Pushed by pstanciu@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/760897ee7477 https://hg.mozilla.org/integration/autoland/rev/3e5f7d3d0c94 Revert "Bug 2060788 - Surface stale and revalidation state in Happy Eyeballs profiler markers r=necko-reviewers,jesup" for causing wpt failures @ drm-mp4-playback-temporary-playduration.https.html

Backed out for causing wpt failures @ drm-mp4-playback-temporary-playduration.https.html

Flags: needinfo?(mail)
Pushed by mail@max-inden.de: https://github.com/mozilla-firefox/firefox/commit/ebf212a7c9e9 https://hg.mozilla.org/integration/autoland/rev/7498ebcdb1d5 Test that Happy Eyeballs revalidates a stale DNS answer r=necko-reviewers,kershaw https://github.com/mozilla-firefox/firefox/commit/7da51d498b3f https://hg.mozilla.org/integration/autoland/rev/ab3116bc2472 Revalidate stale DNS answers in Happy Eyeballs r=necko-reviewers,kershaw https://github.com/mozilla-firefox/firefox/commit/c04c1c0003f5 https://hg.mozilla.org/integration/autoland/rev/64700777366a Surface stale and revalidation state in Happy Eyeballs profiler markers r=necko-reviewers,jesup
Pushed by sstanca@mozilla.com: https://github.com/mozilla-firefox/firefox/commit/2fcba59e9c8f https://hg.mozilla.org/integration/autoland/rev/403c71c8f2b1 Revert "Bug 2060788 - Surface stale and revalidation state in Happy Eyeballs profiler markers r=necko-reviewers,jesup" for causing wpt failures in video_dynamic_poster_absolute.htm.

Reverted this because it was causing wpt failures in video_dynamic_poster_absolute.htm.

Neither I nor Kershaw can reproduce the above failure on latest main. See e.g.:

https://treeherder.mozilla.org/jobs?repo=try&revision=a460df3a1c24b0bc11336776bb4c3ebda3c70411

Thus attempting another landing. In case my patch is the actual root cause, I am sorry for the trouble in advance.

Flags: needinfo?(mail)
Pushed by mail@max-inden.de: https://github.com/mozilla-firefox/firefox/commit/c9b408da359a https://hg.mozilla.org/integration/autoland/rev/4bc2d1107eff Test that Happy Eyeballs revalidates a stale DNS answer r=necko-reviewers,kershaw https://github.com/mozilla-firefox/firefox/commit/a9ed29df9407 https://hg.mozilla.org/integration/autoland/rev/cc97ac2dfe21 Revalidate stale DNS answers in Happy Eyeballs r=necko-reviewers,kershaw https://github.com/mozilla-firefox/firefox/commit/32547b4910c0 https://hg.mozilla.org/integration/autoland/rev/7f788ec4c025 Surface stale and revalidation state in Happy Eyeballs profiler markers r=necko-reviewers,jesup
Status: ASSIGNED → RESOLVED
Closed: 3 months ago
Resolution: --- → FIXED
Target Milestone: --- → 156 Branch
Regressions: 2064432
QA Whiteboard: [qa-triage-done-c157/b156]
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Creator:
Created:
Updated:
Size: