]> git.ipfire.org Git - thirdparty/pdns.git/commitdiff
rec: Add a new max-udp-queries-per-round setting
authorRemi Gacogne <remi.gacogne@powerdns.com>
Thu, 19 Apr 2018 15:03:54 +0000 (17:03 +0200)
committerPieter Lexis <pieter.lexis@powerdns.com>
Mon, 20 Aug 2018 13:01:16 +0000 (15:01 +0200)
This new setting limits the number of UDP queries we attempt to
handle after being woken up by the multiplexer and before returning
back to process other events.
Before this, we could end up trying to process queries after queries
and almost never return from handleNewUDPQuestion() to process new
events, meaning we could eventually end up never scheduling new
mthreads or handle responses from authoritative servers for a long
time, only sending responses for packetcache hits and creating new
mthreads.

(cherry picked from commit a5886e6adad3c19e3490fba1dc7e580defb83eee)

pdns/pdns_recursor.cc
pdns/recursordist/docs/settings.rst

index f8f3a948b2900eb10e75caaf78dbd9449a8398db..97580d58387c7dcda9d05c96b3525c7992c00ccd 100644 (file)
@@ -145,6 +145,7 @@ static AtomicCounter counter;
 static std::shared_ptr<SyncRes::domainmap_t> g_initialDomainMap; // new threads needs this to be setup
 static std::shared_ptr<NetmaskGroup> g_initialAllowFrom; // new thread needs to be setup with this
 static size_t g_tcpMaxQueriesPerConn;
+static size_t s_maxUDPQueriesPerRound;
 static uint64_t g_latencyStatSize;
 static uint32_t g_disthashseed;
 static unsigned int g_maxTCPPerClient;
@@ -1835,7 +1836,7 @@ static void handleNewUDPQuestion(int fd, FDMultiplexer::funcparam_t& var)
   fromaddr.sin6.sin6_family=AF_INET6; // this makes sure fromaddr is big enough
   fillMSGHdr(&msgh, &iov, cbuf, sizeof(cbuf), data, sizeof(data), &fromaddr);
 
-  for(;;)
+  for(size_t counter = 0; counter < s_maxUDPQueriesPerRound; counter++)
   if((len=recvmsg(fd, &msgh, 0)) >= 0) {
 
     firstQuery = false;
@@ -3174,6 +3175,7 @@ static int serviceMain(int argc, char*argv[])
   g_tcpTimeout=::arg().asNum("client-tcp-timeout");
   g_maxTCPPerClient=::arg().asNum("max-tcp-per-client");
   g_tcpMaxQueriesPerConn=::arg().asNum("max-tcp-queries-per-connection");
+  s_maxUDPQueriesPerRound=::arg().asNum("max-udp-queries-per-round");
 
   if (::arg().mustDo("snmp-agent")) {
     g_snmpAgent = std::make_shared<RecursorSNMPAgent>("recursor", ::arg()["snmp-master-socket"]);
@@ -3487,6 +3489,7 @@ int main(int argc, char **argv)
     ::arg().set("max-qperq", "Maximum outgoing queries per query")="50";
     ::arg().set("max-total-msec", "Maximum total wall-clock time per query in milliseconds, 0 for unlimited")="7000";
     ::arg().set("max-recursion-depth", "Maximum number of internal recursion calls per query, 0 for unlimited")="40";
+    ::arg().set("max-udp-queries-per-round", "Maximum number of UDP queries processed per round, before returning back to normal processing")="10000";
 
     ::arg().set("include-dir","Include *.conf files from this directory")="";
     ::arg().set("security-poll-suffix","Domain name from which to query security update notifications")="secpoll.powerdns.com.";
index 8940d8eb65b173928da1aa6b47619bee0a95640e..fcf80968ecf0d1124e4fd3a4da195529bf6bbc7a 100644 (file)
@@ -750,6 +750,18 @@ Maximum number of DNS queries in a TCP connection.
 
 Total maximum number of milliseconds of wallclock time the server may use to answer a single query.
 
+.. _setting-max-udp-queries-per-round:
+
+``max-udp-queries-per-round``
+----------------------------------
+.. versionadded:: 4.2.0
+
+-  Integer
+-  Default: 10000
+
+Maximum number of DNS queries processed in a single round after being woken up by the multiplexer, before
+returning back to normal processing to handle other events.
+
 .. _setting-minimum-ttl-override:
 
 ``minimum-ttl-override``