From 050ce7f1a3896237a79bcf49d0a6421ac46c7a5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 27 Dec 2018 13:12:39 +0200 Subject: [PATCH] MXS-2200: Add runtime handling for all global parameters All global parameters are now handled by the runtime configuration modification code. The parameters that are trivial to update can now be updated at runtime. All other global parameters cause a new error message to be returned stating that the parameter in question cannot be modified at runtime. Also updated the list of modifiable parameters in MaxCtrl. This list should not be stored in MaxCtrl and should be created by MaxScale at runtime. --- maxctrl/lib/alter.js | 8 +++- server/core/config.cc | 32 +++++++++++++++ server/core/config_runtime.cc | 75 ++++++++++++++++++++++++++++++++++ server/core/internal/config.hh | 9 ++++ 4 files changed, 123 insertions(+), 1 deletion(-) diff --git a/maxctrl/lib/alter.js b/maxctrl/lib/alter.js index f753e16cd..32a952774 100644 --- a/maxctrl/lib/alter.js +++ b/maxctrl/lib/alter.js @@ -37,7 +37,13 @@ const maxscale_params = [ 'auth_write_timeout', 'admin_auth', 'admin_log_auth_failures', - 'passive' + 'passive', + 'ms_timestamp', + 'skip_permission_checks', + 'query_retries', + 'query_retry_timeout', + 'retain_last_statements', + 'dump_last_statements' ] function setFilters(host, argv){ diff --git a/server/core/config.cc b/server/core/config.cc index 9f2b12d96..0dad28b4a 100644 --- a/server/core/config.cc +++ b/server/core/config.cc @@ -2632,6 +2632,38 @@ static int handle_global_item(const char* name, const char* value) return processed ? 1 : 0; } +bool config_can_modify_at_runtime(const char* name) +{ + for (int i = 0; config_pre_parse_global_params[i]; ++i) + { + if (strcmp(name, config_pre_parse_global_params[i]) == 0) + { + return true; + } + } + std::unordered_set static_params + { + CN_USERS_REFRESH_TIME, + CN_LOCAL_ADDRESS, + CN_ADMIN_ENABLED, + CN_ADMIN_SSL_CA_CERT, + CN_ADMIN_SSL_CERT, + CN_ADMIN_SSL_KEY, + CN_ADMIN_HOST, + CN_ADMIN_PORT, + CN_LOG_THROTTLING, + "sql_mode", + CN_QUERY_CLASSIFIER_ARGS, + CN_QUERY_CLASSIFIER, + CN_POLL_SLEEP, + CN_NON_BLOCKING_POLLS, + CN_THREAD_STACK_SIZE, + CN_THREADS + }; + + return static_params.count(name); +} + /** * Free an SSL structure * diff --git a/server/core/config_runtime.cc b/server/core/config_runtime.cc index 02c580dee..32401dd3d 100644 --- a/server/core/config_runtime.cc +++ b/server/core/config_runtime.cc @@ -937,6 +937,81 @@ bool runtime_alter_maxscale(const char* name, const char* value) MXS_NOTICE("'%s' set to: %lu", CN_WRITEQ_LOW_WATER, size); } } + else if (key == CN_MS_TIMESTAMP) + { + mxs_log_set_highprecision_enabled(config_truth_value(value)); + rval = true; + } + else if (key == CN_SKIP_PERMISSION_CHECKS) + { + cnf.skip_permission_checks = config_truth_value(value); + rval = true; + } + else if (key == CN_QUERY_RETRIES) + { + int intval = get_positive_int(value); + if (intval) + { + cnf.query_retries = intval; + rval = true; + } + else + { + config_runtime_error("Invalid timeout value for '%s': %s", CN_QUERY_RETRIES, value); + } + } + else if (key == CN_QUERY_RETRY_TIMEOUT) + { + int intval = get_positive_int(value); + if (intval) + { + cnf.query_retry_timeout = intval; + rval = true; + } + else + { + config_runtime_error("Invalid timeout value for '%s': %s", CN_QUERY_RETRY_TIMEOUT, value); + } + } + else if (key == CN_RETAIN_LAST_STATEMENTS) + { + int intval = get_positive_int(value); + if (intval) + { + session_set_retain_last_statements(intval); + rval = true; + } + else + { + config_runtime_error("Invalid value for '%s': %s", CN_RETAIN_LAST_STATEMENTS, value); + } + } + else if (key == CN_DUMP_LAST_STATEMENTS) + { + rval = true; + if (strcmp(value, "on_close") == 0) + { + session_set_dump_statements(SESSION_DUMP_STATEMENTS_ON_CLOSE); + } + else if (strcmp(value, "on_error") == 0) + { + session_set_dump_statements(SESSION_DUMP_STATEMENTS_ON_ERROR); + } + else if (strcmp(value, "never") == 0) + { + session_set_dump_statements(SESSION_DUMP_STATEMENTS_NEVER); + } + else + { + rval = false; + config_runtime_error("%s can have the values 'never', 'on_close' or 'on_error'.", + CN_DUMP_LAST_STATEMENTS); + } + } + else if (config_can_modify_at_runtime(key.c_str())) + { + config_runtime_error("Global parameter '%s' cannot be modified at runtime", name); + } else { config_runtime_error("Unknown global parameter: %s=%s", name, value); diff --git a/server/core/internal/config.hh b/server/core/internal/config.hh index 08e937c04..6862deec8 100644 --- a/server/core/internal/config.hh +++ b/server/core/internal/config.hh @@ -227,3 +227,12 @@ void dump_param_list(int file, const std::unordered_set& ignored, const MXS_MODULE_PARAM* common_params, const MXS_MODULE_PARAM* module_params); + +/** + * Check whether a parameter can be modified at runtime + * + * @param name Name of the parameter + * + * @return True if the parameter can be modified at runtime + */ +bool config_can_modify_at_runtime(const char* name);