From 715afa9c5771ca5b483aad77fe21906685d63889 Mon Sep 17 00:00:00 2001 From: Evan Hunt Date: Mon, 25 Nov 2019 21:28:10 -0800 Subject: [PATCH] add a stats counter for clients dropped due to recursive-clients limit --- CHANGES | 4 ++++ bin/named/statschannel.c | 3 +++ bin/tests/system/fetchlimit/tests.sh | 12 ++++++++++++ lib/ns/client.c | 5 ++++- lib/ns/include/ns/stats.h | 4 +++- 5 files changed, 26 insertions(+), 2 deletions(-) diff --git a/CHANGES b/CHANGES index 1cd85378c7..b0d9930766 100644 --- a/CHANGES +++ b/CHANGES @@ -1,3 +1,7 @@ +5327. [func] Added a statistics counter to track queries + dropped because the recursive-clients quota was + exceeded. [GL #1399] + 5326. [bug] Add python dependancy on 'distutils.core' to configure. 'distutils.core' is required for installation. [GL #1397] diff --git a/bin/named/statschannel.c b/bin/named/statschannel.c index a955d7b207..c125b659cf 100644 --- a/bin/named/statschannel.c +++ b/bin/named/statschannel.c @@ -324,6 +324,9 @@ init_desc(void) { "QryUsedStale"); SET_NSSTATDESC(prefetch, "queries triggered prefetch", "Prefetch"); SET_NSSTATDESC(keytagopt, "Keytag option received", "KeyTagOpt"); + SET_NSSTATDESC(reclimitdropped, + "queries dropped due to recursive client limit", + "RecLimitDropped"); INSIST(i == ns_statscounter_max); diff --git a/bin/tests/system/fetchlimit/tests.sh b/bin/tests/system/fetchlimit/tests.sh index 747ae07dfc..3065060d06 100644 --- a/bin/tests/system/fetchlimit/tests.sh +++ b/bin/tests/system/fetchlimit/tests.sh @@ -179,5 +179,17 @@ echo_i "clients count exceeded 380 on $exceeded trials (expected 0)" if [ $ret != 0 ]; then echo_i "failed"; fi status=`expr $status + $ret` +echo_i "checking drop statistics" +rm -f ns3/named.stats +$RNDCCMD stats +for try in 1 2 3 4 5; do + [ -f ns3/named.stats ] && break + sleep 1 +done +drops=`grep 'queries dropped due to recursive client limit' ns3/named.stats | sed 's/\([0-9][0-9]*\) queries.*/\1/'` +[ "${drops:-0}" -ne 0 ] || ret=1 +if [ $ret != 0 ]; then echo_i "failed"; fi +status=`expr $status + $ret` + echo_i "exit status: $status" [ $status -eq 0 ] || exit 1 diff --git a/lib/ns/client.c b/lib/ns/client.c index 8cd8226549..cf8467316f 100644 --- a/lib/ns/client.c +++ b/lib/ns/client.c @@ -155,8 +155,11 @@ ns_client_killoldestquery(ns_client_t *client) { ISC_LIST_UNLINK(client->manager->recursing, oldest, rlink); UNLOCK(&client->manager->reclock); ns_query_cancel(oldest); - } else + ns_stats_increment(client->sctx->nsstats, + ns_statscounter_reclimitdropped); + } else { UNLOCK(&client->manager->reclock); + } } void diff --git a/lib/ns/include/ns/stats.h b/lib/ns/include/ns/stats.h index 175813113e..8afe14260f 100644 --- a/lib/ns/include/ns/stats.h +++ b/lib/ns/include/ns/stats.h @@ -104,7 +104,9 @@ enum { ns_statscounter_tcphighwater = 65, - ns_statscounter_max = 66, + ns_statscounter_reclimitdropped = 66, + + ns_statscounter_max = 67, }; void