Aligning datatypes for server creation and adding SSL flag for servers discovered through rds_topology

pull/4992/head
Niels Vogell 9 months ago
parent a31838d776
commit 80e100a153

@ -1077,7 +1077,7 @@ class MySQL_HostGroups_Manager : public Base_HostGroups_Manager<MyHGC> {
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<tuple<string, int, long, int>>& new_servers);
void add_discovered_servers_to_mysql_servers_and_replication_hostgroups(const vector<tuple<string, uint16_t, uint32_t, int64_t, int32_t>>& 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);

@ -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<MYSQL_ROW>& 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<tuple<string, int, long, int>>& discovered_servers);
bool is_aws_rds_multi_az_db_cluster_topology(const string& originating_server_hostname, const vector<tuple<string, uint16_t, uint32_t, int64_t, int32_t>>& 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<string> &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);

@ -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<tuple<string, int, long, int>>& new_servers
const vector<tuple<string, uint16_t, uint32_t, int64_t, int32_t>>& 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<string, int, long, int>& s : new_servers) {
for (const tuple<string, uint16_t, uint32_t, int64_t, int32_t>& 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) {

@ -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<string> saved_hostnames;
saved_hostnames.insert(originating_server_hostname);
vector<tuple<string, int, long, int>> new_servers;
vector<tuple<string, uint16_t, uint32_t, int64_t, int32_t>> new_servers;
// Do a loop through the query results to save existing runtime server hostnames
for (std::vector<SQLite3_row *>::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<string, int, long, int> 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<string, uint16_t, uint32_t, int64_t, int32_t> 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<tuple<string, int, long, int>>& discovered_servers) {
bool MySQL_Monitor::is_aws_rds_multi_az_db_cluster_topology(const string& originating_servername, const std::vector<tuple<string, uint16_t, uint32_t, int64_t, int32_t>>& discovered_servers) {
if (discovered_servers.size() != 2) {
return false;
}
vector<string> hostnames(1, originating_servername);
for (tuple<string, int, long, int> server : discovered_servers) {
for (tuple<string, uint16_t, uint32_t, int64_t, int32_t> server : discovered_servers) {
string hostname = std::get<0>(server);
if (hostname.empty()) {
continue;

Loading…
Cancel
Save