]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
Warn on high (90%) mthread stack usage 12373/head
authorOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 3 Jan 2023 11:36:14 +0000 (12:36 +0100)
committerOtto Moerbeek <otto.moerbeek@open-xchange.com>
Tue, 3 Jan 2023 11:36:14 +0000 (12:36 +0100)
pdns/recursordist/pdns_recursor.cc

index de176c2d63a29b77fe1589d88e0d25c73a1a112f..6e9c4f9ac193e5d1744228f08cc49cf57737c68b 100644 (file)
@@ -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);
 }