When a server isn't responding to ping, it is flagged as shunned and all the connections need to be dropped.
All the connections must be dropped before the server is brought back online
// if a server is taken back online, consider it immediately
sum+=mysrvc->weight;
if(
(mysrvc->shunned_and_kill_all_connections==false)// it is safe to bring it back online
||
(mysrvc->shunned_and_kill_all_connections==true&&mysrvc->ConnectionsUsed->conns->len==0&&mysrvc->ConnectionsFree->conns->len==0)// if shunned_and_kill_all_connections is set, ensure all connections are already dropped
query=(char*)"SELECT DISTINCT a.hostname, a.port FROM mysql_servers a JOIN monitor.mysql_server_ping_log b ON a.hostname=b.hostname WHERE status!='OFFLINE_HARD' AND b.ping_error IS NOT NULL";
char*new_query=(char*)"SELECT 1 FROM (SELECT hostname,port FROM monitor.mysql_server_ping_log WHERE hostname='%s' AND port='%s' ORDER BY time_start DESC LIMIT %d) a GROUP BY hostname,port HAVING COUNT(*)=%d";
// the query failed because the server is offline hard
if(
(myconn->parent->status==MYSQL_SERVER_STATUS_OFFLINE_HARD)// the query failed because the server is offline hard
||
(myconn->parent->status==MYSQL_SERVER_STATUS_SHUNNED&&myconn->parent->shunned_automatic==true&&myconn->parent->shunned_and_kill_all_connections==true)// the query failed because the server is shunned due to a serious failure
(parent->status==MYSQL_SERVER_STATUS_OFFLINE_HARD)// the server is OFFLINE as specific by the user
||
(parent->status==MYSQL_SERVER_STATUS_SHUNNED&&parent->shunned_automatic==true&&parent->shunned_and_kill_all_connections==true)// the server is SHUNNED due to a serious issue