Files
MaxScale/maxscale-system-test/mxs1678_relay_master.cpp
Markus Mäkelä 5a62adc63e MXS-1678: Detect broken replication with Last_IO_Errno
This commit introduces changes that fix the relay master detection that
was broken by the merge from 2.1 into 2.2 by commit
1ecd791887994209eb29e56e1271f8c407cd0cdf.

In 2.2, the master server ID is used to detect whether a slave is actually
replicating from a master. The value is still displayed even if the slave
is not actively replicating from a master. The commit in 2.1 causes this
value to be stored unconditionally if it is available. By checking the
value of Last_IO_Errno and comparing it to a list of known error codes, we
know whether the slave is replicating properly.

The slave detection in 2.2 correctly identifies a broken slave with a
stopped IO thread. Due to this, the test case must be modified to check
that the relay master is not a slave if the IO thread is stopped.
2018-03-12 14:55:54 +02:00

51 lines
2.2 KiB
C++

/**
* MXS-1678: Stopping IO thread on relay master causes it to be promoted as master
*
* https://jira.mariadb.org/browse/MXS-1678
*/
#include "testconnections.h"
#include <set>
#include <string>
int main(int argc, char** argv)
{
TestConnections test(argc, argv);
test.repl->connect();
execute_query(test.repl->nodes[3], "STOP SLAVE");
execute_query(test.repl->nodes[3], "CHANGE MASTER TO MASTER_HOST='%s', MASTER_PORT=%d",
test.repl->IP_private[2], test.repl->port[2]);
execute_query(test.repl->nodes[3], "START SLAVE");
sleep(5);
StringSet master = {"Master", "Running"};
StringSet slave = {"Slave", "Running"};
StringSet relay_master = {"Relay Master", "Slave", "Running"};
StringSet relay_master_only = {"Relay Master", "Running"};
test.tprintf("Checking before stopping IO thread");
int exit_code;
char *output = test.maxscales->ssh_node_output(0, "maxadmin list servers", true, &exit_code);
test.tprintf("%s", output);
free(output);
test.add_result(test.maxscales->get_server_status("server1") != master, "server1 is not a master");
test.add_result(test.maxscales->get_server_status("server2") != slave, "server2 is not a slave");
test.add_result(test.maxscales->get_server_status("server3") != relay_master, "server3 is not a relay master");
test.add_result(test.maxscales->get_server_status("server4") != slave, "server4 is not a slave");
execute_query(test.repl->nodes[2], "STOP SLAVE IO_THREAD");
sleep(10);
test.tprintf("Checking after stopping IO thread");
output = test.maxscales->ssh_node_output(0, "maxadmin list servers", true, &exit_code);
test.tprintf("%s", output);
free(output);
test.add_result(test.maxscales->get_server_status("server1") != master, "server1 is not a master");
test.add_result(test.maxscales->get_server_status( "server2") != slave, "server2 is not a slave");
test.add_result(test.maxscales->get_server_status("server3") != relay_master_only, "server3 is not a relay master");
test.add_result(test.maxscales->get_server_status("server4") != slave, "server4 is not a slave");
test.repl->fix_replication();
return test.global_result;
}