From: Christopher Faulet Date: Tue, 29 Sep 2026 07:38:46 +0000 (+0200) Subject: BUG/MINOR: resolvers: count nameserver timeouts X-Git-Url: https://git.kaiwu.me/?a=commitdiff_plain;h=745413eed1769d8dda7eabbd22ad44bfe08147ad;p=haproxy.git BUG/MINOR: resolvers: count nameserver timeouts The per-nameserver "timeout" counter, reported by "show resolvers", the stats and Prometheus, and documented as the number of times the server did not answer in time, has never been incremented since it was introduced in 1.6, so it always reports zero, even when a nameserver never responds. Individual responses are not tracked per nameserver for a given query, so we cannot know which nameservers did not respond when only some did. However when a try expires without any response at all, all nameservers the query was sent to failed to respond in time. Let's count a timeout for each of them in this case. It may undercount timeouts of some nameservers when others respond, but it's never wrong anymore when none responds, which is by far the most useful case. This can be verified with a nameserver which never responds and "resolve_retries 2": after 3 seconds, "show resolvers" reports "sent: 5" and "timeout: 0" before this patch, and "timeout: 4" after. This patch may be backported to stable branches. --- diff --git a/src/resolvers.c b/src/resolvers.c index feca18e59..e09560931 100644 --- a/src/resolvers.c +++ b/src/resolvers.c @@ -2604,6 +2604,16 @@ struct task *process_resolvers(struct task *t, void *context, unsigned int state if (!tick_is_expired(exp, now_ms)) break; + /* When no nameserver responded, they all timed out. Otherwise + * we don't know which ones did not respond. + */ + if (!res->nb_responses) { + struct dns_nameserver *ns; + + list_for_each_entry(ns, &resolvers->nameservers, list) + ns->counters->app.resolver.timeout++; + } + /* If current resolution has been tried too many times and * finishes in timeout we update its status and remove it from * the list */