From a06c8fa8a7f9bd77d1bdf4eb07df601052c2a5fb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Juan=20Manuel=20Fern=C3=A1ndez=20Garc=C3=ADa-Minguill?= =?UTF-8?q?=C3=A1n?= Date: Thu, 10 Jul 2025 12:05:47 +0200 Subject: [PATCH] Allow only galera servers in online status --- lib/MySQL_HostGroups_Manager.cpp | 20 ++++++-------------- 1 file changed, 6 insertions(+), 14 deletions(-) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 7b579a2310..2a2a171679 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -5410,20 +5410,12 @@ void MySQL_HostGroups_Manager::update_galera_set_writer(char *_hostname, int _po } pthread_mutex_unlock(&Galera_Info_mutex); - if (resultset->rows_count) { - for (std::vector::iterator it = resultset->rows.begin() ; it != resultset->rows.end(); ++it) { - SQLite3_row *r=*it; - int hostgroup=atoi(r->fields[0]); - if (hostgroup==_writer_hostgroup) { - int status=atoi(r->fields[1]); - if (status==0) - found_writer=true; - } - if (read_HG>=0) { - if (hostgroup==read_HG) { - found_reader=true; - } - } + for (size_t i = 0, l = resultset->rows.size(); i < l; ++i) { + int status = atoi(resultset->rows[i]->fields[1]); + if (status == 0) { + int hostgroup = atoi(resultset->rows[i]->fields[0]); + found_writer |= hostgroup == _writer_hostgroup; + found_reader |= (read_HG >= 0) && (hostgroup == read_HG); } }