From 2b147a9ea4fac4e02a1caec67fc6774a7398025e Mon Sep 17 00:00:00 2001 From: VilhoRaatikka Date: Wed, 24 Sep 2014 12:03:04 +0300 Subject: [PATCH] Monitors waited monitor check interval time before checking backend servers for the first time. Removed wait for the first check. Added extra debugging to query_classifier to assist in issue resolution regarding to optimized MaxScale builds and pthread_mutex_lock in sql/sql_class.h --- query_classifier/query_classifier.cc | 37 +++++++++++++++++++++---- server/modules/monitor/galera_mon.c | 6 ++-- server/modules/monitor/mysql_mon.c | 6 ++-- server/modules/monitor/ndbcluster_mon.c | 6 ++-- 4 files changed, 43 insertions(+), 12 deletions(-) diff --git a/query_classifier/query_classifier.cc b/query_classifier/query_classifier.cc index f034d770f..ecf305308 100644 --- a/query_classifier/query_classifier.cc +++ b/query_classifier/query_classifier.cc @@ -359,17 +359,37 @@ static bool create_parse_tree( Parser_state parser_state; bool failp = FALSE; const char* virtual_db = "skygw_virtual"; - +#if defined(SS_DEBUG_EXTRA) + LOGIF(LM, (skygw_log_write_flush( + LOGFILE_MESSAGE, + "[readwritesplit:create_parse_tree] 1."))); +#endif if (parser_state.init(thd, thd->query(), thd->query_length())) { failp = TRUE; goto return_here; } - mysql_reset_thd_for_next_command(thd); - - /** Set some database to thd so that parsing won't fail because of - * missing database. Then parse. */ - failp = thd->set_db(virtual_db, strlen(virtual_db)); +#if defined(SS_DEBUG_EXTRA) + LOGIF(LM, (skygw_log_write_flush( + LOGFILE_MESSAGE, + "[readwritesplit:create_parse_tree] 2."))); +#endif + mysql_reset_thd_for_next_command(thd); +#if defined(SS_DEBUG_EXTRA) + LOGIF(LM, (skygw_log_write_flush( + LOGFILE_MESSAGE, + "[readwritesplit:create_parse_tree] 3."))); +#endif + /** + * Set some database to thd so that parsing won't fail because of + * missing database. Then parse. + */ + failp = thd->set_db(virtual_db, strlen(virtual_db)); +#if defined(SS_DEBUG_EXTRA) + LOGIF(LM, (skygw_log_write_flush( + LOGFILE_MESSAGE, + "[readwritesplit:create_parse_tree] 4."))); +#endif if (failp) { LOGIF(LE, (skygw_log_write_flush( LOGFILE_ERROR, @@ -377,6 +397,11 @@ static bool create_parse_tree( } failp = parse_sql(thd, &parser_state, NULL); +#if defined(SS_DEBUG_EXTRA) + LOGIF(LM, (skygw_log_write_flush( + LOGFILE_MESSAGE, + "[readwritesplit:create_parse_tree] 5."))); +#endif if (failp) { LOGIF(LD, (skygw_log_write( LOGFILE_DEBUG, diff --git a/server/modules/monitor/galera_mon.c b/server/modules/monitor/galera_mon.c index d2ad38264..f2e633db7 100644 --- a/server/modules/monitor/galera_mon.c +++ b/server/modules/monitor/galera_mon.c @@ -447,13 +447,15 @@ size_t nrounds = 0; } /** Wait base interval */ thread_millisleep(MON_BASE_INTERVAL_MS); - nrounds += 1; /** If monitor interval time isn't consumed skip checks */ - if ((nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0) + if (nrounds != 0 && + (nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0) { + nrounds += 1; continue; } + nrounds += 1; master_id = -1; ptr = handle->databases; diff --git a/server/modules/monitor/mysql_mon.c b/server/modules/monitor/mysql_mon.c index d7e0b34bd..4d917314f 100644 --- a/server/modules/monitor/mysql_mon.c +++ b/server/modules/monitor/mysql_mon.c @@ -611,13 +611,15 @@ size_t nrounds = 0; } /** Wait base interval */ thread_millisleep(MON_BASE_INTERVAL_MS); - nrounds += 1; /** If monitor interval time isn't consumed skip checks */ - if ((nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0) + if (nrounds != 0 && + (nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0) { + nrounds += 1; continue; } + nrounds += 1; /* reset num_servers */ num_servers = 0; diff --git a/server/modules/monitor/ndbcluster_mon.c b/server/modules/monitor/ndbcluster_mon.c index 2e009e000..46f5dd9ec 100644 --- a/server/modules/monitor/ndbcluster_mon.c +++ b/server/modules/monitor/ndbcluster_mon.c @@ -445,13 +445,15 @@ size_t nrounds = 0; /** Wait base interval */ thread_millisleep(MON_BASE_INTERVAL_MS); - nrounds += 1; /** If monitor interval time isn't consumed skip checks */ - if ((nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0) + if (nrounds != 0 && + (nrounds*MON_BASE_INTERVAL_MS)%handle->interval != 0) { + nrounds += 1; continue; } + nrounds += 1; master_id = -1; ptr = handle->databases;