From a7f7ebdf8a191ba343582f744f43fe3783c85bab Mon Sep 17 00:00:00 2001 From: Otto Moerbeek Date: Tue, 3 Jan 2023 12:36:14 +0100 Subject: [PATCH] Warn on high (90%) mthread stack usage --- pdns/recursordist/pdns_recursor.cc | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/pdns/recursordist/pdns_recursor.cc b/pdns/recursordist/pdns_recursor.cc index de176c2d63a2..6e9c4f9ac193 100644 --- a/pdns/recursordist/pdns_recursor.cc +++ b/pdns/recursordist/pdns_recursor.cc @@ -1816,6 +1816,19 @@ void startDoResolve(void* p) runTaskOnce(g_logCommonErrors); + static const size_t stackSizeThreshold = 9 * ::arg().asNum("stack-size") / 10; + if (MT->getMaxStackUsage() >= stackSizeThreshold) { + SLOG(g_log << Logger::Error << "Reached mthread stack usage of 90%: " << MT->getMaxStackUsage() << " " << makeLoginfo(dc) << " after " << sr.d_outqueries << " out queries, " << sr.d_tcpoutqueries << " TCP out queries, " << sr.d_dotoutqueries << " DoT out queries" << endl, + sr.d_slog->info(Logr::Error, "Reached mthread stack usage of 90%", + "stackUsage", Logging::Loggable(MT->getMaxStackUsage()), + "outqueries", Logging::Loggable(sr.d_outqueries), + "netms", Logging::Loggable(sr.d_totUsec / 1000.0), + "throttled", Logging::Loggable(sr.d_throttledqueries), + "timeouts", Logging::Loggable(sr.d_timeouts), + "tcpout", Logging::Loggable(sr.d_tcpoutqueries), + "dotout", Logging::Loggable(sr.d_dotoutqueries), + "validationState", Logging::Loggable(sr.getValidationState()))); + } t_Counters.at(rec::Counter::maxMThreadStackUsage) = max(MT->getMaxStackUsage(), t_Counters.at(rec::Counter::maxMThreadStackUsage)); t_Counters.updateSnap(g_regressionTestMode); }