MXS-2417: Add option to ignore persisted configs

The load_persisted_configs parameter now controls whether persisted
runtime changes are loaded on startup. The changes are still generated as
it persists the current state of MaxScale making problem analysis easier.
This commit is contained in:
Markus Mäkelä 2019-04-03 11:00:10 +03:00
parent a217dde1f0
commit e3e66f8e90
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 34 additions and 1 deletions

View File

@ -164,6 +164,7 @@ runtime and can only be defined in a configuration file:
* `sql_mode`
* `local_address`
* `users_refresh_time`
* `load_persisted_configs`
* `admin_auth`
* `admin_ssl_key`
* `admin_ssl_cert`
@ -871,6 +872,19 @@ it will only be disabled when the write queue is below `writeq_low_water`. The
parameter accepts size type values. The minimum allowed size is 512
bytes. `writeq_high_water` must always be greater than `writeq_low_water`.
#### `load_persisted_configs`
Load persisted runtime changes on startup. This parameter accepts boolean values
and is enabled by default. This parameter was added in MaxScale 2.3.6.
All runtime configuration changes are persisted in generated configuration files
located by default in `/var/lib/maxscale/maxscale.cnf.d/` and are loaded on
startup after main configuration files have been read. To make runtime
configurations volatile (i.e. they are lost when maxscale is restarted), use
`load_persisted_configs=false`. All changes are still persisted since it stores
the current runtime state of MaxScale. This makes problem analysis easier if an
unexpected outage happens.
### REST API Configuration
The MaxScale REST API is an HTTP interface that provides JSON format data

View File

@ -164,6 +164,7 @@ extern const char CN_QUERY_RETRIES[];
extern const char CN_QUERY_RETRY_TIMEOUT[];
extern const char CN_RELATIONSHIPS[];
extern const char CN_LINKS[];
extern const char CN_LOAD_PERSISTED_CONFIGS[];
extern const char CN_REQUIRED[];
extern const char CN_RETAIN_LAST_STATEMENTS[];
extern const char CN_RETRY_ON_FAILURE[];
@ -294,6 +295,7 @@ typedef struct
char peer_user[MAX_ADMIN_HOST_LEN]; /**< Username for maxscale-to-maxscale traffic */
char peer_password[MAX_ADMIN_HOST_LEN]; /**< Password for maxscale-to-maxscale traffic */
mxb_log_target_t log_target; /**< Log type */
bool load_persisted_configs; /**< Load persisted configuration files on startup */
} MXS_CONFIG;
/**

View File

@ -145,6 +145,7 @@ const char CN_QUERY_RETRIES[] = "query_retries";
const char CN_QUERY_RETRY_TIMEOUT[] = "query_retry_timeout";
const char CN_RELATIONSHIPS[] = "relationships";
const char CN_LINKS[] = "links";
const char CN_LOAD_PERSISTED_CONFIGS[] = "load_persisted_configs";
const char CN_LOCAL_ADDRESS[] = "local_address";
const char CN_REQUIRED[] = "required";
const char CN_RETAIN_LAST_STATEMENTS[] = "retain_last_statements";
@ -1158,7 +1159,8 @@ static bool config_load_and_process(const char* filename, bool (* process_config
const char* persist_cnf = get_config_persistdir();
mxs_mkdir_all(persist_cnf, S_IRWXU | S_IRWXG | S_IROTH | S_IXOTH);
if (is_directory(persist_cnf) && contains_cnf_files(persist_cnf))
if (config_get_global_options()->load_persisted_configs
&& is_directory(persist_cnf) && contains_cnf_files(persist_cnf))
{
/**
* Set the global flag that we are processing a persisted configuration.
@ -2607,6 +2609,20 @@ static int handle_global_item(const char* name, const char* value)
return 0;
}
}
else if (strcmp(name, CN_LOAD_PERSISTED_CONFIGS) == 0)
{
int b = config_truth_value(value);
if (b != -1)
{
gateway.load_persisted_configs = b;
}
else
{
MXS_ERROR("Invalid value for '%s': %s", CN_LOAD_PERSISTED_CONFIGS, value);
return 0;
}
}
else
{
bool found = false;
@ -2825,6 +2841,7 @@ void config_set_global_defaults()
gateway.query_retry_timeout = DEFAULT_QUERY_RETRY_TIMEOUT;
gateway.passive = false;
gateway.promoted_at = 0;
gateway.load_persisted_configs = true;
gateway.peer_hosts[0] = '\0';
gateway.peer_user[0] = '\0';