From d3363b40f6400cc487569eeea6ca9cf932f9c076 Mon Sep 17 00:00:00 2001 From: bert hubert Date: Fri, 12 Aug 2016 19:56:09 +0200 Subject: [PATCH] fix distributor overload behaviour, closes #4311. Also adds & documents metric overload-drops. Want to add a test too, not there yet. --- docs/markdown/authoritative/performance.md | 1 + pdns/common_startup.cc | 5 ++++- pdns/distributor.hh | 16 ++++++---------- 3 files changed, 11 insertions(+), 11 deletions(-) diff --git a/docs/markdown/authoritative/performance.md b/docs/markdown/authoritative/performance.md index 43645c7a5d..4197ee31cb 100644 --- a/docs/markdown/authoritative/performance.md +++ b/docs/markdown/authoritative/performance.md @@ -57,6 +57,7 @@ daemon. * `key-cache-size`: Number of entries in the key cache * `latency`: Average number of microseconds a packet spends within PowerDNS * `meta-cache-size`: Number of entries in the metadata cache +* `overload-drops`: Number of questions dropped because backends overloaded * `packetcache-hit`: Number of packets which were answered out of the cache * `packetcache-miss`: Number of times a packet could not be answered out of the cache * `packetcache-size`: Amount of packets in the packetcache diff --git a/pdns/common_startup.cc b/pdns/common_startup.cc index 46f3d50159..83111347da 100644 --- a/pdns/common_startup.cc +++ b/pdns/common_startup.cc @@ -250,6 +250,7 @@ void declareStats(void) S.declare("udp4-queries","Number of IPv4 UDP queries received"); S.declare("udp6-answers","Number of IPv6 answers sent out over UDP"); S.declare("udp6-queries","Number of IPv6 UDP queries received"); + S.declare("overload-drops","Queries dropped because backends overloaded"); S.declare("rd-queries", "Number of recursion desired questions"); S.declare("recursion-unanswered", "Number of packets unanswered by configured recursor"); @@ -351,6 +352,7 @@ void *qthread(void *number) AtomicCounter &numreceived4=*S.getPointer("udp4-queries"); AtomicCounter &numreceived6=*S.getPointer("udp6-queries"); + AtomicCounter &overloadDrops=*S.getPointer("overload-drops"); int diff; bool logDNSQueries = ::arg().mustDo("log-dns-queries"); @@ -437,7 +439,8 @@ void *qthread(void *number) if(distributor->isOverloaded()) { if(logDNSQueries) - L<<"Dropped query, db is overloaded"< d_overloadQueueLength); } private: - bool d_overloaded; int nextid; time_t d_last_started; + unsigned int d_overloadQueueLength, d_maxQueueLength; int d_num_threads; std::atomic d_queued{0}, d_running{0}; std::vector> d_pipes; @@ -142,8 +142,8 @@ templateSingleThreadDistributorMultiThreadDistributor::MultiThreadDistributor(int n) { d_num_threads=n; - d_overloaded = false; - + d_overloadQueueLength=::arg().asNum("overload-queue-length"); + d_maxQueueLength=::arg().asNum("max-queue-length"); nextid=0; d_last_started=time(0); @@ -322,14 +322,10 @@ templateint MultiThreadDistributor< unixDie("write"); d_queued++; - - static unsigned int overloadQueueLength=::arg().asNum("overload-queue-length"); - static unsigned int maxQueueLength=::arg().asNum("max-queue-length"); - if(overloadQueueLength) - d_overloaded= d_queued > overloadQueueLength; - if(d_queued > maxQueueLength) { + + if(d_queued > d_maxQueueLength) { L<