diff --git a/include/maxscale/config.h b/include/maxscale/config.h index bb9470699..d827702ed 100644 --- a/include/maxscale/config.h +++ b/include/maxscale/config.h @@ -257,6 +257,7 @@ typedef struct * promoted from a passive to an active */ char qc_name[PATH_MAX]; /**< The name of the query classifier to load */ char* qc_args; /**< Arguments for the query classifier */ + QC_CACHE_PROPERTIES* qc_cache_properties; /**< The query classifier cache properties. */ qc_sql_mode_t qc_sql_mode; /**< The query classifier sql mode */ char admin_host[MAX_ADMIN_HOST_LEN]; /**< Admin interface host */ uint16_t admin_port; /**< Admin interface port */ diff --git a/server/core/config.cc b/server/core/config.cc index 6d52e8a2c..2c22a8e7a 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -120,6 +120,7 @@ const char CN_PORT[] = "port"; const char CN_PROTOCOL[] = "protocol"; const char CN_QUERY_CLASSIFIER[] = "query_classifier"; const char CN_QUERY_CLASSIFIER_ARGS[] = "query_classifier_args"; +const char CN_QUERY_CLASSIFIER_CACHE[] = "query_classifier_cache"; const char CN_QUERY_RETRIES[] = "query_retries"; const char CN_QUERY_RETRY_TIMEOUT[] = "query_retry_timeout"; const char CN_RELATIONSHIPS[] = "relationships"; @@ -1723,6 +1724,12 @@ handle_global_item(const char *name, const char *value) { gateway.qc_args = MXS_STRDUP_A(value); } + else if (strcmp(name, CN_QUERY_CLASSIFIER_CACHE) == 0) + { + static QC_CACHE_PROPERTIES cache_properties; + + gateway.qc_cache_properties = &cache_properties; + } else if (strcmp(name, "sql_mode") == 0) { if (strcasecmp(value, "default") == 0) diff --git a/server/core/gateway.cc b/server/core/gateway.cc index ffc589804..8560f71c4 100644 --- a/server/core/gateway.cc +++ b/server/core/gateway.cc @@ -1975,7 +1975,7 @@ int main(int argc, char **argv) goto return_main; } - if (!qc_setup(NULL, cnf->qc_sql_mode, cnf->qc_name, cnf->qc_args)) + if (!qc_setup(cnf->qc_cache_properties, cnf->qc_sql_mode, cnf->qc_name, cnf->qc_args)) { const char* logerr = "Failed to initialise query classifier library."; print_log_n_stderr(true, true, logerr, logerr, eno); diff --git a/server/core/query_classifier.cc b/server/core/query_classifier.cc index ac1503697..075b2b7db 100644 --- a/server/core/query_classifier.cc +++ b/server/core/query_classifier.cc @@ -278,7 +278,19 @@ bool qc_setup(const QC_CACHE_PROPERTIES* cache_properties, if (rv == QC_RESULT_OK) { this_unit.qc_sql_mode = sql_mode; - this_unit.use_cached_result = (cache_properties ? true : false); + + bool use_cached_result = (cache_properties != nullptr); + + if (use_cached_result) + { + MXS_NOTICE("Query classification results are cached and reused."); + } + else + { + MXS_NOTICE("Query classification results are not cached."); + } + + this_unit.use_cached_result = use_cached_result; } else {