Skip to content

Commit

Permalink
Added duplicate server check to prevent redundant server inspections,…
Browse files Browse the repository at this point in the history
… that can cause unique constraint error on mysql_server_galera_log table.
  • Loading branch information
rahim-kanji committed Sep 21, 2023
1 parent 99e0e96 commit 90e3247
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion lib/MySQL_Monitor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -8014,14 +8014,19 @@ bool MySQL_Monitor::monitor_galera_process_ready_tasks(const std::vector<MySQL_M
void MySQL_Monitor::monitor_galera_async() {

std::vector<std::unique_ptr<MySQL_Monitor_State_Data>> mmsds;

std::set<std::string> checked_servers;
pthread_mutex_lock(&galera_mutex);
assert(Galera_Hosts_resultset);
mmsds.reserve(Galera_Hosts_resultset->rows_count);
Monitor_Poll monitor_poll(Galera_Hosts_resultset->rows_count);

for (std::vector<SQLite3_row*>::iterator it = Galera_Hosts_resultset->rows.begin(); it != Galera_Hosts_resultset->rows.end(); ++it) {
const SQLite3_row* r = *it;

auto ret = checked_servers.insert(std::string(r->fields[1]) + ":" + std::string(r->fields[2]));
if (ret.second == false) // duplicate server entry
continue;

bool rc_ping = server_responds_to_ping(r->fields[1], atoi(r->fields[2]));
if (rc_ping) { // only if server is responding to pings

Expand Down

0 comments on commit 90e3247

Please sign in to comment.