From 0a391bd587950e50e431141015cdb0dfa7bcdfb5 Mon Sep 17 00:00:00 2001 From: Rene Cannao Date: Tue, 9 Jul 2024 15:37:18 +0000 Subject: [PATCH] Some code cleanup --- include/MySQL_HostGroups_Manager.h | 66 ---- include/PgSQL_HostGroups_Manager.h | 52 --- lib/BaseHGC.cpp | 348 ------------------ lib/Base_HostGroups_Manager.cpp | 215 ----------- lib/Makefile | 2 +- lib/MyHGC.cpp | 79 ---- lib/MySrvList.cpp | 48 --- lib/PgSQL_HostGroups_Manager.cpp | 555 ----------------------------- 8 files changed, 1 insertion(+), 1364 deletions(-) delete mode 100644 lib/MySrvList.cpp diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index b3b1ae89f..a447bc91a 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -275,22 +275,8 @@ private: }; class MySrvList: public BaseSrvList { // MySQL Server List -#if 0 - private: - MyHGC *myhgc; - int find_idx(MySrvC *); -#endif // 0 public: MySrvList(MyHGC* hgc) : BaseSrvList(hgc) {} -#if 0 - PtrArray *servers; - unsigned int cnt() { return servers->len; } - MySrvList(MyHGC *); - ~MySrvList(); - void add(MySrvC *); - void remove(MySrvC *); - MySrvC * idx(unsigned int i) {return (MySrvC *)servers->index(i); } -#endif // 0 }; @@ -300,58 +286,6 @@ class MyHGC: public BaseHGC { MySrvC *get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_lag_ms, MySQL_Session *sess); }; -#if 0 -class MyHGC { // MySQL Host Group Container - public: - unsigned int hid; - std::atomic num_online_servers; - time_t last_log_time_num_online_servers; - unsigned long long current_time_now; - uint32_t new_connections_now; - MySrvList *mysrvs; - struct { // this is a series of attributes specific for each hostgroup - char * init_connect; - char * comment; - char * ignore_session_variables_text; // this is the original version (text format) of ignore_session_variables - uint32_t max_num_online_servers; - uint32_t throttle_connections_per_sec; - int32_t monitor_slave_lag_when_null; - int8_t autocommit; - int8_t free_connections_pct; - int8_t handle_warnings; - bool multiplex; - bool connection_warming; - bool configured; // this variable controls if attributes are configured or not. If not configured, they do not apply - bool initialized; // this variable controls if attributes were ever configured or not. Used by reset_attributes() - nlohmann::json * ignore_session_variables_json = NULL; // the JSON format of ignore_session_variables - } attributes; - struct { - int64_t weight; - int64_t max_connections; - int32_t use_ssl; - } servers_defaults; - void reset_attributes(); - inline - bool handle_warnings_enabled() const { - return attributes.configured == true && attributes.handle_warnings != -1 ? attributes.handle_warnings : mysql_thread___handle_warnings; - } - inline - int32_t get_monitor_slave_lag_when_null() const { - return attributes.configured == true && attributes.monitor_slave_lag_when_null != -1 ? attributes.monitor_slave_lag_when_null : mysql_thread___monitor_slave_lag_when_null; - } - MyHGC(int); - ~MyHGC(); - MySrvC *get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_lag_ms, MySQL_Session *sess); - void refresh_online_server_count(); - void log_num_online_server_count_error(); - inline - bool online_servers_within_threshold() const { - if (num_online_servers.load(std::memory_order_relaxed) <= attributes.max_num_online_servers) return true; - return false; - } -}; -#endif // 0 - class Group_Replication_Info { public: int writer_hostgroup; diff --git a/include/PgSQL_HostGroups_Manager.h b/include/PgSQL_HostGroups_Manager.h index 6358677ae..2d1dd00f4 100644 --- a/include/PgSQL_HostGroups_Manager.h +++ b/include/PgSQL_HostGroups_Manager.h @@ -242,22 +242,8 @@ class PgSQL_SrvC { // MySQL Server Container }; class PgSQL_SrvList: public BaseSrvList { -#if 0 - private: - PgSQL_HGC *myhgc; - int find_idx(PgSQL_SrvC *); -#endif // 0 public: PgSQL_SrvList(PgSQL_HGC* hgc) : BaseSrvList(hgc) {} -#if 0 - PtrArray *servers; - unsigned int cnt() { return servers->len; } - PgSQL_SrvList(PgSQL_HGC *); - ~PgSQL_SrvList(); - void add(PgSQL_SrvC *); - void remove(PgSQL_SrvC *); - PgSQL_SrvC * idx(unsigned int i) {return (PgSQL_SrvC *)servers->index(i); } -#endif // 0 friend class PgSQL_HGC; }; @@ -268,44 +254,6 @@ class PgSQL_HGC: public BaseHGC { PgSQL_SrvC *get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_lag_ms, PgSQL_Session *sess); }; -#if 0 -class PgSQL_HGC { // MySQL Host Group Container - public: - unsigned int hid; - unsigned long long current_time_now; - uint32_t new_connections_now; - PgSQL_SrvList *mysrvs; - struct { // this is a series of attributes specific for each hostgroup - char * init_connect; - char * comment; - char * ignore_session_variables_text; // this is the original version (text format) of ignore_session_variables - uint32_t max_num_online_servers; - uint32_t throttle_connections_per_sec; - int8_t autocommit; - int8_t free_connections_pct; - int8_t handle_warnings; - bool multiplex; - bool connection_warming; - bool configured; // this variable controls if attributes are configured or not. If not configured, they do not apply - bool initialized; // this variable controls if attributes were ever configured or not. Used by reset_attributes() - nlohmann::json * ignore_session_variables_json = NULL; // the JSON format of ignore_session_variables - } attributes; - struct { - int64_t weight; - int64_t max_connections; - int32_t use_ssl; - } servers_defaults; - void reset_attributes(); - inline - bool handle_warnings_enabled() const { - return attributes.configured == true && attributes.handle_warnings != -1 ? attributes.handle_warnings : mysql_thread___handle_warnings; - } - PgSQL_HGC(int); - ~PgSQL_HGC(); - PgSQL_SrvC *get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_lag_ms, PgSQL_Session *sess); -}; -#endif // 0 - class PgSQL_Group_Replication_Info { public: int writer_hostgroup; diff --git a/lib/BaseHGC.cpp b/lib/BaseHGC.cpp index 8c842d4ce..54b0d4ca5 100644 --- a/lib/BaseHGC.cpp +++ b/lib/BaseHGC.cpp @@ -98,354 +98,6 @@ BaseHGC::~BaseHGC() { delete mysrvs; } -#if 0 -template -TypeSrvC *BaseHGC::get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_lag_ms, TypeSess *sess) { - MySrvC *mysrvc=NULL; - unsigned int j; - unsigned int sum=0; - unsigned int TotalUsedConn=0; - unsigned int l=mysrvs->cnt(); - static time_t last_hg_log = 0; -#ifdef TEST_AURORA - if constexpr (std::is_same_v) { - unsigned long long a1 = array_mysrvc_total/10000; - array_mysrvc_total += l; - unsigned long long a2 = array_mysrvc_total/10000; - if (a2 > a1) { - fprintf(stderr, "Total: %llu, Candidates: %llu\n", array_mysrvc_total-l, array_mysrvc_cands); - } - } -#endif // TEST_AURORA - TypeSrvC *mysrvcCandidates_static[32]; - TypeSrvC **mysrvcCandidates = mysrvcCandidates_static; - unsigned int num_candidates = 0; - bool max_connections_reached = false; - if (l>32) { - mysrvcCandidates = (TypeSrvC **)malloc(sizeof(TypeSrvC *)*l); - } - if (l) { - //int j=0; - for (j=0; jidx(j); - if (mysrvc->get_status() == MYSQL_SERVER_STATUS_ONLINE) { // consider this server only if ONLINE - if (mysrvc->myhgc->num_online_servers.load(std::memory_order_relaxed) <= mysrvc->myhgc->attributes.max_num_online_servers) { // number of online servers in HG is within configured range - if (mysrvc->ConnectionsUsed->conns_length() < mysrvc->max_connections) { // consider this server only if didn't reach max_connections - if (mysrvc->current_latency_us < (mysrvc->max_latency_us ? mysrvc->max_latency_us : mysql_thread___default_max_latency_ms*1000)) { // consider the host only if not too far - if (gtid_trxid) { - if (MyHGM->gtid_exists(mysrvc, gtid_uuid, gtid_trxid)) { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } else { - if (max_lag_ms >= 0) { - if ((unsigned int)max_lag_ms >= mysrvc->aws_aurora_current_lag_us / 1000) { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } else { - sess->thread->status_variables.stvar[st_var_aws_aurora_replicas_skipped_during_query]++; - } - } else { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } - } - } else { - max_connections_reached = true; - } - } else { - mysrvc->myhgc->log_num_online_server_count_error(); - } - } else { - if (mysrvc->get_status() == MYSQL_SERVER_STATUS_SHUNNED) { - // try to recover shunned servers - if (mysrvc->shunned_automatic && mysql_thread___shun_recovery_time_sec) { - time_t t; - t=time(NULL); - // we do all these changes without locking . We assume the server is not used from long - // even if the server is still in used and any of the follow command fails it is not critical - // because this is only an attempt to recover a server that is probably dead anyway - - // the next few lines of code try to solve issue #530 - int max_wait_sec = ( mysql_thread___shun_recovery_time_sec * 1000 >= mysql_thread___connect_timeout_server_max ? mysql_thread___connect_timeout_server_max/1000 - 1 : mysql_thread___shun_recovery_time_sec ); - if (max_wait_sec < 1) { // min wait time should be at least 1 second - max_wait_sec = 1; - } - if (t > mysrvc->time_last_detected_error && (t - mysrvc->time_last_detected_error) > max_wait_sec) { - if ( - (mysrvc->shunned_and_kill_all_connections==false) // it is safe to bring it back online - || - (mysrvc->shunned_and_kill_all_connections==true && mysrvc->ConnectionsUsed->conns_length()==0 && mysrvc->ConnectionsFree->conns_length()==0) // if shunned_and_kill_all_connections is set, ensure all connections are already dropped - ) { -#ifdef DEBUG - if (GloMTH->variables.hostgroup_manager_verbose >= 3) { - proxy_info("Unshunning server %s:%d.\n", mysrvc->address, mysrvc->port); - } -#endif - mysrvc->set_status(MYSQL_SERVER_STATUS_ONLINE); - mysrvc->shunned_automatic=false; - mysrvc->shunned_and_kill_all_connections=false; - mysrvc->connect_ERR_at_time_last_detected_error=0; - mysrvc->time_last_detected_error=0; - // note: the following function scans all the hostgroups. - // This is ok for now because we only have a global mutex. - // If one day we implement a mutex per hostgroup (unlikely, - // but possible), this must be taken into consideration - if (mysql_thread___unshun_algorithm == 1) { - MyHGM->unshun_server_all_hostgroups(mysrvc->address, mysrvc->port, t, max_wait_sec, &mysrvc->myhgc->hid); - } - // if a server is taken back online, consider it immediately - if ( mysrvc->current_latency_us < ( mysrvc->max_latency_us ? mysrvc->max_latency_us : mysql_thread___default_max_latency_ms*1000 ) ) { // consider the host only if not too far - if (gtid_trxid) { - if (MyHGM->gtid_exists(mysrvc, gtid_uuid, gtid_trxid)) { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } else { - if (max_lag_ms >= 0) { - if ((unsigned int)max_lag_ms >= mysrvc->aws_aurora_current_lag_us/1000) { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } else { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } - } - } - } - } - } - } - } - if (max_lag_ms > 0) { // we are using AWS Aurora, as this logic is implemented only here - unsigned int min_num_replicas = sess->thread->variables.aurora_max_lag_ms_only_read_from_replicas; - if (min_num_replicas) { - if (num_candidates >= min_num_replicas) { // there are at least N replicas - // we try to remove the writer - unsigned int total_aws_aurora_current_lag_us=0; - for (j=0; jaws_aurora_current_lag_us; - } - if (total_aws_aurora_current_lag_us) { // we are just double checking that we don't have all servers with aws_aurora_current_lag_us==0 - for (j=0; jaws_aurora_current_lag_us==0) { - sum-=mysrvc->weight; - TotalUsedConn-=mysrvc->ConnectionsUsed->conns_length(); - if (j < num_candidates-1) { - mysrvcCandidates[j]=mysrvcCandidates[num_candidates-1]; - } - num_candidates--; - } - } - } - } - } - } - if (sum==0) { - // per issue #531 , we try a desperate attempt to bring back online any shunned server - // we do this lowering the maximum wait time to 10% - // most of the follow code is copied from few lines above - time_t t; - t=time(NULL); - int max_wait_sec = ( mysql_thread___shun_recovery_time_sec * 1000 >= mysql_thread___connect_timeout_server_max ? mysql_thread___connect_timeout_server_max/10000 - 1 : mysql_thread___shun_recovery_time_sec/10 ); - if (max_wait_sec < 1) { // min wait time should be at least 1 second - max_wait_sec = 1; - } - if (t - last_hg_log > 1) { // log this at most once per second to avoid spamming the logs - last_hg_log = time(NULL); - - if (gtid_trxid) { - proxy_error("Hostgroup %u has no servers ready for GTID '%s:%ld'. Waiting for replication...\n", hid, gtid_uuid, gtid_trxid); - } else { - proxy_error("Hostgroup %u has no servers available%s! Checking servers shunned for more than %u second%s\n", hid, - (max_connections_reached ? " or max_connections reached for all servers" : ""), max_wait_sec, max_wait_sec == 1 ? "" : "s"); - } - } - for (j=0; jidx(j); - if (mysrvc->get_status() == MYSQL_SERVER_STATUS_SHUNNED && mysrvc->shunned_automatic == true) { - if ((t - mysrvc->time_last_detected_error) > max_wait_sec) { - mysrvc->set_status(MYSQL_SERVER_STATUS_ONLINE); - mysrvc->shunned_automatic=false; - mysrvc->connect_ERR_at_time_last_detected_error=0; - mysrvc->time_last_detected_error=0; - // if a server is taken back online, consider it immediately - if ( mysrvc->current_latency_us < ( mysrvc->max_latency_us ? mysrvc->max_latency_us : mysql_thread___default_max_latency_ms*1000 ) ) { // consider the host only if not too far - if (gtid_trxid) { - if (MyHGM->gtid_exists(mysrvc, gtid_uuid, gtid_trxid)) { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } else { - if (max_lag_ms >= 0) { - if ((unsigned int)max_lag_ms >= mysrvc->aws_aurora_current_lag_us/1000) { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } else { - sum+=mysrvc->weight; - TotalUsedConn+=mysrvc->ConnectionsUsed->conns_length(); - mysrvcCandidates[num_candidates]=mysrvc; - num_candidates++; - } - } - } - } - } - } - } - if (sum==0) { - proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySrvC NULL because no backend ONLINE or with weight\n"); - if (l>32) { - free(mysrvcCandidates); - } -#ifdef TEST_AURORA - array_mysrvc_cands += num_candidates; -#endif // TEST_AURORA - return NULL; // if we reach here, we couldn't find any target - } - -/* - unsigned int New_sum=0; - unsigned int New_TotalUsedConn=0; - // we will now scan again to ignore overloaded servers - for (j=0; jConnectionsUsed->conns_length(); - if ((len * sum) <= (TotalUsedConn * mysrvc->weight * 1.5 + 1)) { - - New_sum+=mysrvc->weight; - New_TotalUsedConn+=len; - } else { - // remove the candidate - if (j+1 < num_candidates) { - mysrvcCandidates[j] = mysrvcCandidates[num_candidates-1]; - } - j--; - num_candidates--; - } - } -*/ - - unsigned int New_sum=sum; - - if (New_sum==0) { - proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySrvC NULL because no backend ONLINE or with weight\n"); - if (l>32) { - free(mysrvcCandidates); - } -#ifdef TEST_AURORA - array_mysrvc_cands += num_candidates; -#endif // TEST_AURORA - return NULL; // if we reach here, we couldn't find any target - } - - // latency awareness algorithm is enabled only when compiled with USE_MYSRVC_ARRAY - if (sess && sess->thread->variables.min_num_servers_lantency_awareness) { - if ((int) num_candidates >= sess->thread->variables.min_num_servers_lantency_awareness) { - unsigned int servers_with_latency = 0; - unsigned int total_latency_us = 0; - // scan and verify that all servers have some latency - for (j=0; jcurrent_latency_us) { - servers_with_latency++; - total_latency_us += mysrvc->current_latency_us; - } - } - if (servers_with_latency == num_candidates) { - // all servers have some latency. - // That is good. If any server have no latency, something is wrong - // and we will skip this algorithm - sess->thread->status_variables.stvar[st_var_ConnPool_get_conn_latency_awareness]++; - unsigned int avg_latency_us = 0; - avg_latency_us = total_latency_us/num_candidates; - for (j=0; jcurrent_latency_us > avg_latency_us) { - // remove the candidate - if (j+1 < num_candidates) { - mysrvcCandidates[j] = mysrvcCandidates[num_candidates-1]; - } - j--; - num_candidates--; - } - } - // we scan again to adjust weight - New_sum = 0; - for (j=0; jweight; - } - } - } - } - - - unsigned int k; - if (New_sum > 32768) { - k=rand()%New_sum; - } else { - k=fastrand()%New_sum; - } - k++; - New_sum=0; - - for (j=0; jweight; - if (k<=New_sum) { - proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySrvC %p, server %s:%d\n", mysrvc, mysrvc->address, mysrvc->port); - if (l>32) { - free(mysrvcCandidates); - } -#ifdef TEST_AURORA - array_mysrvc_cands += num_candidates; -#endif // TEST_AURORA - return mysrvc; - } - } - } else { - time_t t = time(NULL); - - if (t - last_hg_log > 1) { - last_hg_log = time(NULL); - proxy_error("Hostgroup %u has no servers available!\n", hid); - } - } - proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySrvC NULL\n"); - if (l>32) { - free(mysrvcCandidates); - } -#ifdef TEST_AURORA - array_mysrvc_cands += num_candidates; -#endif // TEST_AURORA - return NULL; // if we reach here, we couldn't find any target -} -#endif // 0 - - template void BaseHGC::refresh_online_server_count() { if (__sync_fetch_and_add(&glovars.shutdown, 0) != 0) diff --git a/lib/Base_HostGroups_Manager.cpp b/lib/Base_HostGroups_Manager.cpp index 00ccd4d2a..e66635225 100644 --- a/lib/Base_HostGroups_Manager.cpp +++ b/lib/Base_HostGroups_Manager.cpp @@ -62,8 +62,6 @@ class MyHGC; const int MYSQL_ERRORS_STATS_FIELD_NUM = 11; -struct ev_io * new_connector(char *address, uint16_t gtid_port, uint16_t mysql_port); -void * GTID_syncer_run(); static int wait_for_mysql(MYSQL *mysql, int status) { struct pollfd pfd; @@ -1672,119 +1670,6 @@ uint64_t MySQL_HostGroups_Manager::get_mysql_servers_checksum(SQLite3_result* ru return table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS]; } -/** - * @brief Check if a GTID exists for a given MySQL server connection. - * - * This function checks whether a GTID (Global Transaction Identifier) exists for the specified MySQL server connection. - * It performs the following steps: - * 1. Acquires a read lock on the GTID read-write lock. - * 2. Constructs a string representation of the MySQL server address and port. - * 3. Searches for the GTID information associated with the MySQL server in the GTID map using the constructed string as the key. - * 4. If the GTID information is found and is active, it checks whether the specified GTID exists. - * 5. Releases the read lock on the GTID read-write lock. - * - * @param mysrvc A pointer to the MySQL server connection. - * @param gtid_uuid A pointer to the character array representing the GTID UUID. - * @param gtid_trxid The GTID transaction ID. - * @return True if the specified GTID exists for the MySQL server connection, false otherwise. - */ -bool MySQL_HostGroups_Manager::gtid_exists(MySrvC *mysrvc, char * gtid_uuid, uint64_t gtid_trxid) { - bool ret = false; - pthread_rwlock_rdlock(>id_rwlock); - std::string s1 = mysrvc->address; - s1.append(":"); - s1.append(std::to_string(mysrvc->port)); - std::unordered_map ::iterator it2; - it2 = gtid_map.find(s1); - GTID_Server_Data *gtid_is=NULL; - if (it2!=gtid_map.end()) { - gtid_is=it2->second; - if (gtid_is) { - if (gtid_is->active == true) { - ret = gtid_is->gtid_exists(gtid_uuid,gtid_trxid); - } - } - } - //proxy_info("Checking if server %s has GTID %s:%lu . %s\n", s1.c_str(), gtid_uuid, gtid_trxid, (ret ? "YES" : "NO")); - pthread_rwlock_unlock(>id_rwlock); - return ret; -} - -void MySQL_HostGroups_Manager::generate_mysql_gtid_executed_tables() { - pthread_rwlock_wrlock(>id_rwlock); - // first, set them all as active = false - std::unordered_map::iterator it = gtid_map.begin(); - while(it != gtid_map.end()) { - GTID_Server_Data * gtid_si = it->second; - if (gtid_si) { - gtid_si->active = false; - } - it++; - } - - // NOTE: We are required to lock while iterating over 'MyHostGroups'. Otherwise race conditions could take place, - // e.g. servers could be purged by 'purge_mysql_servers_table' and invalid memory be accessed. - wrlock(); - for (unsigned int i=0; ilen; i++) { - MyHGC *myhgc=(MyHGC *)MyHostGroups->index(i); - MySrvC *mysrvc=NULL; - for (unsigned int j=0; jmysrvs->servers->len; j++) { - mysrvc=myhgc->mysrvs->idx(j); - if (mysrvc->gtid_port) { - std::string s1 = mysrvc->address; - s1.append(":"); - s1.append(std::to_string(mysrvc->port)); - std::unordered_map ::iterator it2; - it2 = gtid_map.find(s1); - GTID_Server_Data *gtid_is=NULL; - if (it2!=gtid_map.end()) { - gtid_is=it2->second; - if (gtid_is == NULL) { - gtid_map.erase(it2); - } - } - if (gtid_is) { - gtid_is->active = true; - } else if (mysrvc->get_status() != MYSQL_SERVER_STATUS_OFFLINE_HARD) { - // we didn't find it. Create it - /* - struct ev_io *watcher = (struct ev_io *)malloc(sizeof(struct ev_io)); - gtid_is = new GTID_Server_Data(watcher, mysrvc->address, mysrvc->port, mysrvc->gtid_port); - gtid_map.emplace(s1,gtid_is); - */ - struct ev_io * c = NULL; - c = new_connector(mysrvc->address, mysrvc->gtid_port, mysrvc->port); - if (c) { - gtid_is = (GTID_Server_Data *)c->data; - gtid_map.emplace(s1,gtid_is); - //pthread_mutex_lock(&ev_loop_mutex); - ev_io_start(MyHGM->gtid_ev_loop,c); - //pthread_mutex_unlock(&ev_loop_mutex); - } - } - } - } - } - wrunlock(); - std::vector to_remove; - it = gtid_map.begin(); - while(it != gtid_map.end()) { - GTID_Server_Data * gtid_si = it->second; - if (gtid_si && gtid_si->active == false) { - to_remove.push_back(it->first); - } - it++; - } - for (std::vector::iterator it3=to_remove.begin(); it3!=to_remove.end(); ++it3) { - it = gtid_map.find(*it3); - GTID_Server_Data * gtid_si = it->second; - ev_io_stop(MyHGM->gtid_ev_loop, gtid_si->w); - close(gtid_si->w->fd); - free(gtid_si->w); - gtid_map.erase(*it3); - } - pthread_rwlock_unlock(>id_rwlock); -} /** * @brief Purge the MySQL servers table by removing offline hard servers with no active connections. @@ -5847,106 +5732,6 @@ void MySQL_HostGroups_Manager::converge_galera_config(int _writer_hostgroup) { pthread_mutex_unlock(&Galera_Info_mutex); } -void MySQL_HostGroups_Manager::p_update_mysql_gtid_executed() { - pthread_rwlock_wrlock(>id_rwlock); - - std::unordered_map::iterator it = gtid_map.begin(); - while(it != gtid_map.end()) { - GTID_Server_Data* gtid_si = it->second; - std::string address {}; - std::string port {}; - std::string endpoint_id {}; - - if (gtid_si) { - address = std::string(gtid_si->address); - port = std::to_string(gtid_si->mysql_port); - } else { - std::string s = it->first; - std::size_t found = s.find_last_of(":"); - address = s.substr(0, found); - port = s.substr(found + 1); - } - endpoint_id = address + ":" + port; - - const auto& gitd_id_counter = this->status.p_gtid_executed_map.find(endpoint_id); - prometheus::Counter* gtid_counter = nullptr; - - if (gitd_id_counter == this->status.p_gtid_executed_map.end()) { - auto& gitd_counter = - this->status.p_dyn_counter_array[p_hg_dyn_counter::gtid_executed]; - - gtid_counter = std::addressof(gitd_counter->Add({ - { "hostname", address }, - { "port", port }, - })); - - this->status.p_gtid_executed_map.insert( - { - endpoint_id, - gtid_counter - } - ); - } else { - gtid_counter = gitd_id_counter->second; - } - - if (gtid_si) { - const auto& cur_executed_gtid = gtid_counter->Value(); - gtid_counter->Increment(gtid_si->events_read - cur_executed_gtid); - } - - it++; - } - - pthread_rwlock_unlock(>id_rwlock); -} - -SQLite3_result * MySQL_HostGroups_Manager::get_stats_mysql_gtid_executed() { - const int colnum = 4; - SQLite3_result * result = new SQLite3_result(colnum); - result->add_column_definition(SQLITE_TEXT,"hostname"); - result->add_column_definition(SQLITE_TEXT,"port"); - result->add_column_definition(SQLITE_TEXT,"gtid_executed"); - result->add_column_definition(SQLITE_TEXT,"events"); - int k; - pthread_rwlock_wrlock(>id_rwlock); - std::unordered_map::iterator it = gtid_map.begin(); - while(it != gtid_map.end()) { - GTID_Server_Data * gtid_si = it->second; - char buf[64]; - char **pta=(char **)malloc(sizeof(char *)*colnum); - if (gtid_si) { - pta[0]=strdup(gtid_si->address); - sprintf(buf,"%d", (int)gtid_si->mysql_port); - pta[1]=strdup(buf); - //sprintf(buf,"%d", mysrvc->port); - string s1 = gtid_executed_to_string(gtid_si->gtid_executed); - pta[2]=strdup(s1.c_str()); - sprintf(buf,"%llu", gtid_si->events_read); - pta[3]=strdup(buf); - } else { - std::string s = it->first; - std::size_t found=s.find_last_of(":"); - std::string host=s.substr(0,found); - std::string port=s.substr(found+1); - pta[0]=strdup(host.c_str()); - pta[1]=strdup(port.c_str()); - pta[2]=strdup((char *)"NULL"); - pta[3]=strdup((char *)"0"); - } - result->add_row(pta); - for (k=0; kis_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); - if (mysrvc->get_status() == MYSQL_SERVER_STATUS_ONLINE) { - online_servers_count++; - } - } - num_online_servers.store(online_servers_count, std::memory_order_relaxed); -} - -void MyHGC::log_num_online_server_count_error() { - const time_t curtime = time(NULL); - // if this is the first time the method is called or if more than 10 seconds have passed since the last log - if (last_log_time_num_online_servers == 0 || - ((curtime - last_log_time_num_online_servers) > 10)) { - last_log_time_num_online_servers = curtime; - proxy_error( - "Number of online servers detected in a hostgroup exceeds the configured maximum online servers. hostgroup:%u, num_online_servers:%u, max_online_servers:%u\n", - hid, num_online_servers.load(std::memory_order_relaxed), attributes.max_num_online_servers); - } -} -#endif // 0 diff --git a/lib/MySrvList.cpp b/lib/MySrvList.cpp deleted file mode 100644 index 6cf491f70..000000000 --- a/lib/MySrvList.cpp +++ /dev/null @@ -1,48 +0,0 @@ -#if 0 -#include "MySQL_HostGroups_Manager.h" - -class MySrvConnList; -class MySrvC; -class MySrvList; -class MyHGC; - -MySrvList::MySrvList(MyHGC *_myhgc) { - myhgc=_myhgc; - servers=new PtrArray(); -} - -void MySrvList::add(MySrvC *s) { - if (s->myhgc==NULL) { - s->myhgc=myhgc; - } - servers->add(s); - myhgc->refresh_online_server_count(); -} - - -int MySrvList::find_idx(MySrvC *s) { - for (unsigned int i=0; ilen; i++) { - MySrvC *mysrv=(MySrvC *)servers->index(i); - if (mysrv==s) { - return (unsigned int)i; - } - } - return -1; -} - -void MySrvList::remove(MySrvC *s) { - int i=find_idx(s); - assert(i>=0); - servers->remove_index_fast((unsigned int)i); - myhgc->refresh_online_server_count(); -} - -MySrvList::~MySrvList() { - myhgc=NULL; - while (servers->len) { - MySrvC *mysrvc=(MySrvC *)servers->remove_index_fast(0); - delete mysrvc; - } - delete servers; -} -#endif // 0 diff --git a/lib/PgSQL_HostGroups_Manager.cpp b/lib/PgSQL_HostGroups_Manager.cpp index 87d6224d0..8c37ca8c0 100644 --- a/lib/PgSQL_HostGroups_Manager.cpp +++ b/lib/PgSQL_HostGroups_Manager.cpp @@ -69,39 +69,6 @@ static pthread_mutex_t ev_loop_mutex; const int PgSQL_ERRORS_STATS_FIELD_NUM = 11; -#if 0 -static std::string gtid_executed_to_string(gtid_set_t & gtid_executed); -static void addGtid(const gtid_t & gtid, gtid_set_t & gtid_executed); - -static void gtid_async_cb(struct ev_loop *loop, struct ev_async *watcher, int revents) { - if (glovars.shutdown) { - ev_break(loop); - } - pthread_mutex_lock(&ev_loop_mutex); - PgHGM->gtid_missing_nodes = false; - PgHGM->generate_pgsql_gtid_executed_tables(); - pthread_mutex_unlock(&ev_loop_mutex); - return; -} - -static void gtid_timer_cb (struct ev_loop *loop, struct ev_timer *timer, int revents) { - if (GloMTH == nullptr) { return; } - ev_timer_stop(loop, timer); - ev_timer_set(timer, __sync_add_and_fetch(&GloMTH->variables.binlog_reader_connect_retry_msec,0)/1000, 0); - if (glovars.shutdown) { - ev_break(loop); - } - if (PgHGM->gtid_missing_nodes) { - pthread_mutex_lock(&ev_loop_mutex); - PgHGM->gtid_missing_nodes = false; - PgHGM->generate_pgsql_gtid_executed_tables(); - pthread_mutex_unlock(&ev_loop_mutex); - } - ev_timer_start(loop, timer); - return; -} -#endif // 0 - static int wait_for_pgsql(MYSQL *mysql, int status) { struct pollfd pfd; int timeout, res; @@ -169,435 +136,6 @@ T PgSQL_j_get_srv_default_int_val( return static_cast(-1); } -#if 0 -static void reader_cb(struct ev_loop *loop, struct ev_io *w, int revents) { - pthread_mutex_lock(&ev_loop_mutex); - if (revents & EV_READ) { - PgSQL_GTID_Server_Data *sd = (PgSQL_GTID_Server_Data *)w->data; - bool rc = true; - rc = sd->readall(); - if (rc == false) { - //delete sd; - std::string s1 = sd->address; - s1.append(":"); - s1.append(std::to_string(sd->pgsql_port)); - PgHGM->gtid_missing_nodes = true; - proxy_warning("GTID: failed to connect to ProxySQL binlog reader on port %d for server %s:%d\n", sd->port, sd->address, sd->pgsql_port); - std::unordered_map ::iterator it2; - it2 = PgHGM->gtid_map.find(s1); - if (it2 != PgHGM->gtid_map.end()) { - //PgHGM->gtid_map.erase(it2); - it2->second = NULL; - delete sd; - } - ev_io_stop(PgHGM->gtid_ev_loop, w); - free(w); - } else { - sd->dump(); - } - } - pthread_mutex_unlock(&ev_loop_mutex); -} - -static void connect_cb(EV_P_ ev_io *w, int revents) { - pthread_mutex_lock(&ev_loop_mutex); - struct ev_io * c = w; - if (revents & EV_WRITE) { - int optval = 0; - socklen_t optlen = sizeof(optval); - if ((getsockopt(w->fd, SOL_SOCKET, SO_ERROR, &optval, &optlen) == -1) || - (optval != 0)) { - /* Connection failed; try the next address in the list. */ - //int errnum = optval ? optval : errno; - ev_io_stop(PgHGM->gtid_ev_loop, w); - close(w->fd); - PgHGM->gtid_missing_nodes = true; - PgSQL_GTID_Server_Data * custom_data = (PgSQL_GTID_Server_Data *)w->data; - PgSQL_GTID_Server_Data *sd = custom_data; - std::string s1 = sd->address; - s1.append(":"); - s1.append(std::to_string(sd->pgsql_port)); - proxy_warning("GTID: failed to connect to ProxySQL binlog reader on port %d for server %s:%d\n", sd->port, sd->address, sd->pgsql_port); - std::unordered_map ::iterator it2; - it2 = PgHGM->gtid_map.find(s1); - if (it2 != PgHGM->gtid_map.end()) { - //PgHGM->gtid_map.erase(it2); - it2->second = NULL; - delete sd; - } - //delete custom_data; - free(c); - } else { - ev_io_stop(PgHGM->gtid_ev_loop, w); - int fd=w->fd; - struct ev_io * new_w = (struct ev_io*) malloc(sizeof(struct ev_io)); - new_w->data = w->data; - PgSQL_GTID_Server_Data * custom_data = (PgSQL_GTID_Server_Data *)new_w->data; - custom_data->w = new_w; - free(w); - ev_io_init(new_w, reader_cb, fd, EV_READ); - ev_io_start(PgHGM->gtid_ev_loop, new_w); - } - } - pthread_mutex_unlock(&ev_loop_mutex); -} - -static struct ev_io * new_connector(char *address, uint16_t gtid_port, uint16_t pgsql_port) { - //struct sockaddr_in a; - int s; - - if ((s = socket(AF_INET, SOCK_STREAM, 0)) == -1) { - perror("socket"); - close(s); - return NULL; - } -/* - memset(&a, 0, sizeof(a)); - a.sin_port = htons(gtid_port); - a.sin_family = AF_INET; - if (!inet_aton(address, (struct in_addr *) &a.sin_addr.s_addr)) { - perror("bad IP address format"); - close(s); - return NULL; - } -*/ - ioctl_FIONBIO(s,1); - - struct addrinfo hints; - struct addrinfo *res = NULL; - memset(&hints, 0, sizeof(hints)); - hints.ai_protocol= IPPROTO_TCP; - hints.ai_family= AF_UNSPEC; - hints.ai_socktype= SOCK_STREAM; - - char str_port[NI_MAXSERV+1]; - sprintf(str_port,"%d", gtid_port); - int gai_rc = getaddrinfo(address, str_port, &hints, &res); - if (gai_rc) { - freeaddrinfo(res); - //exit here - return NULL; - } - - //int status = connect(s, (struct sockaddr *) &a, sizeof(a)); - int status = connect(s, res->ai_addr, res->ai_addrlen); - if ((status == 0) || ((status == -1) && (errno == EINPROGRESS))) { - struct ev_io *c = (struct ev_io *)malloc(sizeof(struct ev_io)); - if (c) { - ev_io_init(c, connect_cb, s, EV_WRITE); - PgSQL_GTID_Server_Data * custom_data = new PgSQL_GTID_Server_Data(c, address, gtid_port, pgsql_port); - c->data = (void *)custom_data; - return c; - } - /* else error */ - } - return NULL; -} - - - -PgSQL_GTID_Server_Data::PgSQL_GTID_Server_Data(struct ev_io *_w, char *_address, uint16_t _port, uint16_t _pgsql_port) { - active = true; - w = _w; - size = 1024; // 1KB buffer - data = (char *)malloc(size); - memset(uuid_server, 0, sizeof(uuid_server)); - pos = 0; - len = 0; - address = strdup(_address); - port = _port; - pgsql_port = _pgsql_port; - events_read = 0; -} - -void PgSQL_GTID_Server_Data::resize(size_t _s) { - char *data_ = (char *)malloc(_s); - memcpy(data_, data, (_s > size ? size : _s)); - size = _s; - free(data); - data = data_; -} - -PgSQL_GTID_Server_Data::~PgSQL_GTID_Server_Data() { - free(address); - free(data); -} - -bool PgSQL_GTID_Server_Data::readall() { - bool ret = true; - if (size == len) { - // buffer is full, expand - resize(len*2); - } - int rc = 0; - rc = read(w->fd,data+len,size-len); - if (rc > 0) { - len += rc; - } else { - int myerr = errno; - proxy_error("Read returned %d bytes, error %d\n", rc, myerr); - if ( - (rc == 0) || - (rc==-1 && myerr != EINTR && myerr != EAGAIN) - ) { - ret = false; - } - } - return ret; -} - - -bool PgSQL_GTID_Server_Data::gtid_exists(char *gtid_uuid, uint64_t gtid_trxid) { - std::string s = gtid_uuid; - auto it = gtid_executed.find(s); -// fprintf(stderr,"Checking if server %s:%d has GTID %s:%lu ... ", address, port, gtid_uuid, gtid_trxid); - if (it == gtid_executed.end()) { -// fprintf(stderr,"NO\n"); - return false; - } - for (auto itr = it->second.begin(); itr != it->second.end(); ++itr) { - if ((int64_t)gtid_trxid >= itr->first && (int64_t)gtid_trxid <= itr->second) { -// fprintf(stderr,"YES\n"); - return true; - } - } -// fprintf(stderr,"NO\n"); - return false; -} - -void PgSQL_GTID_Server_Data::read_all_gtids() { - while (read_next_gtid()) { - } - } - -void PgSQL_GTID_Server_Data::dump() { - if (len==0) { - return; - } - read_all_gtids(); - //int rc = write(1,data+pos,len-pos); - fflush(stdout); - ///pos += rc; - if (pos >= len/2) { - memmove(data,data+pos,len-pos); - len = len-pos; - pos = 0; - } -} - -bool PgSQL_GTID_Server_Data::writeout() { - bool ret = true; - if (len==0) { - return ret; - } - int rc = 0; - rc = write(w->fd,data+pos,len-pos); - if (rc > 0) { - pos += rc; - if (pos >= len/2) { - memmove(data,data+pos,len-pos); - len = len-pos; - pos = 0; - } - } - return ret; -} - -bool PgSQL_GTID_Server_Data::read_next_gtid() { - if (len==0) { - return false; - } - void *nlp = NULL; - nlp = memchr(data+pos,'\n',len-pos); - if (nlp == NULL) { - return false; - } - int l = (char *)nlp - (data+pos); - char rec_msg[80]; - if (strncmp(data+pos,(char *)"ST=",3)==0) { - // we are reading the bootstrap - char *bs = (char *)malloc(l+1-3); // length + 1 (null byte) - 3 (header) - memcpy(bs, data+pos+3, l-3); - bs[l-3] = '\0'; - char *saveptr1=NULL; - char *saveptr2=NULL; - //char *saveptr3=NULL; - char *token = NULL; - char *subtoken = NULL; - //char *subtoken2 = NULL; - char *str1 = NULL; - char *str2 = NULL; - //char *str3 = NULL; - for (str1 = bs; ; str1 = NULL) { - token = strtok_r(str1, ",", &saveptr1); - if (token == NULL) { - break; - } - int j = 0; - for (str2 = token; ; str2 = NULL) { - subtoken = strtok_r(str2, ":", &saveptr2); - if (subtoken == NULL) { - break; - } - j++; - if (j%2 == 1) { // we are reading the uuid - char *p = uuid_server; - for (unsigned int k=0; kfirst; - s.insert(8,"-"); - s.insert(13,"-"); - s.insert(18,"-"); - s.insert(23,"-"); - s = s + ":"; - for (auto itr = it->second.begin(); itr != it->second.end(); ++itr) { - std::string s2 = s; - s2 = s2 + std::to_string(itr->first); - s2 = s2 + "-"; - s2 = s2 + std::to_string(itr->second); - s2 = s2 + ","; - gtid_set = gtid_set + s2; - } - } - // Extract latest comma only in case 'gtid_executed' isn't empty - if (gtid_set.empty() == false) { - gtid_set.pop_back(); - } - return gtid_set; -} - - - -static void addGtid(const gtid_t& gtid, gtid_set_t& gtid_executed) { - auto it = gtid_executed.find(gtid.first); - if (it == gtid_executed.end()) - { - gtid_executed[gtid.first].emplace_back(gtid.second, gtid.second); - return; - } - - bool flag = true; - for (auto itr = it->second.begin(); itr != it->second.end(); ++itr) - { - if (gtid.second >= itr->first && gtid.second <= itr->second) - return; - if (gtid.second + 1 == itr->first) - { - --itr->first; - flag = false; - break; - } - else if (gtid.second == itr->second + 1) - { - ++itr->second; - flag = false; - break; - } - else if (gtid.second < itr->first) - { - it->second.emplace(itr, gtid.second, gtid.second); - return; - } - } - - if (flag) - it->second.emplace_back(gtid.second, gtid.second); - - for (auto itr = it->second.begin(); itr != it->second.end(); ++itr) - { - auto next_itr = std::next(itr); - if (next_itr != it->second.end() && itr->second + 1 == next_itr->first) - { - itr->second = next_itr->second; - it->second.erase(next_itr); - break; - } - } -} - -static void * GTID_syncer_run() { - //struct ev_loop * gtid_ev_loop; - //gtid_ev_loop = NULL; - PgHGM->gtid_ev_loop = ev_loop_new (EVBACKEND_POLL | EVFLAG_NOENV); - if (PgHGM->gtid_ev_loop == NULL) { - proxy_error("could not initialise GTID sync loop\n"); - exit(EXIT_FAILURE); - } - //ev_async_init(gtid_ev_async, gtid_async_cb); - //ev_async_start(gtid_ev_loop, gtid_ev_async); - PgHGM->gtid_ev_timer = (struct ev_timer *)malloc(sizeof(struct ev_timer)); - ev_async_init(PgHGM->gtid_ev_async, gtid_async_cb); - ev_async_start(PgHGM->gtid_ev_loop, PgHGM->gtid_ev_async); - //ev_timer_init(PgHGM->gtid_ev_timer, gtid_timer_cb, __sync_add_and_fetch(&GloMTH->variables.binlog_reader_connect_retry_msec,0)/1000, 0); - ev_timer_init(PgHGM->gtid_ev_timer, gtid_timer_cb, 3, 0); - ev_timer_start(PgHGM->gtid_ev_loop, PgHGM->gtid_ev_timer); - //ev_ref(gtid_ev_loop); - ev_run(PgHGM->gtid_ev_loop, 0); - //sleep(1000); - return NULL; -} -#endif // 0 - //static void * HGCU_thread_run() { static void * HGCU_thread_run() { PtrArray *conn_array=new PtrArray(); @@ -725,12 +263,6 @@ PgSQL_Connection * PgSQL_SrvConnList::remove(int _k) { return (PgSQL_Connection *)conns->remove_index_fast(_k); } -/* -unsigned int PgSQL_SrvConnList::conns_length() { - return conns->len; -} -*/ - PgSQL_SrvConnList::PgSQL_SrvConnList(PgSQL_SrvC *_mysrvc) { mysrvc=_mysrvc; conns=new PtrArray(); @@ -749,37 +281,6 @@ PgSQL_SrvConnList::~PgSQL_SrvConnList() { delete conns; } -#if 0 -PgSQL_SrvList::PgSQL_SrvList(PgSQL_HGC *_myhgc) { - myhgc=_myhgc; - servers=new PtrArray(); -} - -void PgSQL_SrvList::add(PgSQL_SrvC *s) { - if (s->myhgc==NULL) { - s->myhgc=myhgc; - } - servers->add(s); -} - - -int PgSQL_SrvList::find_idx(PgSQL_SrvC *s) { - for (unsigned int i=0; ilen; i++) { - PgSQL_SrvC *mysrv=(PgSQL_SrvC *)servers->index(i); - if (mysrv==s) { - return (unsigned int)i; - } - } - return -1; -} - -void PgSQL_SrvList::remove(PgSQL_SrvC *s) { - int i=find_idx(s); - assert(i>=0); - servers->remove_index_fast((unsigned int)i); -} -#endif // 0 - void PgSQL_SrvConnList::drop_all_connections() { proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Dropping all connections (%u total) on PgSQL_SrvConnList %p for server %s:%d , hostgroup=%d , status=%d\n", conns_length(), this, mysrvc->address, mysrvc->port, mysrvc->myhgc->hid, mysrvc->status); while (conns_length()) { @@ -926,62 +427,6 @@ PgSQL_SrvC::~PgSQL_SrvC() { delete ConnectionsFree; } -#if 0 -PgSQL_SrvList::~PgSQL_SrvList() { - myhgc=NULL; - while (servers->len) { - PgSQL_SrvC *mysrvc=(PgSQL_SrvC *)servers->remove_index_fast(0); - delete mysrvc; - } - delete servers; -} - -PgSQL_HGC::PgSQL_HGC(int _hid) { - hid=_hid; - mysrvs=new PgSQL_SrvList(this); - current_time_now = 0; - new_connections_now = 0; - attributes.initialized = false; - reset_attributes(); - // Uninitialized server defaults. Should later be initialized via 'pgsql_hostgroup_attributes'. - servers_defaults.weight = -1; - servers_defaults.max_connections = -1; - servers_defaults.use_ssl = -1; -} - -void PgSQL_HGC::reset_attributes() { - if (attributes.initialized == false) { - attributes.init_connect = NULL; - attributes.comment = NULL; - attributes.ignore_session_variables_text = NULL; - } - attributes.initialized = true; - attributes.configured = false; - attributes.max_num_online_servers = 1000000; - attributes.throttle_connections_per_sec = 1000000; - attributes.autocommit = -1; - attributes.free_connections_pct = 10; - attributes.handle_warnings = -1; - attributes.multiplex = true; - attributes.connection_warming = false; - free(attributes.init_connect); - attributes.init_connect = NULL; - free(attributes.comment); - attributes.comment = NULL; - free(attributes.ignore_session_variables_text); - attributes.ignore_session_variables_text = NULL; - if (attributes.ignore_session_variables_json) { - delete attributes.ignore_session_variables_json; - attributes.ignore_session_variables_json = NULL; - } -} - -PgSQL_HGC::~PgSQL_HGC() { - reset_attributes(); // free all memory - delete mysrvs; -} -#endif // 0 - using metric_name = std::string; using metric_help = std::string; using metric_tags = std::map;