Preserve fractional SERVFAIL lifetimes before retrying the backend
perfloop-oss/coredns · Cache Thrash
https://perfloop.ai/t/oss/case_23ty1cv368
Verdict
VERIFIED · settled 2026-11-10 · merged as coredns/coredns#8756
What happened: The check fails before this change and passes with it.
Hypothesis
The failure cache accepts fractional lifetimes but stores only whole seconds. A positive lifetime shorter than one second therefore behaves as if the entry had already expired. Repeated DNS queries can reach a failing backend again even while the configured failure interval is active. Configuration prevalence, retry cadence and operational savings remain unmeasured.
The README defines servfail DURATION as the caching interval and reserves zero for disabling it. cacheParse accepts time.Duration values from zero through five minutes without a whole-second restriction. ResponseWriter.WriteMsg selects c.failttl for ServerError responses. newItem then stores uint32(d.Seconds()) in origTTL, and item.ttl plus Cache.getIfNotStale use that integer for freshness. Both a written SERVFAIL and the live-context error-without-response branch in ServeDNS reach this representation. The latter is already covered by TestCacheServfailOnTimeout with a five-second control.
checkProperty call_4j64iYvoKgWYUN6caEzL8xrn ran go test ./plugin/cache -run '^$' -fuzz '^FuzzPerfloopFailureLifetime$' -fuzztime=5s -parallel=1 -count=1 -timeout=90s -v at ef93f4c07f07435268af58a32c92b2b69e607811. All 70 zero/whole-second seed controls passed. The search stopped after 76 executions at a 6ns duration and zero elapsed time in the error-without-response mode. One failure entry remained, but the immediate follow-up made a second backend call and wrote no cached response. The native corpus preserves that input.
checkProperty call_Si3FgwrBpBwgjkUNSLfaWesN confirmed the reduced 1ns, zero-elapsed witness without search: backend-calls=2, expected=1, retained-entries=1. Property prop_ka91h1k08y stores the native check, generated replay and reduced explicit seed. The nanosecond value is a boundary witness, not an assertion about production query cadence. Fractional failures acquired through written responses share the source mechanism, but only their integer-duration controls ran before this search stopped.
The smallest Case check is the stored two-query witness with serve_stale disabled. The proof target is honoring accepted fractional failure lifetimes for both acquisition routes while preserving disabled-cache and canceled-request behavior. Optional readable samples are 500ms and 1.5s with a whole-second control. A duration-aware internal expiry can address the representation loss as a class instead of special-casing subsecond settings. No exact upper-cutoff equality policy or minimum speedup is requested. Any performance publication still needs an attributable failure-and-retry workload rather than scaling this synthetic call count.
This is independent of hyp_3p76pf4af3: repairing the stale-window comparison alone cannot recover a failure lifetime already stored as zero, and this witness has stale serving disabled. The prior oversized-integer TTL repair hyp_nq9r90q2cc concerns range overflow, not positive fractional failure durations. In current inspected upstream work, https://github.com/coredns/coredns/pull/8566 leaves the integer lifetime representation intact while changing DNSSEC sharing. https://github.com/coredns/coredns/pull/8589 changes in-flight stale waiting, and https://github.com/coredns/coredns/pull/8626 changes stale response TTLs. The bounded cache-path history fetch remained shallow. The coredns-discuss search for servfail/fractional/duration was refused with HTTP 403, so older history and discussion coverage remain gaps.
Change to test: Retain the configured failure-cache lifetime at full precision for storage, freshness selection and stale classification instead of deriving it from the integer wire TTL. Preserve zero-as-disabled, the five-minute cap and cancellation isolation; an explicit expiry field and native-check layout are provisional choices.
Where it lives
perfloop-oss/coredns · plugin/cache/handler.go
Evidence
The check fails before this change and passes with it: `For live requests with SERVFAIL caching set to 1ns, 500ms, 1.5s, 5s or 5m, both written SERVFAIL responses and SERVFAIL errors without a response are reused before expiry without contacting the backend, then a healthy response is fetched and cached after expiry; this holds with stale serving disabled and with synchronous stale verification, while wire TTLs remain whole seconds.`
Checks: 2 of 2 passed. Verification: no defect found.