Reset default master node state as well

Now that mariadbmon supports failover and switchover, a test may
may change the master to some other node than node 0.

Consequently, as part of fixing the replication, gtid_slave_pos
of node 0 must be reset as well.
This commit is contained in:
Johan Wikman
2018-01-05 11:49:23 +02:00
parent 396c8405be
commit 3c5963cf3b

View File

@ -383,7 +383,7 @@ int Mariadb_nodes::start_replication()
connect(); connect();
for (int i = 1; i < N; i++) for (int i = 0; i < N; i++)
{ {
execute_query(nodes[i], "STOP SLAVE;"); execute_query(nodes[i], "STOP SLAVE;");
@ -392,17 +392,20 @@ int Mariadb_nodes::start_replication()
execute_query(nodes[i], "SET GLOBAL gtid_slave_pos='0-1-0'"); execute_query(nodes[i], "SET GLOBAL gtid_slave_pos='0-1-0'");
} }
// TODO: Reuse the code in sync_slaves() to get the actual file name and position if (i != 0)
execute_query(nodes[i], {
"CHANGE MASTER TO " // TODO: Reuse the code in sync_slaves() to get the actual file name and position
"MASTER_HOST='%s', MASTER_PORT=%d, " execute_query(nodes[i],
"MASTER_USER='repl', MASTER_PASSWORD='repl', " "CHANGE MASTER TO "
"%s", "MASTER_HOST='%s', MASTER_PORT=%d, "
IP_private[0], port[0], g_require_gtid ? "MASTER_USER='repl', MASTER_PASSWORD='repl', "
"MASTER_USE_GTID=slave_pos" : "%s",
"MASTER_LOG_FILE='mar-bin.000001', MASTER_LOG_POS=4"); IP_private[0], port[0], g_require_gtid ?
"MASTER_USE_GTID=slave_pos" :
"MASTER_LOG_FILE='mar-bin.000001', MASTER_LOG_POS=4");
execute_query(nodes[i], "START SLAVE"); execute_query(nodes[i], "START SLAVE");
}
} }
return local_result; return local_result;