Merge branch '2.2' of github.com:mariadb-corporation/MaxScale into 2.2

This commit is contained in:
Timofey Turenko 2017-12-21 17:29:57 +02:00
commit ad57de6784
6 changed files with 43 additions and 2158 deletions

View File

@ -223,19 +223,6 @@ external agent that automatically reintegrates failed servers into the
cluster. One of these agents is the _replication-manager_ which automatically
configures the failed servers as new slaves of the current master.
### `allow_external_slaves`
Allow the use of external slaves. This option is enabled by default.
If a slave server is replicating from a master that is not being monitored by
the MySQL monitor, the slaves will be assigned the _Slave of External Server_
status (a status mainly for informational purposes).
When the `allow_external_slaves` option is enabled, the server will also be
assigned the _Slave_ status which allows them to be used like normal slave
servers. When the option is disabled, the servers will only receive the _Slave
of External Server_ status and they will not be used.
## Failover, switchover and auto-rejoin
Starting with MaxScale 2.2.1, MySQL Monitor supports replication cluster

View File

@ -8,6 +8,7 @@ servers=server1,server2
user=maxskysql
passwd=skysql
monitor_interval=1000
ignore_external_masters=true
[RW Split Router]
type=service

View File

@ -18,8 +18,10 @@ void change_master(TestConnections& test, int slave, int master, const char* nam
source += "'";
}
execute_query(test.repl->nodes[slave], "STOP ALL SLAVES;CHANGE MASTER %s TO master_host='%s', master_port=3306, "
"master_user='%s', master_password='%s', master_use_gtid=slave_pos;START ALL SLAVES",
execute_query(test.repl->nodes[slave], "STOP ALL SLAVES;"
"SET GLOBAL gtid_slave_pos='0-1-0';"
"CHANGE MASTER %s TO master_host='%s', master_port=3306, master_user='%s', master_password='%s', master_use_gtid=slave_pos;"
"START ALL SLAVES",
source.c_str(), test.repl->IP[master], test.repl->user_name, test.repl->password, source.c_str());
}
@ -60,34 +62,39 @@ int main(int argc, char** argv)
{
TestConnections test(argc, argv);
// Stop replication on nodes three and four
test.repl->connect();
test.tprintf("Server sanity check");
check_status(test, {"Master", "Running"}, {"Slave", "Running"});
test.tprintf("Stop replication on nodes three and four");
execute_query(test.repl->nodes[2], "STOP ALL SLAVES; RESET SLAVE ALL;");
execute_query(test.repl->nodes[3], "STOP ALL SLAVES; RESET SLAVE ALL;");
// Point the master to an external server
test.tprintf("Point the master to an external server");
change_master(test, 1, 0);
change_master(test, 0, 2);
check_status(test, {"Master", "Running"}, {"Slave", "Running"});
// Resetting the slave on master should have no effect
test.tprintf("Resetting the slave on master should have no effect");
execute_query(test.repl->nodes[0], "STOP ALL SLAVES; RESET SLAVE ALL;");
check_status(test, {"Master", "Running"}, {"Slave", "Running"});
// Configure multi-source replication, check that master status is as expected
change_master(test, 0, 2, "extra-slave");
change_master(test, 1, 2, "extra-slave");
check_status(test, {"Master", "Running"}, {"Slave", "Running", "Slave of External Server"});
// TODO: Fix this so that multi-source replication is tested
// test.tprintf("Configure multi-source replication, check that master status is as expected");
// change_master(test, 0, 2, "extra-slave");
// change_master(test, 1, 2, "extra-slave");
// check_status(test, {"Master", "Running"}, {"Slave", "Running", "Slave of External Server"});
// Stopping multi-source replication on slave should remove the Slave of External Server status
execute_query(test.repl->nodes[1], "STOP SLAVE 'extra-slave'; RESET SLAVE 'extra-slave';");
check_status(test, {"Master", "Running"}, {"Slave", "Running"});
// test.tprintf("Stopping multi-source replication on slave should remove the Slave of External Server status");
// execute_query(test.repl->nodes[1], "STOP SLAVE 'extra-slave'; RESET SLAVE 'extra-slave';");
// check_status(test, {"Master", "Running"}, {"Slave", "Running"});
// sleep(60);
// Doing the same on the master should have no effect
execute_query(test.repl->nodes[0], "STOP ALL SLAVES; RESET SLAVE ALL;");
check_status(test, {"Master", "Running"}, {"Slave", "Running"});
// test.tprintf("Doing the same on the master should have no effect");
// execute_query(test.repl->nodes[0], "STOP ALL SLAVES; RESET SLAVE ALL;");
// check_status(test, {"Master", "Running"}, {"Slave", "Running"});
// Cleanup
test.tprintf("Cleanup");
test.repl->execute_query_all_nodes( "STOP ALL SLAVES; RESET SLAVE ALL;");
test.repl->fix_replication();
return test.global_result;

View File

@ -63,7 +63,6 @@ typedef struct
down before failover is initiated */
bool allow_cluster_recovery; /**< Allow failed servers to rejoin the cluster */
bool warn_set_standalone_master; /**< Log a warning when setting standalone master */
bool allow_external_slaves; /**< Whether to allow usage of external slave servers */
bool auto_failover; /**< If automatic master failover is enabled */
uint32_t failover_timeout; /**< Timeout in seconds for the master failover */
uint32_t switchover_timeout; /**< Timeout in seconds for the master switchover */

File diff suppressed because it is too large Load Diff

View File

@ -596,10 +596,10 @@ extern "C"
{"detect_stale_slave", MXS_MODULE_PARAM_BOOL, "true"},
{"mysql51_replication", MXS_MODULE_PARAM_BOOL, "false"},
{"multimaster", MXS_MODULE_PARAM_BOOL, "false"},
{"detect_standalone_master", MXS_MODULE_PARAM_BOOL, "false"},
{"detect_standalone_master", MXS_MODULE_PARAM_BOOL, "true"},
{CN_FAILCOUNT, MXS_MODULE_PARAM_COUNT, "5"},
{"allow_cluster_recovery", MXS_MODULE_PARAM_BOOL, "true"},
{"allow_external_slaves", MXS_MODULE_PARAM_BOOL, "true"},
{"ignore_external_masters", MXS_MODULE_PARAM_BOOL, "false"},
{
"script",
MXS_MODULE_PARAM_PATH,
@ -929,13 +929,13 @@ startMonitor(MXS_MONITOR *monitor, const MXS_CONFIG_PARAMETER* params)
handle->detectStaleSlave = config_get_bool(params, "detect_stale_slave");
handle->replicationHeartbeat = config_get_bool(params, "detect_replication_lag");
handle->multimaster = config_get_bool(params, "multimaster");
handle->ignore_external_masters = config_get_bool(params, "ignore_external_masters");
handle->detect_standalone_master = config_get_bool(params, "detect_standalone_master");
handle->failcount = config_get_integer(params, CN_FAILCOUNT);
handle->allow_cluster_recovery = config_get_bool(params, "allow_cluster_recovery");
handle->mysql51_replication = config_get_bool(params, "mysql51_replication");
handle->script = config_copy_string(params, "script");
handle->events = config_get_enum(params, "events", mxs_monitor_event_enum_values);
handle->allow_external_slaves = config_get_bool(params, "allow_external_slaves");
handle->auto_failover = config_get_bool(params, CN_AUTO_FAILOVER);
handle->failover_timeout = config_get_integer(params, CN_FAILOVER_TIMEOUT);
handle->switchover_timeout = config_get_integer(params, CN_SWITCHOVER_TIMEOUT);
@ -1465,14 +1465,8 @@ static MXS_MONITORED_SERVER *build_mysql51_replication_tree(MXS_MONITOR *mon)
(database->server->master_id <= 0 ||
database->server->master_id != handle->master->server->node_id))
{
if (handle->allow_external_slaves)
{
monitor_set_pending_status(database, SERVER_SLAVE);
}
else
{
monitor_clear_pending_status(database, SERVER_SLAVE);
}
monitor_set_pending_status(database, SERVER_SLAVE);
monitor_set_pending_status(database, SERVER_SLAVE_OF_EXTERNAL_MASTER);
}
database = database->next;
@ -2209,6 +2203,19 @@ monitorMain(void *arg)
{
// Clear slave and stale slave status bits from current master
monitor_clear_pending_status(root_master, SERVER_SLAVE | SERVER_STALE_SLAVE);
/**
* Clear external slave status from master if configured to do so.
* This allows parts of a multi-tiered replication setup to be used
* in MaxScale.
*/
if (SERVER_IS_SLAVE_OF_EXTERNAL_MASTER(root_master->server) &&
SERVER_IS_MASTER(root_master->server) && handle->ignore_external_masters)
{
monitor_clear_pending_status(root_master,
SERVER_SLAVE | SERVER_SLAVE_OF_EXTERNAL_MASTER);
server_clear_status_nolock(root_master->server, SERVER_SLAVE | SERVER_SLAVE_OF_EXTERNAL_MASTER);
}
}
/**
@ -2742,14 +2749,7 @@ static MXS_MONITORED_SERVER *get_replication_tree(MXS_MONITOR *mon, int num_serv
{
if (current->master_id > 0)
{
if (handle->allow_external_slaves)
{
monitor_set_pending_status(ptr, SERVER_SLAVE);
}
else
{
monitor_clear_pending_status(ptr, SERVER_SLAVE);
}
monitor_set_pending_status(ptr, SERVER_SLAVE);
monitor_set_pending_status(ptr, SERVER_SLAVE_OF_EXTERNAL_MASTER);
}
}