MXS-1985: Add concurrent KILL test case
The test case runs parallel KILL queries and reproduces the problem.
This commit is contained in:
@ -961,6 +961,10 @@ set_tests_properties(mxs1958_insert_priv PROPERTIES WILL_FAIL TRUE)
|
|||||||
# https://jira.mariadb.org/browse/MXS-1961
|
# https://jira.mariadb.org/browse/MXS-1961
|
||||||
add_test_executable(mxs1961_standalone_rejoin.cpp mxs1961_standalone_rejoin mxs1961_standalone_rejoin LABELS REPL_BACKEND)
|
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)
|
configure_file(templates.h.in templates.h @ONLY)
|
||||||
|
|
||||||
include(CTest)
|
include(CTest)
|
||||||
|
|||||||
55
maxscale-system-test/mxs1985_kill_hang.cpp
Normal file
55
maxscale-system-test/mxs1985_kill_hang.cpp
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/**
|
||||||
|
* MXS-1985: MaxScale hangs on concurrent KILL processing
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "testconnections.h"
|
||||||
|
|
||||||
|
#include <atomic>
|
||||||
|
#include <thread>
|
||||||
|
#include <iostream>
|
||||||
|
|
||||||
|
using namespace std;
|
||||||
|
|
||||||
|
static atomic<bool> running{true};
|
||||||
|
|
||||||
|
int main(int argc, char *argv[])
|
||||||
|
{
|
||||||
|
TestConnections test(argc, argv);
|
||||||
|
vector<thread> 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;
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user