From: Remi Gacogne Date: Fri, 2 Oct 2020 15:03:06 +0000 (+0200) Subject: dnsdist: Fix tcpGaveUp and tcpDownstreamTimeout counters X-Git-Tag: auth-4.5.0-alpha0~14^2~5 X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=e5f92a1109e4f3c4c90f0ee440b67b660c6b1139;p=thirdparty%2Fpdns.git dnsdist: Fix tcpGaveUp and tcpDownstreamTimeout counters --- diff --git a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc index 1d5271360a..8e63caf70e 100644 --- a/pdns/dnsdistdist/dnsdist-tcp-downstream.cc +++ b/pdns/dnsdistdist/dnsdist-tcp-downstream.cc @@ -251,7 +251,8 @@ void TCPConnectionToBackend::handleIO(std::shared_ptr& c if (!reconnected) { /* reconnect failed, we give up */ DEBUGLOG("reconnect failed, we give up"); - conn->notifyAllQueriesFailed(now); + ++conn->d_ds->tcpGaveUp; + conn->notifyAllQueriesFailed(now, FailureReason::gaveUp); } } @@ -375,6 +376,7 @@ bool TCPConnectionToBackend::reconnect() void TCPConnectionToBackend::handleTimeout(const struct timeval& now, bool write) { + /* in some cases we could retry, here, reconnecting and sending our pending responses again */ if (write) { ++d_ds->tcpWriteTimeouts; } @@ -386,10 +388,10 @@ void TCPConnectionToBackend::handleTimeout(const struct timeval& now, bool write d_ioState->reset(); } - notifyAllQueriesFailed(now, true); + notifyAllQueriesFailed(now, FailureReason::timeout); } -void TCPConnectionToBackend::notifyAllQueriesFailed(const struct timeval& now, bool timeout) +void TCPConnectionToBackend::notifyAllQueriesFailed(const struct timeval& now, FailureReason reason) { d_connectionDied = true; @@ -404,9 +406,12 @@ void TCPConnectionToBackend::notifyAllQueriesFailed(const struct timeval& now, b return; } - if (timeout) { + if (reason == FailureReason::timeout) { ++clientConn->d_ci.cs->tcpDownstreamTimeouts; } + else if (reason == FailureReason::gaveUp) { + ++clientConn->d_ci.cs->tcpGaveUp; + } if (d_state == State::sendingQueryToBackend) { clientConn->notifyIOError(clientConn, std::move(d_currentQuery.d_idstate), now); @@ -462,14 +467,14 @@ IOState TCPConnectionToBackend::handleResponse(std::shared_ptr& conn, const struct timeval& now); static void handleIOCallback(int fd, FDMultiplexer::funcparam_t& param); static IOState queueNextQuery(std::shared_ptr& conn); @@ -172,7 +177,7 @@ private: IOState handleResponse(std::shared_ptr& conn, const struct timeval& now); uint16_t getQueryIdFromResponse(); bool reconnect(); - void notifyAllQueriesFailed(const struct timeval& now, bool timeout = false); + void notifyAllQueriesFailed(const struct timeval& now, FailureReason reason); boost::optional getBackendReadTTD(const struct timeval& now) const { @@ -204,9 +209,6 @@ private: return res; } - /* waitingForResponseFromBackend is a state where we have not yet started reading the size, - so we can still switch to sending instead */ - enum class State { idle, doingHandshake, sendingQueryToBackend, waitingForResponseFromBackend, readingResponseSizeFromBackend, readingResponseFromBackend }; static const uint16_t s_xfrID; std::vector d_responseBuffer;