diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 5705ac942..a8c3b1c62 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -1077,7 +1077,7 @@ class MySQL_HostGroups_Manager : public Base_HostGroups_Manager { void set_Readyset_status(char *hostname, int port, enum MySerStatus status); unsigned long long Get_Memory_Stats(); - void add_discovered_servers_to_mysql_servers_and_replication_hostgroups(const vector>& new_servers); + void add_discovered_servers_to_mysql_servers_and_replication_hostgroups(const vector>& new_servers); void update_group_replication_set_offline(char *_hostname, int _port, int _writer_hostgroup, char *error); void update_group_replication_set_read_only(char *_hostname, int _port, int _writer_hostgroup, char *error); diff --git a/include/MySQL_Monitor.hpp b/include/MySQL_Monitor.hpp index 621959b5a..617d1bf3c 100644 --- a/include/MySQL_Monitor.hpp +++ b/include/MySQL_Monitor.hpp @@ -463,7 +463,7 @@ class MySQL_Monitor { static void trigger_dns_cache_update(); void process_discovered_topology(const std::string& originating_server_hostname, const vector& discovered_servers, const MySQL_Monitor_State_Data* mmsd, int num_fields); - bool is_aws_rds_multi_az_db_cluster_topology(const string& originating_server_hostname, const vector>& discovered_servers); + bool is_aws_rds_multi_az_db_cluster_topology(const string& originating_server_hostname, const vector>& discovered_servers); bool is_aws_rds_topology_query_task(const MySQL_Monitor_State_Data_Task_Type& task_type); bool mysql_row_matches_query_task(const unordered_set &field_names, const MySQL_Monitor_State_Data_Task_Type &task_type); void add_topology_query_to_task(MySQL_Monitor_State_Data_Task_Type &task_type); diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index edcf64efc..451e4ffac 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -7355,7 +7355,7 @@ MySQLServers_SslParams * MySQL_HostGroups_Manager::get_Server_SSL_Params(char *h * @param new_servers A vector of tuples where each tuple contains the values needed to add each new server. */ void MySQL_HostGroups_Manager::add_discovered_servers_to_mysql_servers_and_replication_hostgroups( - const vector>& new_servers + const vector>& new_servers ) { int added_new_server = -1; @@ -7363,14 +7363,15 @@ void MySQL_HostGroups_Manager::add_discovered_servers_to_mysql_servers_and_repli wrlock(); // Add the discovered server with default values - for (const tuple& s : new_servers) { + for (const tuple& s : new_servers) { string host = std::get<0>(s); - int port = std::get<1>(s); - long int hostgroup_id = std::get<2>(s); - int weight = std::get<3>(s); + uint16_t port = std::get<1>(s); + uint32_t hostgroup_id = std::get<2>(s); + int64_t weight = std::get<3>(s); + int32_t use_ssl = std::get<4>(s); srv_info_t srv_info { host.c_str(), (uint16_t)port, "AWS RDS" }; - srv_opts_t srv_opts { weight, -1, -1 }; + srv_opts_t srv_opts { weight, -1, use_ssl }; int res = create_new_server_in_hg(hostgroup_id, srv_info, srv_opts); if (added_new_server < 0) { diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 09f96fda8..1dfb93f37 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -3492,7 +3492,7 @@ void MySQL_Monitor::process_discovered_topology(const std::string& originating_s return; } - int reader_hostgroup = mmsd->reader_hostgroup; + uint32_t reader_hostgroup = (uint32_t)(mmsd->reader_hostgroup); char *error = NULL; int cols = 0; @@ -3508,7 +3508,7 @@ void MySQL_Monitor::process_discovered_topology(const std::string& originating_s } else { unordered_set saved_hostnames; saved_hostnames.insert(originating_server_hostname); - vector> new_servers; + vector> new_servers; // Do a loop through the query results to save existing runtime server hostnames for (std::vector::iterator it = runtime_mysql_servers->rows.begin(); it != runtime_mysql_servers->rows.end(); it++) { @@ -3532,9 +3532,9 @@ VALGRIND_DISABLE_ERROR_REPORTING; VALGRIND_ENABLE_ERROR_REPORTING; string current_discovered_hostname = row[2]; string current_discovered_port_string = row[3]; - int current_discovered_port; + uint16_t current_discovered_port; try { - current_discovered_port = stoi(current_discovered_port_string); + current_discovered_port = (uint16_t)stoi(current_discovered_port_string); } catch (...) { proxy_error( "Unable to parse port value coming from '%s' during topology discovery ('%s':%s). Terminating discovery early.\n", @@ -3554,8 +3554,12 @@ VALGRIND_ENABLE_ERROR_REPORTING; return; } - int current_determined_weight = -1; // TODO: Add logic for selecting a different weight based on discovered role and status - tuple discovered_server(current_discovered_hostname, current_discovered_port, reader_hostgroup, current_determined_weight); + int64_t current_determined_weight = (int64_t)(-1L); // TODO: Add logic for selecting a different weight based on discovered role and status + int32_t use_ssl = 0; + if (mmsd->use_ssl) { + use_ssl = 1; + } + tuple discovered_server(current_discovered_hostname, current_discovered_port, reader_hostgroup, current_determined_weight, use_ssl); if (!saved_hostnames.count(current_discovered_hostname)) { // Server isn't in either hostgroup yet, adding as reader proxy_info("%d: Adding new host '%s' to new server list in hostgroup [%ld].\n", __LINE__, std::get<0>(discovered_server).c_str(), std::get<2>(discovered_server)); @@ -3576,13 +3580,13 @@ VALGRIND_ENABLE_ERROR_REPORTING; * @param discovered_servers A vector of servers discovered when querying the cluster's topology. * @return Returns 'true' if all conditions are met and 'false' otherwise. */ -bool MySQL_Monitor::is_aws_rds_multi_az_db_cluster_topology(const string& originating_servername, const std::vector>& discovered_servers) { +bool MySQL_Monitor::is_aws_rds_multi_az_db_cluster_topology(const string& originating_servername, const std::vector>& discovered_servers) { if (discovered_servers.size() != 2) { return false; } vector hostnames(1, originating_servername); - for (tuple server : discovered_servers) { + for (tuple server : discovered_servers) { string hostname = std::get<0>(server); if (hostname.empty()) { continue;