From 5b5068c38c0839a4f6319f86e6f8776ba0c08dce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alejandro=20R=2E=20Sede=C3=B1o?= Date: Fri, 24 Jan 2025 13:47:51 -0500 Subject: [PATCH] Add DNS query Trace of NotStarted before queuing. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Before this change, it was possible that the `addTrace(NotStarted)` occured after the resolver thread picked up the query and started work. This can be seen when running the getaddrinfo tests 1000 times in the form of failure around or just under 1% of the time. bazel test --config=libc++ --runs_per_test 1000 //test/extensions/network/dns_resolver/getaddrinfo:getaddrinfo_test Signed-off-by: Alejandro R. SedeƱo --- .../extensions/network/dns_resolver/getaddrinfo/getaddrinfo.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/extensions/network/dns_resolver/getaddrinfo/getaddrinfo.cc b/source/extensions/network/dns_resolver/getaddrinfo/getaddrinfo.cc index 1988eb88e32c..0c6025490ed5 100644 --- a/source/extensions/network/dns_resolver/getaddrinfo/getaddrinfo.cc +++ b/source/extensions/network/dns_resolver/getaddrinfo/getaddrinfo.cc @@ -36,6 +36,7 @@ ActiveDnsQuery* GetAddrInfoDnsResolver::resolve(const std::string& dns_name, ResolveCb callback) { ENVOY_LOG(debug, "adding new query [{}] to pending queries", dns_name); auto new_query = std::make_unique(dns_name, dns_lookup_family, callback); + new_query->addTrace(static_cast(GetAddrInfoTrace::NotStarted)); ActiveDnsQuery* active_query; { absl::MutexLock guard(&mutex_); @@ -48,7 +49,6 @@ ActiveDnsQuery* GetAddrInfoDnsResolver::resolve(const std::string& dns_name, } active_query = pending_queries_.back().pending_query_.get(); } - active_query->addTrace(static_cast(GetAddrInfoTrace::NotStarted)); return active_query; }