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.
This commit is contained in:
parent
88f234fdcd
commit
050ce7f1a3
@ -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){
|
||||
|
@ -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<std::string> 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
|
||||
*
|
||||
|
@ -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);
|
||||
|
@ -227,3 +227,12 @@ void dump_param_list(int file,
|
||||
const std::unordered_set<std::string>& 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);
|
||||
|
Loading…
x
Reference in New Issue
Block a user