mirror of
https://github.com/coredns/coredns.git
synced 2026-10-17 15:55:47 -04:00
* plugin/cache: cache SERVFAIL when the resolver fails without a response The forward plugin returns (SERVFAIL, err) on an upstream timeout without calling WriteMsg, so the response never reaches the cache ResponseWriter and is not stored. Every client retry then hits the upstream again and pays the full forward timeout, while a SERVFAIL sent by the upstream is cached normally. Store a SERVFAIL generated from the failure, bounded by the existing servfail TTL, so identical queries are answered from the cache while it is valid. A servfail TTL of 0 keeps the previous behaviour. Signed-off-by: Ahmad Mehrabi <mehrabi@post.com> * plugin/cache: do not cache SERVFAIL caused by a canceled request forward also returns SERVFAIL together with an error when the request context is canceled. DoH propagates the HTTP request context, so caching that failure would make every subsequent request with the same cache key fail until the servfail TTL expires, even though the upstream is healthy. Only insert the synthetic SERVFAIL when the request context is still live, and add a regression test that cancels the first request and then verifies that a subsequent healthy request reaches the backend. Signed-off-by: Ahmad Mehrabi <mehrabi@post.com> --------- Signed-off-by: Ahmad Mehrabi <mehrabi@post.com>
20 KiB
20 KiB