diff --git a/include/MySQL_HostGroups_Manager.h b/include/MySQL_HostGroups_Manager.h index 9b728543a..2cbc9d963 100644 --- a/include/MySQL_HostGroups_Manager.h +++ b/include/MySQL_HostGroups_Manager.h @@ -558,6 +558,23 @@ class MySQL_HostGroups_Manager { void update_group_replication_set_read_only(char *_hostname, int _port, int _writer_hostgroup, char *error); void update_group_replication_set_writer(char *_hostname, int _port, int _writer_hostgroup); void converge_group_replication_config(int _writer_hostgroup); + /** + * @brief Set the supplied server as SHUNNED, this function shall be called + * to 'SHUNNED' those servers which replication lag is bigger than: + * - `mysql_thread___monitor_groupreplication_max_transactions_behind_count` + * + * @details The function automatically handles if the supplies server is a + * writer, and the 'writer_is_also_reader' flag is present in that + * hostgroup. In that case, it also sets as 'SHUNNED' the corresponding + * server that is present in the 'reader_hostgroup'. + * + * @param _hid The writer hostgroup. + * @param address The server address. + * @param port The server port. + * @param read_only Boolean specifying the read_only flag value of the server. + * @param enable Boolean specifying if the server needs to be disabled / enabled, + * 'true' for enabling the server if it's 'SHUNNED', 'false' for disabling it. + */ void group_replication_lag_action(int _hid, char *address, unsigned int port, bool read_only, bool enable); void update_galera_set_offline(char *_hostname, int _port, int _writer_hostgroup, char *error, bool soft=false); diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 943f839ba..29d16ef80 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -3399,8 +3399,7 @@ void MySQL_HostGroups_Manager::group_replication_lag_action( reader_hostgroup_query.c_str(), &error , &cols , &affected_rows , &rhid_res ); - // If the is now reader hostgroup configured for 'mysql_group_replication_hostgroups' - // an invalid configuration was somehow inserted. + // If the server isn't present in the supplied hostgroup, there is nothing to do. if (rhid_res->rows.empty() || rhid_res->rows[0]->get_size() == 0) { goto __exit_replication_lag_action; } @@ -3417,6 +3416,8 @@ void MySQL_HostGroups_Manager::group_replication_lag_action( continue; } } else { + // In case of 'writer_is_also_reader' the server can be present + // in both, the 'reader_hostgroup' and the 'writer_hostgroup'. if (writer_is_also_reader) { if (_hid >= 0 && _hid != (int)myhgc->hid && reader_hostgroup != (int)myhgc->hid) { continue;