From e4fd764d86f0d6392ec8dcfa20714a12480996f3 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Wed, 24 Apr 2024 16:22:26 +0500 Subject: [PATCH] Added is_locked flag within '#ifdef DEBUG' conditional block --- include/MySQL_HostGroups_Manager.h | 4 +++- lib/MyHGC.cpp | 4 ++-- lib/MySQL_HostGroups_Manager.cpp | 4 ++++ 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 6d14670b7..b5d3cb854 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -972,7 +972,9 @@ class MySQL_HostGroups_Manager { void init(); void wrlock(); void wrunlock(); - bool is_locked = false; // will be removed after testing +#ifdef DEBUG + bool is_locked = false; +#endif int servers_add(SQLite3_result *resultset); /** * @brief Generates a new global checksum for module 'mysql_servers_v2' using the provided hash. diff --git a/lib/MyHGC.cpp b/lib/MyHGC.cpp index bc347af9c..72dd3f564 100644 --- a/lib/MyHGC.cpp +++ b/lib/MyHGC.cpp @@ -392,9 +392,9 @@ MySrvC *MyHGC::get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_ void MyHGC::refresh_online_server_count() { if (__sync_fetch_and_add(&glovars.shutdown, 0) != 0) return; - +#ifdef DEBUG assert(MyHGM->is_locked); - +#endif unsigned int online_servers_count = 0; for (unsigned int i = 0; i < mysrvs->servers->len; i++) { MySrvC* mysrvc = (MySrvC*)mysrvs->servers->index(i); diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index eb7705e99..9dae056eb 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -724,7 +724,9 @@ void MySQL_HostGroups_Manager::wrlock() { #else spin_wrlock(&rwlock); #endif +#ifdef DEBUG is_locked = true; +#endif } void MySQL_HostGroups_Manager::p_update_mysql_error_counter(p_mysql_error_type err_type, unsigned int hid, char* address, uint16_t port, unsigned int code) { @@ -759,7 +761,9 @@ void MySQL_HostGroups_Manager::p_update_mysql_error_counter(p_mysql_error_type e } void MySQL_HostGroups_Manager::wrunlock() { +#ifdef DEBUG is_locked = false; +#endif #ifdef MHM_PTHREAD_MUTEX pthread_mutex_unlock(&lock); #else