From 601809e6fd29812bed7eb23e09b671dfe59d3b10 Mon Sep 17 00:00:00 2001 From: Jim Riggs Date: Tue, 25 Aug 2020 16:00:31 -0500 Subject: [PATCH] Log emergency check of shunned servers when no servers are available Issue #531 added "a desperate attempt to bring back online any shunned server" when no servers are available; however, no indication or notification of this is logged. Add a log message indicating that the hostgroup has no servers available and shunned hosts are being checked before the normal shun recovery time. --- lib/MySQL_HostGroups_Manager.cpp | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/lib/MySQL_HostGroups_Manager.cpp b/lib/MySQL_HostGroups_Manager.cpp index 551269940..3982ecea1 100644 --- a/lib/MySQL_HostGroups_Manager.cpp +++ b/lib/MySQL_HostGroups_Manager.cpp @@ -2811,12 +2811,17 @@ MySrvC *MyHGC::get_random_MySrvC(char * gtid_uuid, uint64_t gtid_trxid, int max_ // per issue #531 , we try a desperate attempt to bring back online any shunned server // we do this lowering the maximum wait time to 10% // most of the follow code is copied from few lines above + static time_t last_hg_log = 0; time_t t; t=time(NULL); int max_wait_sec = ( mysql_thread___shun_recovery_time_sec * 1000 >= mysql_thread___connect_timeout_server_max ? mysql_thread___connect_timeout_server_max/10000 - 1 : mysql_thread___shun_recovery_time_sec/10 ); if (max_wait_sec < 1) { // min wait time should be at least 1 second max_wait_sec = 1; } + if (t - last_hg_log > 1) { // log this at most once per second to avoid spamming the logs + last_hg_log = time(NULL); + proxy_error("Hostgroup %u has no servers available! Checking servers shunned for more than %u second%s\n", hid, max_wait_sec, max_wait_sec == 1 ? "" : "s"); + } for (j=0; jidx(j); if (mysrvc->status==MYSQL_SERVER_STATUS_SHUNNED && mysrvc->shunned_automatic==true) {