Files
MaxScale/maxscale-system-test/mxs1585.cpp
Markus Mäkelä de768469b9 Fix hanging of mxs1585
The test appears to hang when the `SET sql_log_bin = 0` statement is
executed. Removing this seems to fix it and is OK as that's not what the
test aims to check.
2018-03-27 11:50:30 +03:00

78 lines
1.8 KiB
C++

/**
* MXS-1585: https://jira.mariadb.org/browse/MXS-1585
*
* Check that MaxScale doesn't crash when the master is set into maintenance
* mode when master_failure_mode is fail_on_write.
*/
#include "testconnections.h"
#include <vector>
static bool running = true;
void* query_thr(void* data)
{
TestConnections* test = (TestConnections*)data;
while (running)
{
MYSQL* mysql = test->open_rwsplit_connection();
while (running)
{
if (mysql_query(mysql, "INSERT INTO test.mxs1585 VALUES (1)") ||
mysql_query(mysql, "DELETE FROM test.mxs1585 LIMIT 100"))
{
break;
}
}
mysql_close(mysql);
}
return NULL;
}
int main(int argc, char** argv)
{
TestConnections test(argc, argv);
test.connect_maxscale();
test.try_query(test.conn_rwsplit, "DROP TABLE IF EXISTS test.mxs1585");
test.try_query(test.conn_rwsplit, "CREATE TABLE test.mxs1585(id INT) ENGINE=MEMORY");
test.close_maxscale_connections();
std::vector<pthread_t> threads;
threads.resize(100);
for (auto& a: threads)
{
pthread_create(&a, NULL, query_thr, &test);
}
for (int i = 0; i < 5; i++)
{
for (int x = 1; x <= 4; x++)
{
test.ssh_maxscale(true, "maxadmin set server server%d maintenance", x);
sleep(1);
test.ssh_maxscale(true, "maxadmin clear server server%d maintenance", x);
sleep(1);
}
}
running = false;
for (auto& a: threads)
{
test.set_timeout(60);
pthread_join(a, NULL);
}
test.connect_maxscale();
test.try_query(test.conn_rwsplit, "DROP TABLE test.mxs1585");
test.check_maxscale_alive();
return test.global_result;
}