From 992fc809137915300354a4c6a6268e4e405d92ec Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Thu, 8 Jun 2023 12:44:17 +0200 Subject: [PATCH] rec: keep track of max depth reaches and report it if !quiet This is enough for now, mostly a metric only interesting to devs --- pdns/recursordist/pdns_recursor.cc | 4 +++- pdns/recursordist/syncres.cc | 1 + pdns/recursordist/syncres.hh | 1 + 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index e1dbcf7bd4..644541d639 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -1791,6 +1791,7 @@ void startDoResolve(void* p) // NOLINT(readability-function-cognitive-complexity g_log << ", dnssec=" << sr.getValidationState(); } g_log << " answer-is-variable=" << sr.wasVariable() << ", into-packetcache=" << intoPC; + g_log << " maxdepth=" << sr.d_maxdepth; g_log << endl; } else { @@ -1807,7 +1808,8 @@ void startDoResolve(void* p) // NOLINT(readability-function-cognitive-complexity "rcode", Logging::Loggable(res), "validationState", Logging::Loggable(sr.getValidationState()), "answer-is-variable", Logging::Loggable(sr.wasVariable()), - "into-packetcache", Logging::Loggable(intoPC)); + "into-packetcache", Logging::Loggable(intoPC), + "maxdepth", Logging::Loggable(sr.d_maxdepth)); } } diff --git a/pdns/recursordist/syncres.cc b/pdns/recursordist/syncres.cc index a2cba559bf..c6be854ae1 100644 --- a/pdns/recursordist/syncres.cc +++ b/pdns/recursordist/syncres.cc @@ -1824,6 +1824,7 @@ int SyncRes::doResolveNoQNameMinimization(const DNSName& qname, const QType qtyp LOG(prefix << qname << ": Wants " << (d_doDNSSEC ? "" : "NO ") << "DNSSEC processing, " << (d_requireAuthData ? "" : "NO ") << "auth data required by query for " << qtype << endl); + d_maxdepth = std::max(d_maxdepth, depth); if (s_maxdepth > 0) { auto bound = getAdjustedRecursionBound(); // Use a stricter bound if throttling diff --git a/pdns/recursordist/syncres.hh b/pdns/recursordist/syncres.hh index 539216bc3b..c61e78a0de 100644 --- a/pdns/recursordist/syncres.hh +++ b/pdns/recursordist/syncres.hh @@ -570,6 +570,7 @@ public: unsigned int d_timeouts; unsigned int d_unreachables; unsigned int d_totUsec; + unsigned int d_maxdepth{0}; // Initialized ony once, as opposed to d_now which gets updated after outgoing requests const struct timeval d_fixednow; -- 2.47.2