diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index f573b9725..20eef1e04 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -689,6 +689,12 @@ MySrvC *MyHGC::get_random_MySrvC() { } } } + + if (New_sum==0) { + proxy_debug(PROXY_DEBUG_MYSQL_CONNPOOL, 7, "Returning MySrvC NULL because no backend ONLINE or with weight\n"); + return NULL; // if we reach here, we couldn't find any target + } + unsigned int k=rand()%New_sum; k++; New_sum=0; diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 94748fbf4..6afb18283 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -1018,7 +1018,7 @@ __end_monitor_ping_loop: if (resultset) { if (resultset->rows_count) { // disable host - proxy_error("Server %s:%s missed %d heartbeats, shunning it and killing all the connections\n", addresses[j], atoi(ports[j]), max_failures); + proxy_error("Server %s:%s missed %d heartbeats, shunning it and killing all the connections\n", addresses[j], ports[j], max_failures); MyHGM->shun_and_killall(addresses[j],atoi(ports[j])); } delete resultset;