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.
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 */