From 8792a64c0a30b26e9ccb7c51bffe06e8e6330fd3 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Tue, 1 Aug 2023 12:49:46 +0500 Subject: [PATCH] Increment DNS cache record count when the records are cleared from the DNS cache, given that both the MySQL servers and ProxySQL servers tables are empty. --- lib/MySQL_Monitor.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 655244adf..8afc84615 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -6631,11 +6631,15 @@ void DNS_Cache::remove(const std::string& hostname) { } void DNS_Cache::clear() { + size_t records_removed = 0; int rc = pthread_rwlock_wrlock(&rwlock_); assert(rc == 0); + records_removed = records.size(); records.clear(); rc = pthread_rwlock_unlock(&rwlock_); assert(rc == 0); + if (records_removed) + __sync_fetch_and_add(&GloMyMon->dns_cache_record_updated, records_removed); proxy_debug(PROXY_DEBUG_MYSQL_CONNECTION, 5, "DNS cache was cleared.\n"); }