From 4c53273427c021e9afa2f86dd4c8e2784b699b67 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ren=C3=A9=20Canna=C3=B2?= Date: Sat, 27 Feb 2016 21:04:20 +0000 Subject: [PATCH] LOAD MYSQL GLOBAL VARIABLES resets MySQL Monitor timers And immediately triggers new checks Issue #490 --- lib/MySQL_Monitor.cpp | 60 +++++++++++++++++++++---------------------- 1 file changed, 30 insertions(+), 30 deletions(-) diff --git a/lib/MySQL_Monitor.cpp b/lib/MySQL_Monitor.cpp index 4b25c0eaf..4334c95cd 100644 --- a/lib/MySQL_Monitor.cpp +++ b/lib/MySQL_Monitor.cpp @@ -711,6 +711,13 @@ void * MySQL_Monitor::monitor_connect() { unsigned int glover; t1=monotonic_time(); + glover=GloMTH->get_global_version(); + if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { + MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; + mysql_thr->refresh_variables(); + next_loop_at=0; + } + if (t1 < next_loop_at) { goto __sleep_monitor_connect_loop; } @@ -724,13 +731,6 @@ void * MySQL_Monitor::monitor_connect() { // create libevent base libevent_base= event_base_new(); - glover=GloMTH->get_global_version(); - if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { - MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; - mysql_thr->refresh_variables(); - //proxy_error("%s\n", "MySQL_Monitor - CONNECT - refreshing variables"); - } - proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query); admindb->execute_statement(query, &error , &cols , &affected_rows , &resultset); if (error) { @@ -836,9 +836,16 @@ void * MySQL_Monitor::monitor_ping() { SQLite3_result *resultset=NULL; MySQL_Monitor_State_Data **sds=NULL; int i=0; - char *query=(char *)"SELECT DISTINCT hostname, port FROM mysql_servers"; + char *query=(char *)"SELECT DISTINCT hostname, port FROM mysql_servers WHERE status!='OFFLINE_HARD'"; t1=monotonic_time(); + glover=GloMTH->get_global_version(); + if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { + MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; + mysql_thr->refresh_variables(); + next_loop_at=0; + } + if (t1 < next_loop_at) { goto __sleep_monitor_ping_loop; } @@ -852,13 +859,6 @@ void * MySQL_Monitor::monitor_ping() { // create libevent base libevent_base= event_base_new(); - glover=GloMTH->get_global_version(); - if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { - MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; - mysql_thr->refresh_variables(); - //proxy_error("%s\n","MySQL_Monitor - PING - refreshing variables"); - } - proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query); admindb->execute_statement(query, &error , &cols , &affected_rows , &resultset); if (error) { @@ -969,9 +969,16 @@ void * MySQL_Monitor::monitor_read_only() { SQLite3_result *resultset=NULL; MySQL_Monitor_State_Data **sds=NULL; int i=0; - char *query=(char *)"SELECT DISTINCT hostname, port FROM mysql_servers JOIN mysql_replication_hostgroups ON hostgroup_id=writer_hostgroup OR hostgroup_id=reader_hostgroup"; + char *query=(char *)"SELECT DISTINCT hostname, port FROM mysql_servers JOIN mysql_replication_hostgroups ON hostgroup_id=writer_hostgroup OR hostgroup_id=reader_hostgroup WHERE status!='OFFLINE_HARD'"; t1=monotonic_time(); + glover=GloMTH->get_global_version(); + if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { + MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; + mysql_thr->refresh_variables(); + next_loop_at=0; + } + if (t1 < next_loop_at) { goto __sleep_monitor_read_only; } @@ -985,13 +992,6 @@ void * MySQL_Monitor::monitor_read_only() { // create libevent base libevent_base= event_base_new(); - glover=GloMTH->get_global_version(); - if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { - MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; - mysql_thr->refresh_variables(); - //proxy_error("%s\n","MySQL_Monitor - PING - refreshing variables"); - } - proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query); // admindb->execute_statement(query, &error , &cols , &affected_rows , &resultset); resultset = MyHGM->execute_query(query, &error); @@ -1147,6 +1147,13 @@ void * MySQL_Monitor::monitor_replication_lag() { char *query=(char *)"SELECT hostgroup_id, hostname, port, max_replication_lag FROM mysql_servers WHERE max_replication_lag > 0 AND status NOT LIKE 'OFFLINE%'"; t1=monotonic_time(); + glover=GloMTH->get_global_version(); + if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { + MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; + mysql_thr->refresh_variables(); + next_loop_at=0; + } + if (t1 < next_loop_at) { goto __sleep_monitor_replication_lag; } @@ -1160,13 +1167,6 @@ void * MySQL_Monitor::monitor_replication_lag() { // create libevent base libevent_base= event_base_new(); - glover=GloMTH->get_global_version(); - if (MySQL_Monitor__thread_MySQL_Thread_Variables_version < glover ) { - MySQL_Monitor__thread_MySQL_Thread_Variables_version=glover; - mysql_thr->refresh_variables(); - //proxy_error("%s\n","MySQL_Monitor - PING - refreshing variables"); - } - proxy_debug(PROXY_DEBUG_ADMIN, 4, "%s\n", query); // admindb->execute_statement(query, &error , &cols , &affected_rows , &resultset); resultset = MyHGM->execute_query(query, &error);