Skip to content

Commit

Permalink
Merge pull request PowerDNS#12373 from omoerbeek/rec-stack-usage-warning
Browse files Browse the repository at this point in the history
rec: Warn on high (90%) mthread stack usage
  • Loading branch information
omoerbeek authored Jan 3, 2023
2 parents 39942da + a7f7ebd commit 44d305b
Showing 1 changed file with 13 additions and 0 deletions.
13 changes: 13 additions & 0 deletions pdns/recursordist/pdns_recursor.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
Expand Down

0 comments on commit 44d305b

Please sign in to comment.