Added logging

pull/4127/head
Rahim Kanji 3 years ago
parent e324521271
commit 446c9ec0c8

@ -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);
//

@ -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::list<std::tuple<st
if (is_writer == false) {
// the server has read_only=0 (writer), but we can't find any writer,
// so we copy all reader nodes to writer
proxy_info("Server '%s:%d' found with 'read_only=0', but not found as writer\n", hostname.c_str(), port);
proxy_debug(PROXY_DEBUG_MONITOR, 5, "Server '%s:%d' found with 'read_only=0', but not found as writer\n", hostname.c_str(), port);
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) {
@ -4628,9 +4631,13 @@ void MySQL_HostGroups_Manager::read_only_action_v2(const std::list<std::tuple<st
}
update_mysql_servers_table = true;
proxy_info("Regenerating table 'mysql_servers' due to actions on server '%s:%d'\n", hostname.c_str(), port);
} else {
bool act = false;
proxy_info("Server '%s:%d' found with 'read_only=0', also found as writer\n", hostname.c_str(), port);
proxy_debug(PROXY_DEBUG_MONITOR, 5, "Server '%s:%d' found with 'read_only=0', also found as writer\n", hostname.c_str(), port);
// if the server was RO=0 on the previous check then no action is needed
if (host_server_mapping->get_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::list<std::tuple<st
}
update_mysql_servers_table = true;
proxy_info("Regenerating table 'mysql_servers' due to actions on server '%s:%d'\n", hostname.c_str(), port);
}
}
} else if (read_only == 1) {
if (is_writer) {
// the server has read_only=1 (reader), but we find it as writer, so we copy all writer nodes to reader (previous reader nodes will be reused)
proxy_info("Server '%s:%d' found with 'read_only=1', but not found as reader\n", hostname.c_str(), port);
proxy_debug(PROXY_DEBUG_MONITOR, 5, "Server '%s:%d' found with 'read_only=1', but not found as reader\n", hostname.c_str(), port);
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);
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<Node>& src_nodes = mapping[src_type];
if (src_nodes.empty()) return;

Loading…
Cancel
Save