MXS-2011 Assert that configurations are identical
At save time, assert that the configuration as dispersed around blr and as stored in the config object are identical. Later its the state from the config object that will be saved.
This commit is contained in:
parent
0c3fcfe302
commit
dec81594c1
@ -226,8 +226,10 @@ typedef enum
|
||||
* BLR_BLR_MASTER_RETRY_COUNT Maximum value of retries
|
||||
*/
|
||||
#define BLR_MASTER_BACKOFF_TIME 10
|
||||
#define BLR_MASTER_CONNECT_RETRY "60"
|
||||
#define BLR_MASTER_RETRY_COUNT "1000"
|
||||
|
||||
#define BLR_MASTER_CONNECT_RETRY_VALUE 60
|
||||
#define BLR_MASTER_CONNECT_RETRY "60"
|
||||
#define BLR_MASTER_RETRY_COUNT "1000"
|
||||
|
||||
/* Default value for @@max_connections SQL var */
|
||||
#define BLR_DEFAULT_MAX_CONNS 151
|
||||
@ -239,7 +241,8 @@ typedef enum
|
||||
#define BLR_NET_LATENCY_WAIT_TIME 1
|
||||
|
||||
/* default heartbeat interval in seconds */
|
||||
#define BLR_HEARTBEAT_DEFAULT_INTERVAL "300"
|
||||
#define BLR_HEARTBEAT_DEFAULT_INTERVAL_VALUE 300
|
||||
#define BLR_HEARTBEAT_DEFAULT_INTERVAL "300"
|
||||
|
||||
/* Max heartbeat interval in seconds */
|
||||
#define BLR_HEARTBEAT_MAX_INTERVAL 4294967
|
||||
@ -368,6 +371,11 @@ public:
|
||||
class ChangeMasterConfig
|
||||
{
|
||||
public:
|
||||
ChangeMasterConfig()
|
||||
: heartbeat_period(BLR_HEARTBEAT_DEFAULT_INTERVAL_VALUE)
|
||||
, connect_retry(BLR_MASTER_CONNECT_RETRY_VALUE)
|
||||
{
|
||||
}
|
||||
std::string connection_name;
|
||||
std::string host;
|
||||
int port;
|
||||
@ -379,7 +387,7 @@ public:
|
||||
std::string ssl_key;
|
||||
std::string ssl_cert;
|
||||
std::string ssl_ca;
|
||||
std::string ssl_enabled;
|
||||
bool ssl_enabled;
|
||||
std::string ssl_version;
|
||||
/* MariaDB 10 GTID */
|
||||
std::string use_mariadb10_gtid;
|
||||
@ -395,11 +403,15 @@ class ChangeMasterOptions
|
||||
{
|
||||
public:
|
||||
ChangeMasterOptions()
|
||||
: heartbeat_period(BLR_HEARTBEAT_DEFAULT_INTERVAL)
|
||||
, connect_retry(BLR_MASTER_CONNECT_RETRY)
|
||||
{
|
||||
}
|
||||
|
||||
ChangeMasterOptions(const std::string& s)
|
||||
: connection_name(s)
|
||||
, heartbeat_period(BLR_HEARTBEAT_DEFAULT_INTERVAL)
|
||||
, connect_retry(BLR_MASTER_CONNECT_RETRY)
|
||||
{
|
||||
}
|
||||
|
||||
|
@ -3338,6 +3338,29 @@ blr_file_write_master_config(ROUTER_INSTANCE *router, char *error)
|
||||
return 2;
|
||||
}
|
||||
|
||||
// Assert that the configurarion as dispersed around blr and
|
||||
// as stored in the configuration item are identical.
|
||||
mxb_assert(router->configs.size() > 0);
|
||||
const ChangeMasterConfig& primary = router->configs.front();
|
||||
|
||||
mxb_assert(primary.host == router->service->dbref->server->address);
|
||||
mxb_assert(primary.port == router->service->dbref->server->port);
|
||||
mxb_assert(primary.user == router->user);
|
||||
mxb_assert(primary.password == router->password);
|
||||
|
||||
if (router->ssl_enabled)
|
||||
{
|
||||
mxb_assert(primary.ssl_enabled);
|
||||
mxb_assert(primary.ssl_ca == router->service->dbref->server->server_ssl->ssl_ca_cert);
|
||||
mxb_assert(primary.ssl_cert == router->service->dbref->server->server_ssl->ssl_cert);
|
||||
mxb_assert(primary.ssl_key == router->service->dbref->server->server_ssl->ssl_key);
|
||||
}
|
||||
|
||||
mxb_assert(!router->ssl_version || (primary.ssl_version == router->ssl_version));
|
||||
|
||||
mxb_assert(primary.heartbeat_period == (int)router->heartbeat);
|
||||
mxb_assert(primary.connect_retry == router->retry_interval);
|
||||
|
||||
/* write ini file section */
|
||||
fprintf(config_file, "[%s]\n", section);
|
||||
|
||||
|
@ -4223,7 +4223,7 @@ bool ChangeMasterOptions::validate(ROUTER_INSTANCE* router,
|
||||
config->ssl_key = this->ssl_key;
|
||||
config->ssl_cert = this->ssl_cert;
|
||||
config->ssl_ca = this->ssl_ca;
|
||||
config->ssl_enabled = this->ssl_enabled;
|
||||
config->ssl_enabled = this->ssl_enabled.empty() ? false : atoi(this->ssl_enabled.c_str());
|
||||
config->ssl_version = this->ssl_version;
|
||||
config->use_mariadb10_gtid = this->use_mariadb10_gtid;
|
||||
config->heartbeat_period = heartbeat_period;
|
||||
@ -4344,7 +4344,7 @@ int blr_apply_change_master_0(ROUTER_INSTANCE* router,
|
||||
// No CA cert is defined or only one of CERT or KEY is defined
|
||||
(new_config.ssl_ca.empty() || new_config.ssl_cert.empty() != new_config.ssl_key.empty())
|
||||
{
|
||||
if (!new_config.ssl_enabled.empty() && atoi(new_config.ssl_enabled.c_str()))
|
||||
if (new_config.ssl_enabled)
|
||||
{
|
||||
snprintf(error,
|
||||
BINLOG_ERROR_MSG_LEN,
|
||||
@ -6258,9 +6258,9 @@ blr_set_master_ssl(ROUTER_INSTANCE *router,
|
||||
SSL_LISTENER *server_ssl = NULL;
|
||||
int updated = 0;
|
||||
|
||||
if (!config.ssl_enabled.empty())
|
||||
if (config.ssl_enabled)
|
||||
{
|
||||
router->ssl_enabled = atoi(config.ssl_enabled.c_str());
|
||||
router->ssl_enabled = config.ssl_enabled;
|
||||
updated++;
|
||||
}
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user