Repository navigation
Fix timing flake in proxy_serve_stale_dns_fail - #13869
Conversation
The test asked each proxy for a stale copy 7 seconds after pushing it, under a single 15 second stale limit, so the "serves stale" responses had only 8 seconds of headroom. A CI agent that stalls longer than that gets a correct 500 instead of the expected 200, and the gold file mismatches. Give the two kinds of checks their own stale window. The proxies now allow 300 seconds, so lateness cannot turn a "serves stale" response into a 500. Requests that expect a copy that is too old send X-Stale-Window: narrow, and a header_rewrite set-config rule shrinks max_stale_age to one second for that request only, so lateness only makes those responses more certain. Every request still reads the same cached copy, so the child's second request still checks that a copy rewritten by negative revalidation expires by its max-age. The 17 second waits go away and the test drops from about 56 seconds to about 28.
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
No open issues 🎉
What changed in this PR
Adjusts proxy_serve_stale_dns_fail to eliminate timing-related flakes on slow CI agents by separating “serve stale” vs “too old” validations into distinct stale windows while reducing overall test runtime.
Changes:
- Introduces wide vs narrow stale windows (300s vs 1s) and toggles behavior per-request via
X-Stale-Window: narrow. - Applies per-request
proxy.config.http.cache.max_stale_agenarrowing usingheader_rewriteset-configrules in remap. - Removes long sleeps and updates timing to keep assertions deterministic while cutting runtime roughly in half.
| File | Description |
|---|---|
| tests/gold_tests/cache/proxy_serve_stale_dns_fail.test.py | Adds per-request stale-window control via header_rewrite and adjusts sleeps to prevent timing flakes and reduce test duration. |
Review effort: Lite
There was a problem hiding this comment.
Summary
Approve. The fix addresses the root cause of the flake: the serve-stale checks and the too-old checks shared one 15 second window, so CI stalls flipped the expected 200s into 500s. Splitting them into a 300 second default window and a 1 second per-request window (via header_rewrite set-config on the overridable proxy.config.http.cache.max_stale_age) makes delay harmless for the serve-stale checks and only strengthens the too-old checks. The reasoning matches the core logic in HttpTransact::is_stale_cache_response_returnable and the negative revalidation path, which rewrites the cached copy with a new Expires but keeps max-age=5, so the copy's age restarts. Verified locally: the test passes in about 28 seconds (down from about 56); widening the narrow window to 300 makes it fail, so the narrow checks still catch failures; inserting a 20 second stall before both serve-stale requests (the original flake scenario) still passes.
Positive Notes
- Fixes the cause instead of padding sleeps, and cuts runtime roughly in half.
- The comments explain the stale window design and why the child's second request still needs its 7 second wait.
- Thorough testing in the description: stall injection, mutations to confirm the checks still catch failures, and sanitizer builds.
Recommendation
Approve - the code looks good. Minor items can be addressed optionally.
|
One optional note on |
|
Thanks, good catch. I added the comment in e50f965: only the localhost maps load the rule, so the narrow window applies on the proxy the client talks to directly, not on the parent the child forwards to. |
|
[approve ci autest 1] |
…ns-fail-flake-local # Conflicts: # tests/gold_tests/cache/proxy_serve_stale_dns_fail.test.py
The AuTest this pull request fixed was converted to Uranium on master. Carry the same fix into tests/uranium_tests/cache: a 300 second stale window for the checks that expect a stale copy, and a header_rewrite rule that narrows it to one second for the requests that expect a copy to be too old, in place of the 17 second sleeps.
|
#13545 moved this test to Uranium, so I merged master and moved the fix into I reran the proof against the Uranium test:
Could you take another look? |
There was a problem hiding this comment.
Warning
Copilot couldn't run its full agentic review because it didn't start before the timeout. Make sure your repository has a runner available, or add a copilot-code-review.yml file specifying one with the runs-on attribute. See the docs for more details.
Copilot review overview
2 open issues
Review effort: Lite
|
CI hit this on the Uranium version this morning: autest build 45685 on #13880, which only changes HttpSessionManager.cc. The responses were 500, 500, 200, 500 where the gold file expects 200 first, the same signature as the AuTest failures, so the move to Uranium did not make it go away. |
traeak
left a comment
There was a problem hiding this comment.
Looks the same as before when approved.
The serve-stale checks and the too-old checks shared one 15 second stale limit, and the test asked for a stale copy 7 seconds after pushing it, so a CI agent that stalled for more than 8 seconds got a correct 500 instead of the expected 200. Each kind of check now has its own window: the proxies allow 300 seconds, and requests that expect a too-old copy send X-Stale-Window: narrow, which a header_rewrite set-config rule turns into a one second max_stale_age for that request only. The two 17 second sleeps become one 7 second wait. (cherry picked from commit 701bda1)
|
Cherry-picked to the 10.2.x branch as e3225a4 for the 10.2.2 release. |


test_proxy_serve_stale_dns_failasks each proxy for a stale copy 7 seconds after pushing it, under a single 15 second stale limit, so the "serves stale" responses have only 8 seconds of headroom. When the machine running the test stalls longer than that, the proxy correctly answers500 Cannot find serverinstead of the expected 200 and the output check fails. CI hit this failure on busy agents in the AuTest version of this test, and again on the Uranium version after #13545 moved it there.This gives the two kinds of checks their own stale window. Both proxies now allow 300 seconds, so a late request can no longer turn a "serves stale" response into a 500. The requests that expect a copy to be too old send
X-Stale-Window: narrow, and aheader_rewriteset-configrule on the localhost maps shrinksproxy.config.http.cache.max_stale_ageto one second for that request only, so lateness only makes those responses more certain. The header is not part of the cache key, so every request still reads the same cached copy, and the child's second request still checks that a copy rewritten by negative revalidation expires by its max-age. The two 17 second waits become one 7 second wait, and the test drops from about 51 seconds to about 24.Testing, with the Uranium runner on a Fedora 44 host: pausing the test for 20 seconds before the first check fails master 4 of 4 times with the CI signature. This change passes 4 of 4 with a 20 second pause and 4 of 4 with a 40 second pause. Setting the wide window to one second, setting the narrow window to 300 seconds, or not sending the header each make the new test fail 3 of 3 times, so every check still discriminates.