diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 6621dcf1e..1a0f9c6f3 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -606,6 +606,10 @@ add_test_executable(mxs1503_extra_slaves.cpp mxs1503_extra_slaves mxs1503_extra_ # https://jira.mariadb.org/browse/MXS-1506 add_test_executable(mxs1506_delayed_retry.cpp mxs1506_delayed_retry mxs1506_delayed_retry LABELS readwritesplit REPL_BACKEND) +# MXS-1506: Delayed retry without master +# https://jira.mariadb.org/browse/MXS-1506 +add_test_executable(mxs1506_no_master.cpp mxs1506_no_master mxs1506_delayed_retry LABELS readwritesplit REPL_BACKEND) + # MXS-1509: Show correct server state for multisource replication # https://jira.mariadb.org/browse/MXS-1509 add_test_executable(mxs1509.cpp mxs1509 mxs1509 LABELS mysqlmon REPL_BACKEND) diff --git a/maxscale-system-test/mxs1506_no_master.cpp b/maxscale-system-test/mxs1506_no_master.cpp new file mode 100644 index 000000000..bac4a1d98 --- /dev/null +++ b/maxscale-system-test/mxs1506_no_master.cpp @@ -0,0 +1,61 @@ +/** + * MXS-1506: Delayed query retry without master + * + * https://jira.mariadb.org/browse/MXS-1506 + */ +#include "testconnections.h" +#include +#include +#include +#include +#include + +using namespace std; + +bool query(TestConnections& test) +{ + test.maxscales->connect(); + execute_query_silent(test.maxscales->conn_rwsplit[0], "SET @a = 1") == 0; + sleep(5); + auto row = get_row(test.maxscales->conn_rwsplit[0], "SELECT @a"); + test.maxscales->disconnect(); + return row[0] == "1"; +} + +void block(TestConnections& test, std::vector nodes) +{ + for (auto a : nodes) + { + test.repl->block_node(a); + } + + sleep(10); + + for (auto a : nodes) + { + test.repl->unblock_node(a); + } +} + +int main(int argc, char** argv) +{ + TestConnections test(argc, argv); + thread thr; + + cout << "Blocking the master and executing a SELECT" << endl; + thr = thread(block, std::ref(test), vector({0})); + test.assert(query(test), "Select without master should work"); + thr.join(); + + cout << "Blocking the slave and executing a SELECT" << endl; + thr = thread(block, std::ref(test), vector({1})); + test.assert(query(test), "Select without slave should work"); + thr.join(); + + cout << "Blocking both servers and executing a SELECT" << endl; + thr = thread(block, std::ref(test), vector({0, 1})); + test.assert(query(test), "Select with no servers should work"); + thr.join(); + + return test.global_result; +}