diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index fd16e0ffa..d18cea2ff 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -961,6 +961,10 @@ set_tests_properties(mxs1958_insert_priv PROPERTIES WILL_FAIL TRUE) # https://jira.mariadb.org/browse/MXS-1961 add_test_executable(mxs1961_standalone_rejoin.cpp mxs1961_standalone_rejoin mxs1961_standalone_rejoin LABELS REPL_BACKEND) +# MXS-1985: MaxScale hangs on concurrent KILL processing +# https://jira.mariadb.org/browse/MXS-1985 +add_test_executable(mxs1985_kill_hang.cpp mxs1985_kill_hang replication LABELS REPL_BACKEND) + configure_file(templates.h.in templates.h @ONLY) include(CTest) diff --git a/maxscale-system-test/mxs1985_kill_hang.cpp b/maxscale-system-test/mxs1985_kill_hang.cpp new file mode 100644 index 000000000..2ee70392e --- /dev/null +++ b/maxscale-system-test/mxs1985_kill_hang.cpp @@ -0,0 +1,55 @@ +/** + * MXS-1985: MaxScale hangs on concurrent KILL processing + */ + +#include "testconnections.h" + +#include +#include +#include + +using namespace std; + +static atomic running{true}; + +int main(int argc, char *argv[]) +{ + TestConnections test(argc, argv); + vector threads; + + for (int i = 0; i < 20; i++) + { + threads.emplace_back([&, i]() + { + while (running) + { + MYSQL* c = test.maxscales->open_rwsplit_connection(); + + // It doesn't really matter if the connection ID exists, this is just a + // handy way of generating cross-thread communication. + for (auto&& a: get_result(c, "SELECT id FROM information_schema.processlist" + " WHERE user like '%skysql%'")) + { + if (execute_query_silent(c, std::string("KILL " + a[0]).c_str())) + { + break; + } + } + + mysql_close(c); + } + }); + } + + sleep(10); + running = false; + + // If MaxScale hangs, at least one thread will not return in time + test.set_timeout(30); + for (auto&& a: threads) + { + a.join(); + } + + return test.global_result; +}