Merge branch '2.1' into develop

This commit is contained in:
Markus Mäkelä
2017-07-31 15:57:05 +03:00
27 changed files with 389 additions and 58 deletions

View File

@ -302,6 +302,10 @@ add_test_executable(mxs1110_16mb.cpp mxs1110_16mb longblob_filters LABELS readwr
# Schemarouter implicit database detection
add_test_executable(mxs1310_implicit_db.cpp mxs1310_implicit_db mxs1310_implicit_db LABELS schemarouter REPL_BACKEND)
# Retry reads with persistent connections
add_test_executable(mxs1323_retry_read.cpp mxs1323_retry_read mxs1323 LABELS readwritesplit LIGHT REPL_BACKEND)
add_test_executable(mxs1323_stress.cpp mxs1323_stress mxs1323 LABELS readwritesplit REPL_BACKEND)
# INSERT extremelly big number of rows
add_test_executable(lots_of_rows.cpp lots_of_rows galera LABELS readwritesplit HEAVY GALERA_BACKEND)
@ -309,7 +313,7 @@ add_test_executable(lots_of_rows.cpp lots_of_rows galera LABELS readwritesplit H
add_test_script(mariadb_tests_hartmut mariadb_tests_hartmut.sh replication LABELS readwritesplit REPL_BACKEND)
# A set of MariaDB server tests executed against Maxscale RWSplit (Galera backend)
add_test_script(mariadb_tests_hartmut_galera mariadb_tests_hartmut.sh galera LABELS readwritesplit GALERA_BACKEND)
add_test_script(mariadb_tests_hartmut_galera mariadb_tests_hartmut.sh galera_hartmut LABELS readwritesplit GALERA_BACKEND)
# Creates a number of connections > max_connections setting
add_test_executable(max_connections.cpp max_connections replication LABELS MySQLAuth MySQLProtocol UNSTABLE HEAVY REPL_BACKEND)
@ -545,7 +549,7 @@ add_test_executable(rwsplit_multi_stmt.cpp rwsplit_multi_stmt rwsplit_multi_stmt
add_test_executable(rwsplit_read_only_trx.cpp rwsplit_read_only_trx rwsplit_read_only_trx LABELS readwritesplit REPL_BACKEND)
# Test replication-manager with MaxScale
add_test_executable(replication_manager.cpp replication_manager replication_manager LABELS maxscale REPL_BACKEND)
#add_test_executable(replication_manager.cpp replication_manager replication_manager LABELS maxscale REPL_BACKEND)
#add_test_executable_notest(replication_manager_2nodes.cpp replication_manager_2nodes replication_manager_2nodes LABELS maxscale REPL_BACKEND)
#add_test_executable_notest(replication_manager_3nodes.cpp replication_manager_3nodes replication_manager_3nodes LABELS maxscale REPL_BACKEND)

View File

@ -65,6 +65,7 @@ int main(int argc, char *argv[])
free(rows);
}
test.stop_timeout();
execute_query(test.repl->nodes[0], "DROP TABLE test.t1;RESET MASTER");
test.repl->fix_replication();

View File

@ -1,39 +1,18 @@
/**
* @file bug662.cpp regression case for bug 662 ("MaxScale hangs in startup if backend server is not responsive"), covers also bug680 ("RWSplit can't load DB user if backend is not available at MaxScale start")
*
* - block all Mariadb servers Firewall
* - restart MaxScale
* - check it took no more then 20 seconds
* - unblock Mariadb servers
* - sleep one minute
* - check if Maxscale is alive
* - Block all Mariadb servers
* - Restart MaxScale
* - Unblock Mariadb servers
* - Sleep and check if Maxscale is alive
*/
/*
Vilho Raatikka 2014-12-29 08:38:28 UTC
During startup, load_mysql_users tries to read the contents of the mysql.user table. If the chosen backend is not responsive, connection hangs for a long time.
Comment 1 Vilho Raatikka 2014-12-29 11:41:32 UTC
The issue causes long stalls for the executing thread whenever getUsers function is called and one or more backends are not responsive.
Comment 2 Vilho Raatikka 2014-12-29 11:50:10 UTC
dbusers.c: Added function for setting read, write and connection timeout values. Set default timeouts for getUsers. Defaults are listed in service.c
gateway.c:shutdown_server is called whenever MaxScale is to be shut down. Added call for service_shutdown to shutdown_server.
service.c:service_alloc: replaced malloc with calloc and removed unnecessary zero/NULL initialization statements as a consequence.
serviceStart: Exit serviceStartPort loop if shutdown flag is set for the service.
serviceStartAll: Exit serviceStart loop if shutdown flag is set for the service.
service.c: Added service_shutdown which sets shutdown flag for each service found in allServices list.
service.h: Added prototype for service_shutdown
*/
#include <iostream>
#include "testconnections.h"
#include "maxadmin_operations.h"
int main(int argc, char *argv[])
{
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(20);
int i;
Test->tprintf("Connecting to Maxscale %s\n", Test->maxscale_IP);
@ -44,6 +23,7 @@ int main(int argc, char *argv[])
for (i = 0; i < Test->repl->N; i++)
{
Test->set_timeout(30);
Test->tprintf("Setup firewall to block mysql on node %d\n", i);
Test->repl->block_node(i);
fflush(stdout);
@ -53,12 +33,12 @@ int main(int argc, char *argv[])
Test->tprintf("Restarting MaxScale");
Test->restart_maxscale();
Test->set_timeout(20);
Test->tprintf("Checking if MaxScale is alive by connecting to MaxAdmin\n");
Test->add_result(Test->execute_maxadmin_command((char* ) "show servers"), "Maxadmin execution failed.\n");
for (i = 0; i < Test->repl->N; i++)
{
Test->set_timeout(30);
Test->tprintf("Setup firewall back to allow mysql on node %d\n", i);
Test->repl->unblock_node(i);
fflush(stdout);
@ -68,13 +48,11 @@ int main(int argc, char *argv[])
Test->tprintf("Sleeping 30 seconds\n");
sleep(30);
Test->set_timeout(20);
Test->set_timeout(30);
Test->tprintf("Checking Maxscale is alive\n");
Test->check_maxscale_alive();
int rval = Test->global_result;
delete Test;
return rval;
//}
}

View File

@ -0,0 +1,89 @@
[maxscale]
threads=###threads###
log_info=1
[Galera Monitor]
type=monitor
module=galeramon
servers=server1,server2,server3,server4
user=maxskysql
passwd=skysql
monitor_interval=1000
root_node_as_master=false
[RW Split Router]
type=service
router=readwritesplit
servers=server1,server2,server3,server4
user=maxskysql
passwd=skysql
router_options=slave_selection_criteria=LEAST_GLOBAL_CONNECTIONS
max_slave_connections=1
[Read Connection Router Slave]
type=service
router=readconnroute
router_options=slave
servers=server1,server2,server3,server4
user=maxskysql
passwd=skysql
[Read Connection Router Master]
type=service
router=readconnroute
router_options=master
servers=server1,server2,server3,server4
user=maxskysql
passwd=skysql
[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
[Read Connection Listener Slave]
type=listener
service=Read Connection Router Slave
protocol=MySQLClient
port=4009
[Read Connection Listener Master]
type=listener
service=Read Connection Router Master
protocol=MySQLClient
port=4008
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default
[server1]
type=server
address=###galera_server_IP_1###
port=###galera_server_port_1###
protocol=MySQLBackend
[server2]
type=server
address=###galera_server_IP_2###
port=###galera_server_port_2###
protocol=MySQLBackend
[server3]
type=server
address=###galera_server_IP_3###
port=###galera_server_port_3###
protocol=MySQLBackend
[server4]
type=server
address=###galera_server_IP_4###
port=###galera_server_port_4###
protocol=MySQLBackend

View File

@ -0,0 +1,51 @@
[maxscale]
threads=###threads###
log_info=1
[MySQL Monitor]
type=monitor
module=mysqlmon
###repl51###
servers= server1,server2
user=maxskysql
passwd= skysql
monitor_interval=500
[RW Split Router]
type=service
router= readwritesplit
servers=server1,server2
user=maxskysql
passwd=skysql
[RW Split Listener]
type=listener
service=RW Split Router
protocol=MySQLClient
port=4006
[CLI]
type=service
router=cli
[CLI Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default
[server1]
type=server
address=###node_server_IP_1###
port=###node_server_port_1###
protocol=MySQLBackend
persistpoolmax=10
persistmaxtime=300
[server2]
type=server
address=###node_server_IP_2###
port=###node_server_port_2###
protocol=MySQLBackend
persistpoolmax=10
persistmaxtime=300

View File

@ -14,6 +14,7 @@
#include "sql_const.h"
#include <climits>
#include <string>
#include <sstream>
#include <vector>
Mariadb_nodes::Mariadb_nodes(const char *pref, const char *test_cwd, bool verbose):
@ -918,6 +919,13 @@ int Mariadb_nodes::get_server_id(int index)
return id;
}
std::string Mariadb_nodes::get_server_id_str(int index)
{
std::stringstream ss;
ss << get_server_id(index);
return ss.str();
}
void Mariadb_nodes::generate_ssh_cmd(char *cmd, int node, const char *ssh, bool sudo)
{
if (strcmp(IP[node], "127.0.0.1") == 0)

View File

@ -16,6 +16,7 @@
#include "mariadb_func.h"
#include <errno.h>
#include <string>
/**
* @brief A class to handle backend nodes
@ -329,6 +330,7 @@ public:
* @return Node id of the server or -1 on error
*/
int get_server_id(int index);
std::string get_server_id_str(int index);
/**
* @brief Generate command line to execute command on the node via ssh

View File

@ -4,7 +4,7 @@
#
# TODO: Don't test correctness of routing with mysqltest
#
./non_native_setup $1
master_id=`echo "SELECT @@server_id" | mysql -u$node_user -p$node_password -h $node_000_network $ssl_options -P $node_000_port | tail -n1`
echo "--disable_query_log" > Hartmut_tests/maxscale-mysqltest/testconf.inc
echo "SET @TMASTER_ID=$master_id;" >> Hartmut_tests/maxscale-mysqltest/testconf.inc

View File

@ -207,7 +207,7 @@ int compare_expected(TestConnections * Test, const char * sql, my_ulonglong exp_
my_ulonglong *rows = new my_ulonglong[30];
my_ulonglong i;
Test->set_timeout(10);
Test->set_timeout(30);
execute_query_num_of_rows(Test->conn_rwsplit, sql, rows, &i);
Test->tprintf("Result sets number is %llu\n", i);
@ -245,7 +245,7 @@ int compare_stmt_expected(TestConnections * Test, MYSQL_STMT * stmt, my_ulonglon
my_ulonglong *rows = new my_ulonglong[30];
my_ulonglong i;
Test->set_timeout(10);
Test->set_timeout(30);
execute_stmt_num_of_rows(stmt, rows, &i);
Test->tprintf("Result sets number is %llu\n", i);
@ -290,7 +290,7 @@ int main(int argc, char *argv[])
MYSQL_STMT * stmt;
TestConnections * Test = new TestConnections(argc, argv);
Test->set_timeout(10);
Test->set_timeout(30);
Test->connect_rwsplit();
create_t1(Test->conn_rwsplit);

View File

@ -0,0 +1,50 @@
/**
* Test for MXS-1323.
* - Check that retried reads work with persistent connections
*/
#include "testconnections.h"
void* async_block(void* data)
{
TestConnections *test = (TestConnections*)data;
sleep(5);
test->tprintf("Blocking slave");
test->repl->block_node(1);
return NULL;
}
std::string do_query(TestConnections& test)
{
MYSQL* conn = test.open_rwsplit_connection();
const char* query = "SELECT SLEEP(10), @@server_id";
char output[512] = "";
find_field(conn, query, "@@server_id", output);
mysql_close(conn);
return std::string(output);
}
int main(int argc, char *argv[])
{
TestConnections test(argc, argv);
char server_id[2][1024];
test.repl->connect();
std::string master = test.repl->get_server_id_str(0);
std::string slave = test.repl->get_server_id_str(1);
test.repl->close_connections();
test.set_timeout(60);
test.add_result(do_query(test) != slave, "The slave should respond to the first query");
pthread_t thr;
pthread_create(&thr, NULL, async_block, &test);
test.add_result(do_query(test) != master, "The master should respond to the second query");
pthread_join(thr, NULL);
test.repl->unblock_node(1);
return test.global_result;
}

View File

@ -0,0 +1,81 @@
/**
* Test for MXS-1323.
* - Check that retried reads work with persistent connections
*/
#include "testconnections.h"
#include <sstream>
static bool running = true;
void* async_query(void* data)
{
TestConnections *test = (TestConnections*)data;
while (running && test->global_result == 0)
{
MYSQL* conn = test->open_rwsplit_connection();
for (int i = 0; i < 50 && running && test->global_result == 0; i++)
{
const char* query = "SET @a = (SELECT SLEEP(1))";
test->try_query(conn, query);
}
mysql_close(conn);
}
return NULL;
}
#define NUM_THR 5
int main(int argc, char *argv[])
{
TestConnections test(argc, argv);
pthread_t query_thr[NUM_THR];
std::stringstream ss;
ss << "CREATE OR REPLACE TABLE test.t1 (id INT)";
test.connect_maxscale();
test.try_query(test.conn_rwsplit, ss.str().c_str());
ss.str("");
ss << "INSERT INTO test.t1 VALUES (0)";
for (int i = 1; i <= 10000; i++)
{
ss << ",(" << i << ")";
}
test.try_query(test.conn_rwsplit, ss.str().c_str());
test.close_maxscale_connections();
if (test.global_result)
{
return test.global_result;
}
for (int i = 0; i < NUM_THR; i++)
{
pthread_create(&query_thr[i], NULL, async_query, &test);
}
for (int i = 0; i < 3 && test.global_result == 0; i++)
{
test.tprintf("Round %d", i + 1);
test.repl->block_node(1);
sleep(5);
test.repl->unblock_node(1);
sleep(5);
}
running = false;
for (int i = 0; i < NUM_THR; i++)
{
test.set_timeout(10);
pthread_join(query_thr[i], NULL);
}
return test.global_result;
}