From e0e06711d8343bc15aab36402e8a64057c445390 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Wed, 8 Mar 2023 12:33:04 +0500 Subject: [PATCH 01/11] Some improvements and fixes --- include/MySQL_HostGroups_Manager.h | 17 +++-- lib/MySQL_HostGroups_Manager.cpp | 99 ++++++++++++++---------------- 2 files changed, 52 insertions(+), 64 deletions(-) diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 8f21cb56ff..189a78c1ed 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -402,13 +402,15 @@ class MySQL_HostGroups_Manager { __HGM_TABLES_SIZE }; - std::array table_resultset_checksum; + std::array table_resultset_checksum { 0 }; class HostGroup_Server_Mapping { public: enum Type { WRITER = 0, - READER = 1 + READER = 1, + + __TYPE_SIZE }; struct Node { @@ -418,7 +420,7 @@ class MySQL_HostGroups_Manager { MySerStatus server_status = MYSQL_SERVER_STATUS_OFFLINE_HARD; }; - HostGroup_Server_Mapping() : readonly_flag(1), myHGM(NULL) { } + HostGroup_Server_Mapping(MySQL_HostGroups_Manager* hgm) : readonly_flag(1), myHGM(hgm) { } ~HostGroup_Server_Mapping() = default; // Note: copy, remove, clear method also makes changes to MyHostGroups @@ -452,23 +454,18 @@ class MySQL_HostGroups_Manager { return readonly_flag; } - inline - void set_HGM(MySQL_HostGroups_Manager* hgm) { - myHGM = hgm; - } - private: unsigned int get_hostgroup_id(Type type, size_t index) const; unsigned int get_hostgroup_id(Type type, const Node& node) const; MySrvC* insert_HGM(unsigned int hostgroup_id, const MySrvC* srv); void remove_HGM(MySrvC* srv); - std::array, 2> mapping; + std::array, __TYPE_SIZE> mapping; // index 0 contains reader and 1 contains writer hostgroups int readonly_flag; MySQL_HostGroups_Manager* myHGM; }; - std::unordered_map hostgroup_server_mapping; + std::unordered_map> hostgroup_server_mapping; uint64_t hgsm_mysql_servers_checksum = 0; uint64_t hgsm_mysql_replication_hostgroups_checksum = 0; diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index ff016f42d9..96d52f7925 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -1930,6 +1930,7 @@ bool MySQL_HostGroups_Manager::commit( delete resultset; } else { proxy_info("Checksum for table %s is 0x%lX\n", "mysql_servers", (long unsigned int)0); + table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS] = 0; } } @@ -1970,9 +1971,9 @@ bool MySQL_HostGroups_Manager::commit( int affected_rows = 0; SQLite3_result* resultset = NULL; - const char* query = "SELECT DISTINCT hostname, port, '1' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=writer_hostgroup \ + const char* query = "SELECT DISTINCT hostname, port, '1' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=writer_hostgroup WHERE status<>3 \ UNION \ - SELECT DISTINCT hostname, port, '0' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=reader_hostgroup \ + SELECT DISTINCT hostname, port, '0' is_writer, status, reader_hostgroup, writer_hostgroup, mem_pointer FROM mysql_replication_hostgroups JOIN mysql_servers ON hostgroup_id=reader_hostgroup WHERE status<>3 \ ORDER BY hostname, port"; mydb->execute_statement(query, &error, &cols, &affected_rows, &resultset); @@ -1989,8 +1990,18 @@ bool MySQL_HostGroups_Manager::commit( const std::string& server_id = std::string(r->fields[0]) + ":::" + r->fields[1]; if (fetched_server_mapping == NULL || server_id != fetched_server_id) { - fetched_server_mapping = &hostgroup_server_mapping[server_id]; - fetched_server_mapping->set_HGM(this); + + auto itr = hostgroup_server_mapping.find(server_id); + + if (itr == hostgroup_server_mapping.end()) { + std::unique_ptr server_mapping(new HostGroup_Server_Mapping(this)); + fetched_server_mapping = server_mapping.get(); + hostgroup_server_mapping.insert({ server_id, std::move(server_mapping) }); + } + else { + fetched_server_mapping = itr->second.get(); + } + fetched_server_id = server_id; } @@ -4582,27 +4593,12 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listsecond; - - const std::vector& writer_map = host_server_mapping.get(HostGroup_Server_Mapping::Type::WRITER); - const std::vector& reader_map = host_server_mapping.get(HostGroup_Server_Mapping::Type::READER); - - bool removed_offline_server = false; + HostGroup_Server_Mapping* host_server_mapping = itr->second.get(); - for (size_t i = 0; i < writer_map.size();) { - - const HostGroup_Server_Mapping::Node& node = writer_map[i]; - - // remove offline hard server node from writer map - if (node.server_status == MYSQL_SERVER_STATUS_OFFLINE_HARD) { - proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Removing server %s:%d in hostgroup=%d having status='OFFLINE_HARD'\n", hostname.c_str(), port, node.writer_hostgroup_id); - host_server_mapping.remove(HostGroup_Server_Mapping::Type::WRITER, i); - removed_offline_server = true; - continue; - } + if (!host_server_mapping) + assert(0); - i++; - } + const std::vector& writer_map = host_server_mapping->get(HostGroup_Server_Mapping::Type::WRITER); is_writer = !writer_map.empty(); @@ -4610,14 +4606,14 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); if (mysql_thread___monitor_writer_is_also_reader) { // server is also a reader, we copy all nodes from writer to reader (previous reader nodes will be reused) - host_server_mapping.copy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); + host_server_mapping->copy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); } else { // server can only be a writer - host_server_mapping.clear(HostGroup_Server_Mapping::Type::READER); + host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER); } update_mysql_servers_table = true; @@ -4625,12 +4621,12 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listget_readonly_flag() != 0) { // it is the first time that we detect RO on this server - - act = removed_offline_server; if (act == false) { + const std::vector& reader_map = host_server_mapping->get(HostGroup_Server_Mapping::Type::READER); + for (const auto& reader_node : reader_map) { for (const auto& writer_node : writer_map) { @@ -4648,7 +4644,7 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listset_readonly_flag(0); } } else { // the server was already detected as RO=0 @@ -4658,14 +4654,14 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); if (mysql_thread___monitor_writer_is_also_reader) { // server is also a reader, we copy all nodes from writer to reader (previous reader nodes will be reused) - host_server_mapping.copy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); + host_server_mapping->copy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); } else { // server can only be a writer - host_server_mapping.clear(HostGroup_Server_Mapping::Type::READER); + host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER); } update_mysql_servers_table = true; @@ -4674,10 +4670,10 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); // clearing all writer nodes - host_server_mapping.clear(HostGroup_Server_Mapping::Type::WRITER); + host_server_mapping->clear(HostGroup_Server_Mapping::Type::WRITER); update_mysql_servers_table = true; } @@ -4718,29 +4714,24 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listmyhgc->hid, srv->address, srv->port); srv->status = MYSQL_SERVER_STATUS_OFFLINE_HARD; srv->ConnectionsFree->drop_all_connections(); -} \ No newline at end of file +} From 3c3112ab2daa3ddb6fd1b575742a46d516093c12 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Wed, 8 Mar 2023 23:45:34 +0500 Subject: [PATCH 02/11] Calculate hash only if initialized --- lib/MySQL_HostGroups_Manager.cpp | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 96d52f7925..f08a0d9842 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -4733,7 +4733,9 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::list Date: Thu, 9 Mar 2023 12:09:39 +0500 Subject: [PATCH 03/11] Removed update code from copy and renamed method to copy_if_not_exists --- include/MySQL_HostGroups_Manager.h | 10 +---- lib/MySQL_HostGroups_Manager.cpp | 60 ++++++++++++------------------ 2 files changed, 25 insertions(+), 45 deletions(-) diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 189a78c1ed..f7cac8cc5f 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -423,8 +423,8 @@ class MySQL_HostGroups_Manager { HostGroup_Server_Mapping(MySQL_HostGroups_Manager* hgm) : readonly_flag(1), myHGM(hgm) { } ~HostGroup_Server_Mapping() = default; - // Note: copy, remove, clear method also makes changes to MyHostGroups - void copy(Type dest_type, Type src_type, bool update_if_exists = true); + // Note: copy_if_not_exists, remove, clear method also makes changes to MyHostGroups + void copy_if_not_exists(Type dest_type, Type src_type); void remove(Type type, size_t index); void clear(Type type); // @@ -439,11 +439,6 @@ class MySQL_HostGroups_Manager { mapping[type].push_back(node); } - inline - void set(Type type, const std::vector& nodes) { - mapping[type] = nodes; - } - inline void set_readonly_flag(int val) { readonly_flag = val; @@ -455,7 +450,6 @@ class MySQL_HostGroups_Manager { } private: - unsigned int get_hostgroup_id(Type type, size_t index) const; unsigned int get_hostgroup_id(Type type, const Node& node) const; MySrvC* insert_HGM(unsigned int hostgroup_id, const MySrvC* srv); void remove_HGM(MySrvC* srv); diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index f08a0d9842..59590d2c91 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -4572,6 +4572,14 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re free(query); } +/** + * @brief New implementation of the read_only_action method that does not depend on the admin table. + * The method checks each server in the provided list and adjusts the servers according to their corresponding read_only value. + * If any change has occured, checksum is calculated. + * + * @param mysql_servers List of servers having hostname, port and read only value. + * + */ void MySQL_HostGroups_Manager::read_only_action_v2(const std::list>& mysql_servers) { std::string hostname; @@ -4606,11 +4614,11 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); + host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); if (mysql_thread___monitor_writer_is_also_reader) { // server is also a reader, we copy all nodes from writer to reader (previous reader nodes will be reused) - host_server_mapping->copy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); + host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER); } else { // server can only be a writer host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER); @@ -4623,22 +4631,19 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listget_readonly_flag() != 0) { // it is the first time that we detect RO on this server + const std::vector& reader_map = host_server_mapping->get(HostGroup_Server_Mapping::Type::READER); - if (act == false) { - const std::vector& reader_map = host_server_mapping->get(HostGroup_Server_Mapping::Type::READER); - - for (const auto& reader_node : reader_map) { - for (const auto& writer_node : writer_map) { + for (const auto& reader_node : reader_map) { + for (const auto& writer_node : writer_map) { - if (reader_node.writer_hostgroup_id == writer_node.writer_hostgroup_id) { - goto __writer_found; - } + if (reader_node.writer_hostgroup_id == writer_node.writer_hostgroup_id) { + goto __writer_found; } - act = true; - break; - __writer_found: - continue; } + act = true; + break; + __writer_found: + continue; } if (act == false) { @@ -4654,11 +4659,11 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); + host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); if (mysql_thread___monitor_writer_is_also_reader) { // server is also a reader, we copy all nodes from writer to reader (previous reader nodes will be reused) - host_server_mapping->copy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); + host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER); } else { // server can only be a writer host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER); @@ -4670,7 +4675,7 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER, false); + host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER); // clearing all writer nodes host_server_mapping->clear(HostGroup_Server_Mapping::Type::WRITER); @@ -7625,7 +7630,7 @@ MySrvC* MySQL_HostGroups_Manager::find_server_in_hg(unsigned int _hid, const std return f_server; } -void MySQL_HostGroups_Manager::HostGroup_Server_Mapping::copy(Type dest_type, Type src_type, bool update_if_exists /*= true*/) { +void MySQL_HostGroups_Manager::HostGroup_Server_Mapping::copy_if_not_exists(Type dest_type, Type src_type) { const std::vector& src_nodes = mapping[src_type]; @@ -7640,15 +7645,6 @@ void MySQL_HostGroups_Manager::HostGroup_Server_Mapping::copy(Type dest_type, Ty if (src_node.reader_hostgroup_id == dest_node.reader_hostgroup_id && src_node.writer_hostgroup_id == dest_node.writer_hostgroup_id) { - - if (update_if_exists) { - MySrvC* new_srv = insert_HGM(get_hostgroup_id(dest_type, dest_node), src_node.srv); - - if (!new_srv) assert(0); - - dest_node.srv = new_srv; - dest_node.server_status = src_node.server_status; - } goto __skip; } } @@ -7703,16 +7699,6 @@ void MySQL_HostGroups_Manager::HostGroup_Server_Mapping::clear(Type type) { mapping[type].clear(); } -unsigned int MySQL_HostGroups_Manager::HostGroup_Server_Mapping::get_hostgroup_id(Type type, size_t index) const { - - if (type == Type::WRITER) - return mapping[Type::WRITER][index].writer_hostgroup_id; - else if (type == Type::READER) - return mapping[Type::READER][index].reader_hostgroup_id; - else - assert(0); -} - unsigned int MySQL_HostGroups_Manager::HostGroup_Server_Mapping::get_hostgroup_id(Type type, const Node& node) const { if (type == Type::WRITER) From 44b09e0a64b45cd4890e3cfe2adb00679a157ff4 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Thu, 9 Mar 2023 14:46:03 +0500 Subject: [PATCH 04/11] Revert "Removed incoming_replication_hostgroups flag" This reverts commit 3aa4055109ef61bdaa399b288dfa427e71f71cfe. --- lib/MySQL_HostGroups_Manager.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 59590d2c91..cfeca2f2e6 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -1833,11 +1833,12 @@ bool MySQL_HostGroups_Manager::commit( proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "DELETE FROM mysql_servers_incoming\n"); mydb->execute("DELETE FROM mysql_servers_incoming"); - proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "DELETE FROM mysql_replication_hostgroups\n"); - mydb->execute("DELETE FROM mysql_replication_hostgroups"); - - generate_mysql_replication_hostgroups_table(); - + // replication + if (incoming_replication_hostgroups) { // this IF is extremely important, otherwise replication hostgroups may disappear + proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 4, "DELETE FROM mysql_replication_hostgroups\n"); + mydb->execute("DELETE FROM mysql_replication_hostgroups"); + generate_mysql_replication_hostgroups_table(); + } // group replication if (incoming_group_replication_hostgroups) { From d1700b45047aad12fc93be91e42db1c882f14160 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Fri, 10 Mar 2023 00:14:39 +0500 Subject: [PATCH 05/11] Resetting checksum before recalculation --- lib/MySQL_HostGroups_Manager.cpp | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index cfeca2f2e6..8ec0db1f35 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -1915,6 +1915,9 @@ bool MySQL_HostGroups_Manager::commit( save_runtime_mysql_servers(runtime_mysql_servers); } + // reset all checksum + table_resultset_checksum.fill(0); + if (resultset) { if (resultset->rows_count) { if (init == false) { @@ -1931,7 +1934,6 @@ bool MySQL_HostGroups_Manager::commit( delete resultset; } else { proxy_info("Checksum for table %s is 0x%lX\n", "mysql_servers", (long unsigned int)0); - table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS] = 0; } } @@ -4708,6 +4710,10 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::list3 ORDER BY hostgroup_id, hostname, port"; mydb->execute_statement(query, &error, &cols, &affected_rows, &resultset); @@ -4720,8 +4726,6 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::list Date: Fri, 10 Mar 2023 21:07:57 +0500 Subject: [PATCH 06/11] Adding max_allowed_packet value verification --- .../reg_test_compression_split_packets-t.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/test/tap/tests/reg_test_compression_split_packets-t.cpp b/test/tap/tests/reg_test_compression_split_packets-t.cpp index 9a074ccdb6..08c1842dee 100644 --- a/test/tap/tests/reg_test_compression_split_packets-t.cpp +++ b/test/tap/tests/reg_test_compression_split_packets-t.cpp @@ -74,6 +74,21 @@ int test_compress_split_packets(const CommandLine& cl, const vector test MYSQL_QUERY_P(proxy, "/* create_new_connection=1 */ BEGIN"); + // 0. Confirm max_allowed_packet contains updated value + MYSQL_QUERY(proxy, "SHOW VARIABLES LIKE 'max_allowed_packet'"); + MYSQL_RES* res = mysql_store_result(proxy); + MYSQL_ROW row = mysql_fetch_row(res); + + const auto max_allowed_packet = strtoul(row[1], NULL, 10); + const bool is_max_allowed_packet_equal = max_allowed_packet == 41943040; + + ok( + is_max_allowed_packet_equal, "'max_allowed_packet' variable should contain updated value '41943040'. Error: '%s'", + (is_max_allowed_packet_equal == false ? row[1] : "") + ); + + mysql_free_result(res); + // 1. Test table creation const char* CREATE_TABLE_QUERY = "CREATE TABLE IF NOT EXISTS test.compress_split_packet (id INT PRIMARY KEY AUTO_INCREMENT, binarydata LONGBLOB)"; @@ -185,7 +200,7 @@ int main(int argc, char** argv) { CommandLine cl; // '4' tests per payload, times '2' due to compression/non-compression on backend servers - plan(test_payload_sizes.size() * 4 * 2); + plan(test_payload_sizes.size() * 4 * 2 + 2); if (cl.getEnv()) { diag("Failed to get the required environmental variables."); From e324521271abb125aaaf7e9cb98f76f25a1d3e88 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Mon, 13 Mar 2023 16:37:47 +0500 Subject: [PATCH 07/11] Updated cluster sync hostgroup id --- test/tap/tests/test_cluster_sync-t.cpp | 72 +++++++++++++------------- 1 file changed, 36 insertions(+), 36 deletions(-) diff --git a/test/tap/tests/test_cluster_sync-t.cpp b/test/tap/tests/test_cluster_sync-t.cpp index 7764bb6b74..308581526f 100644 --- a/test/tap/tests/test_cluster_sync-t.cpp +++ b/test/tap/tests/test_cluster_sync-t.cpp @@ -517,28 +517,28 @@ int main(int, char**) { { vector insert_mysql_servers_values { - std::make_tuple(2, "127.0.0.1", 13308, 14, "OFFLINE_HARD", 2, 1, 500, 300, 1, 200, ""), - std::make_tuple(3, "127.0.0.1", 13309, 15, "SHUNNED", 1, 0, 500, 300, 1, 200, ""), - std::make_tuple(0, "127.0.0.1", 13306, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, ""), - std::make_tuple(1, "127.0.0.1", 13307, 13, "OFFLINE_SOFT", 2, 1, 500, 300, 1, 200, "") + std::make_tuple(1002, "127.0.0.1", 13308, 14, "OFFLINE_HARD", 2, 1, 500, 300, 1, 200, ""), + std::make_tuple(1003, "127.0.0.1", 13309, 15, "SHUNNED", 1, 0, 500, 300, 1, 200, ""), + std::make_tuple(1000, "127.0.0.1", 13306, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, ""), + std::make_tuple(1001, "127.0.0.1", 13307, 13, "OFFLINE_SOFT", 2, 1, 500, 300, 1, 200, "") }; check_mysql_servers_sync(cl, proxy_admin, r_proxy_admin, insert_mysql_servers_values); vector insert_mysql_servers_values_2 { - std::make_tuple(0, "127.0.0.1", 13306, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "mysql_1"), - std::make_tuple(1, "127.0.0.1", 13307, 13, "OFFLINE_SOFT", 2, 1, 500, 300, 1, 200, "mysql_2_offline"), - std::make_tuple(2, "127.0.0.1", 13308, 14, "OFFLINE_SOFT", 2, 1, 500, 300, 1, 200, "mysql_3_offline"), - std::make_tuple(3, "127.0.0.1", 13309, 15, "OFFLINE_SOFT", 1, 0, 500, 300, 1, 200, "mysql_4_offline") + std::make_tuple(1000, "127.0.0.1", 13306, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "mysql_1"), + std::make_tuple(1001, "127.0.0.1", 13307, 13, "OFFLINE_SOFT", 2, 1, 500, 300, 1, 200, "mysql_2_offline"), + std::make_tuple(1002, "127.0.0.1", 13308, 14, "OFFLINE_SOFT", 2, 1, 500, 300, 1, 200, "mysql_3_offline"), + std::make_tuple(1003, "127.0.0.1", 13309, 15, "OFFLINE_SOFT", 1, 0, 500, 300, 1, 200, "mysql_4_offline") }; check_mysql_servers_sync(cl, proxy_admin, r_proxy_admin, insert_mysql_servers_values_2); vector insert_mysql_servers_values_3 { - std::make_tuple(0, "127.0.0.1", 13306, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "mysql_1"), - std::make_tuple(1, "127.0.0.1", 13307, 13, "OFFLINE_HARD", 2, 1, 500, 300, 1, 200, "mysql_2_offline"), - std::make_tuple(2, "127.0.0.1", 13308, 14, "OFFLINE_HARD", 2, 1, 500, 300, 1, 200, "mysql_3_offline"), - std::make_tuple(3, "127.0.0.1", 13309, 15, "OFFLINE_HARD", 1, 0, 500, 300, 1, 200, "mysql_4_offline") + std::make_tuple(1000, "127.0.0.1", 13306, 12, "ONLINE", 1, 1, 1000, 300, 1, 200, "mysql_1"), + std::make_tuple(1001, "127.0.0.1", 13307, 13, "OFFLINE_HARD", 2, 1, 500, 300, 1, 200, "mysql_2_offline"), + std::make_tuple(1002, "127.0.0.1", 13308, 14, "OFFLINE_HARD", 2, 1, 500, 300, 1, 200, "mysql_3_offline"), + std::make_tuple(1003, "127.0.0.1", 13309, 15, "OFFLINE_HARD", 1, 0, 500, 300, 1, 200, "mysql_4_offline") }; check_mysql_servers_sync(cl, proxy_admin, r_proxy_admin, insert_mysql_servers_values_3); @@ -557,10 +557,10 @@ int main(int, char**) { "active, max_writers, writer_is_also_reader, max_transactions_behind) " "VALUES (%d, %d, %d, %d, %d, %d, %d, %d)"; std::vector> insert_galera_values { - std::make_tuple(0, 4, 8, 12, 1, 10, 0, 200), - std::make_tuple(1, 5, 9, 13, 1, 20, 0, 250), - std::make_tuple(2, 6, 10, 14, 1, 20, 0, 150), - std::make_tuple(3, 7, 11, 15, 1, 20, 0, 350) + std::make_tuple(1000, 1004, 1008, 1012, 1, 10, 0, 200), + std::make_tuple(1001, 1005, 1009, 1013, 1, 20, 0, 250), + std::make_tuple(1002, 1006, 1010, 1014, 1, 20, 0, 150), + std::make_tuple(1003, 1007, 1011, 1015, 1, 20, 0, 350) }; std::vector insert_mysql_galera_hostgroup_queries {}; @@ -675,10 +675,10 @@ int main(int, char**) { "active, max_writers, writer_is_also_reader, max_transactions_behind, comment) " "VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %s)"; std::vector> insert_galera_values { - std::make_tuple(3, 7, 11, 15, 1, 20, 0, 350, "'reader_writer_test_galera_hostgroup'"), - std::make_tuple(0, 4, 8, 12, 1, 10, 0, 200, "'reader_writer_test_galera_hostgroup'"), - std::make_tuple(2, 6, 10, 14, 1, 20, 0, 150, "'reader_writer_test_galera_hostgroup'"), - std::make_tuple(1, 5, 9, 13, 1, 20, 0, 250, "'reader_writer_test_galera_hostgroup'"), + std::make_tuple(1003, 1007, 1011, 1015, 1, 20, 0, 350, "'reader_writer_test_galera_hostgroup'"), + std::make_tuple(1000, 1004, 1008, 1012, 1, 10, 0, 200, "'reader_writer_test_galera_hostgroup'"), + std::make_tuple(1002, 1006, 1010, 1014, 1, 20, 0, 150, "'reader_writer_test_galera_hostgroup'"), + std::make_tuple(1001, 1005, 1009, 1013, 1, 20, 0, 250, "'reader_writer_test_galera_hostgroup'"), }; std::vector insert_mysql_galera_hostgroup_queries {}; @@ -791,10 +791,10 @@ int main(int, char**) { "active, max_writers, writer_is_also_reader, max_transactions_behind) " "VALUES (%d, %d, %d, %d, %d, %d, %d, %d)"; std::vector> insert_group_replication_values { - std::make_tuple(2, 6, 10, 14, 1, 20, 0, 150), - std::make_tuple(0, 4, 8, 12, 1, 10, 0, 200), - std::make_tuple(3, 7, 11, 15, 1, 20, 0, 350), - std::make_tuple(1, 5, 9, 13, 1, 20, 0, 250), + std::make_tuple(1002, 1006, 1010, 1014, 1, 20, 0, 150), + std::make_tuple(1000, 1004, 1008, 1012, 1, 10, 0, 200), + std::make_tuple(1003, 1007, 1011, 1015, 1, 20, 0, 350), + std::make_tuple(1001, 1005, 1009, 1013, 1, 20, 0, 250), }; std::vector insert_mysql_group_replication_hostgroup_queries {}; @@ -908,10 +908,10 @@ int main(int, char**) { "active, max_writers, writer_is_also_reader, max_transactions_behind, comment) " "VALUES (%d, %d, %d, %d, %d, %d, %d, %d, %s)"; std::vector> insert_group_replication_values { - std::make_tuple(2, 6, 10, 14, 1, 20, 0, 150, "'reader_writer_test_group_replication_hostgroup'"), - std::make_tuple(3, 7, 11, 15, 1, 20, 0, 350, "'reader_writer_test_group_replication_hostgroup'"), - std::make_tuple(1, 5, 9, 13, 1, 20, 0, 250, "'reader_writer_test_group_replication_hostgroup'"), - std::make_tuple(0, 4, 8, 12, 1, 10, 0, 200, "'reader_writer_test_group_replication_hostgroup'") + std::make_tuple(1002, 1006, 1010, 1014, 1, 20, 0, 150, "'reader_writer_test_group_replication_hostgroup'"), + std::make_tuple(1003, 1007, 1011, 1015, 1, 20, 0, 350, "'reader_writer_test_group_replication_hostgroup'"), + std::make_tuple(1001, 1005, 1009, 1013, 1, 20, 0, 250, "'reader_writer_test_group_replication_hostgroup'"), + std::make_tuple(1000, 1004, 1008, 1012, 1, 10, 0, 200, "'reader_writer_test_group_replication_hostgroup'") }; std::vector insert_mysql_group_replication_hostgroup_queries {}; @@ -1174,10 +1174,10 @@ int main(int, char**) { "check_timeout_ms, writer_is_also_reader, new_reader_weight, add_lag_ms, min_lag_ms, lag_num_checks) " "VALUES (%d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d)"; std::vector> insert_aws_aurora_values { - std::make_tuple(2, 6, 1, 3308, ".test_domain2", 10002, 2002, 2002, 0, 3, 50, 100, 1), - std::make_tuple(3, 7, 1, 3309, ".test_domain3", 10003, 2003, 2003, 0, 4, 50, 100, 1), - std::make_tuple(0, 4, 1, 3306, ".test_domain0", 10000, 2000, 2000, 0, 1, 50, 100, 1), - std::make_tuple(1, 5, 1, 3307, ".test_domain1", 10001, 2001, 2001, 0, 2, 50, 100, 1), + std::make_tuple(1002, 1006, 1, 3308, ".test_domain2", 10002, 2002, 2002, 0, 3, 50, 100, 1), + std::make_tuple(1003, 1007, 1, 3309, ".test_domain3", 10003, 2003, 2003, 0, 4, 50, 100, 1), + std::make_tuple(1000, 1004, 1, 3306, ".test_domain0", 10000, 2000, 2000, 0, 1, 50, 100, 1), + std::make_tuple(1001, 1005, 1, 3307, ".test_domain1", 10001, 2001, 2001, 0, 2, 50, 100, 1), }; std::vector insert_mysql_aws_aurora_hostgroup_queries {}; @@ -1301,10 +1301,10 @@ int main(int, char**) { "check_timeout_ms, writer_is_also_reader, new_reader_weight, add_lag_ms, min_lag_ms, lag_num_checks, comment) " "VALUES (%d, %d, %d, %d, '%s', %d, %d, %d, %d, %d, %d, %d, %d, '%s')"; std::vector> insert_aws_aurora_values { - std::make_tuple(3, 7, 1, 3309, ".test_domain3", 10003, 2003, 2003, 0, 4, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), - std::make_tuple(1, 5, 1, 3307, ".test_domain1", 10001, 2001, 2001, 0, 2, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), - std::make_tuple(2, 6, 1, 3308, ".test_domain2", 10002, 2002, 2002, 0, 3, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), - std::make_tuple(0, 4, 1, 3306, ".test_domain0", 10000, 2000, 2000, 0, 1, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), + std::make_tuple(1003, 1007, 1, 3309, ".test_domain3", 10003, 2003, 2003, 0, 4, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), + std::make_tuple(1001, 1005, 1, 3307, ".test_domain1", 10001, 2001, 2001, 0, 2, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), + std::make_tuple(1002, 1006, 1, 3308, ".test_domain2", 10002, 2002, 2002, 0, 3, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), + std::make_tuple(1000, 1004, 1, 3306, ".test_domain0", 10000, 2000, 2000, 0, 1, 50, 100, 1, "reader_writer_test_aws_aurora_hostgroup"), }; std::vector insert_mysql_aws_aurora_hostgroup_queries {}; From 446c9ec0c814a6bc0a61cfa6d7d9fda0fee67cd3 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Tue, 14 Mar 2023 13:22:46 +0500 Subject: [PATCH 08/11] Added logging --- include/MySQL_HostGroups_Manager.h | 23 +++++++++++++++++++++++ lib/MySQL_HostGroups_Manager.cpp | 17 +++++++++++++++-- 2 files changed, 38 insertions(+), 2 deletions(-) diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index f7cac8cc5f..6f29b633c7 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -424,8 +424,31 @@ class MySQL_HostGroups_Manager { ~HostGroup_Server_Mapping() = default; // Note: copy_if_not_exists, remove, clear method also makes changes to MyHostGroups + + /** + * @brief Copies all unique nodes from source vector to destination vector. + * @details Copies all unique nodes from source vector to destination vector. The source and destination vectors are identified by an input enumeration type, + * which can be either a reader or a writer. During the copying process, the function also adds servers to the HostGroup connection container. + * @param dest_type Input Can be reader or writer + * @param src_type Input Can be reader or writer + */ void copy_if_not_exists(Type dest_type, Type src_type); + + /** + * @brief Removes node located at the specified index. + * @details Node is removed from vector located at the specified index identified by an input enumeration type. + Node that was removed is marked as offline in the HostGroup connection container. + * @param dest_type Input Can be reader or writer + * @param index Input Index of node to be removed + */ void remove(Type type, size_t index); + + /** + * @brief Removes all nodes. + * @details All nodes are removed from vector, identified by an input enumeration type. + Nodes that are removed is marked as offline in the HostGroup connection container. + * @param type Input Can be reader or writer + */ void clear(Type type); // diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 8ec0db1f35..06803a923d 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -1966,8 +1966,9 @@ bool MySQL_HostGroups_Manager::commit( if (hgsm_mysql_servers_checksum != table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS] || hgsm_mysql_replication_hostgroups_checksum != table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS]) { - proxy_info("Checksum for table 'mysql_servers': old:0x%lX new:0x%lX\n", hgsm_mysql_servers_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS]); - proxy_info("Checksum for table 'mysql_replication_hostgroups': old:0x%lX new:0x%lX\n", hgsm_mysql_replication_hostgroups_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS]); + proxy_info("Rebuilding 'Hostgroup_Manager_Mapping' due to checksums change - mysql_servers { old: 0x%lX, new: 0x%lX }, mysql_replication_hostgroups { old:0x%lX, new:0x%lX }\n", + hgsm_mysql_servers_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_SERVERS], + hgsm_mysql_replication_hostgroups_checksum, table_resultset_checksum[HGM_TABLES::MYSQL_REPLICATION_HOSTGROUPS]); char* error = NULL; int cols = 0; @@ -4617,6 +4618,8 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); if (mysql_thread___monitor_writer_is_also_reader) { @@ -4628,9 +4631,13 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listget_readonly_flag() != 0) { // it is the first time that we detect RO on this server @@ -4673,17 +4680,21 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy_if_not_exists(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER); // clearing all writer nodes host_server_mapping->clear(HostGroup_Server_Mapping::Type::WRITER); update_mysql_servers_table = true; + proxy_info("Regenerating table 'mysql_servers' due to actions on server '%s:%d'\n", hostname.c_str(), port); } } else { // LCOV_EXCL_START @@ -7637,6 +7648,8 @@ MySrvC* MySQL_HostGroups_Manager::find_server_in_hg(unsigned int _hid, const std void MySQL_HostGroups_Manager::HostGroup_Server_Mapping::copy_if_not_exists(Type dest_type, Type src_type) { + assert(dest_type != src_type); + const std::vector& src_nodes = mapping[src_type]; if (src_nodes.empty()) return; From c7c71c99d3d0390c4d77bb4343c40ab1f443e60f Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Tue, 14 Mar 2023 17:19:17 +0500 Subject: [PATCH 09/11] Fixed logging and comments --- include/MySQL_HostGroups_Manager.h | 12 +++++------- lib/MySQL_HostGroups_Manager.cpp | 6 +++--- 2 files changed, 8 insertions(+), 10 deletions(-) diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 6f29b633c7..00ec96778e 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -423,12 +423,11 @@ class MySQL_HostGroups_Manager { HostGroup_Server_Mapping(MySQL_HostGroups_Manager* hgm) : readonly_flag(1), myHGM(hgm) { } ~HostGroup_Server_Mapping() = default; - // Note: copy_if_not_exists, remove, clear method also makes changes to MyHostGroups - /** * @brief Copies all unique nodes from source vector to destination vector. - * @details Copies all unique nodes from source vector to destination vector. The source and destination vectors are identified by an input enumeration type, - * which can be either a reader or a writer. During the copying process, the function also adds servers to the HostGroup connection container. + * @details Copies all unique nodes from source vector to destination vector. The source and destination + * vectors are identified by an input enumeration type, which can be either a reader or a writer. + * During the copying process, the function also adds servers to the HostGroup connection container. * @param dest_type Input Can be reader or writer * @param src_type Input Can be reader or writer */ @@ -437,7 +436,7 @@ class MySQL_HostGroups_Manager { /** * @brief Removes node located at the specified index. * @details Node is removed from vector located at the specified index identified by an input enumeration type. - Node that was removed is marked as offline in the HostGroup connection container. + * Node that was removed is marked as offline in the HostGroup connection container. * @param dest_type Input Can be reader or writer * @param index Input Index of node to be removed */ @@ -446,11 +445,10 @@ class MySQL_HostGroups_Manager { /** * @brief Removes all nodes. * @details All nodes are removed from vector, identified by an input enumeration type. - Nodes that are removed is marked as offline in the HostGroup connection container. + * Nodes that are removed is marked as offline in the HostGroup connection container. * @param type Input Can be reader or writer */ void clear(Type type); - // inline const std::vector& get(Type type) const { diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 06803a923d..f9676dc56f 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -4635,9 +4635,6 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listget_readonly_flag() != 0) { // it is the first time that we detect RO on this server @@ -4668,6 +4665,9 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); From 0268495d52746011f7887dfddaa12e730341f3d9 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Tue, 18 Apr 2023 14:59:14 +0500 Subject: [PATCH 10/11] * Fixed the functionality of 'mysql-monitor_writer_is_also_reader' --- include/MySQL_HostGroups_Manager.h | 19 ++++++++++++++++++- lib/MySQL_HostGroups_Manager.cpp | 23 ++++++++--------------- 2 files changed, 26 insertions(+), 16 deletions(-) diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 00ec96778e..45ca581334 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -378,6 +378,23 @@ struct hg_metrics_map_idx { }; }; +/** + * @brief Required server info for the read_only Monitoring actions. + */ +using hostname_t = std::string; +using port_t = int; +using read_only_t = int; + +using read_only_server_t = std::tuple; + +enum READ_ONLY_SERVER_T { + HOSTNAME = 0, + PORT, + READONLY, + __SIZE +}; +// + class MySQL_HostGroups_Manager { private: SQLite3DB *admindb; @@ -748,7 +765,7 @@ class MySQL_HostGroups_Manager { void replication_lag_action_inner(MyHGC *, char*, unsigned int, int); void replication_lag_action(int, char*, unsigned int, int); void read_only_action(char *hostname, int port, int read_only); - void read_only_action_v2(const std::list>& mysql_servers); + void read_only_action_v2(const std::list& mysql_servers); unsigned int get_servers_table_version(); void wait_servers_table_version(unsigned, unsigned); bool shun_and_killall(char *hostname, int port); diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 6f9c1a6546..1495c397fd 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -4584,18 +4584,17 @@ void MySQL_HostGroups_Manager::read_only_action(char *hostname, int port, int re * @param mysql_servers List of servers having hostname, port and read only value. * */ -void MySQL_HostGroups_Manager::read_only_action_v2(const std::list>& mysql_servers) { +void MySQL_HostGroups_Manager::read_only_action_v2(const std::list& mysql_servers) { - std::string hostname; - int port = -1; - int read_only = -1; bool update_mysql_servers_table = false; unsigned long long curtime1 = monotonic_time(); wrlock(); for (const auto& server : mysql_servers) { bool is_writer = false; - std::tie(hostname, port, read_only) = server; + const std::string& hostname = std::get(server); + const int port = std::get(server); + const int read_only = std::get(server); const std::string& srv_id = hostname + ":::" + std::to_string(port); auto itr = hostgroup_server_mapping.find(srv_id); @@ -4622,11 +4621,8 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); - if (mysql_thread___monitor_writer_is_also_reader) { - // server is also a reader, we copy all nodes from writer to reader (previous reader nodes will be reused) - host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER); - } else { - // server can only be a writer + if (mysql_thread___monitor_writer_is_also_reader == false) { + // remove node from reader host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER); } @@ -4671,11 +4667,8 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::listcopy_if_not_exists(HostGroup_Server_Mapping::Type::WRITER, HostGroup_Server_Mapping::Type::READER); - if (mysql_thread___monitor_writer_is_also_reader) { - // server is also a reader, we copy all nodes from writer to reader (previous reader nodes will be reused) - host_server_mapping->copy_if_not_exists(HostGroup_Server_Mapping::Type::READER, HostGroup_Server_Mapping::Type::WRITER); - } else { - // server can only be a writer + if (mysql_thread___monitor_writer_is_also_reader == false) { + // remove node from reader host_server_mapping->clear(HostGroup_Server_Mapping::Type::READER); } From 4bc48a81fe5ad25d70df36d30d29b1130fe37c66 Mon Sep 17 00:00:00 2001 From: Rahim Kanji Date: Thu, 20 Apr 2023 22:28:12 +0500 Subject: [PATCH 11/11] In the constructor of MySrvC, a maximum latency value is accepted in milliseconds, which is then converted into microseconds. Fixed in read_only_actions_v2. --- lib/MySQL_HostGroups_Manager.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 1495c397fd..1516f17a9a 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -7748,7 +7748,7 @@ MySrvC* MySQL_HostGroups_Manager::HostGroup_Server_Mapping::insert_HGM(unsigned proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 5, "Adding new server %s:%d , weight=%d, status=%d, mem_ptr=%p into hostgroup=%d\n", srv->address, srv->port, srv->weight, srv->status, srv, hostgroup_id); MySrvC* new_srv = new MySrvC(srv->address, srv->port, srv->gtid_port, srv->weight, srv->status, srv->compression, - srv->max_connections, srv->max_replication_lag, srv->use_ssl, srv->max_latency_us, srv->comment); + srv->max_connections, srv->max_replication_lag, srv->use_ssl, (srv->max_latency_us/1000), srv->comment); hostgroup_container->mysrvs->add(new_srv);