MXS-1719 Add test that reveals problem

With the masking filter, several UPDATEs as one multi-statement
causes the session to hang.
This commit is contained in:
Johan Wikman 2018-03-19 14:52:05 +02:00
parent c4d3628c4a
commit f5562d2cab
5 changed files with 154 additions and 0 deletions

View File

@ -158,6 +158,7 @@ mxs1643_extra_events
mxs1653_ps_hang
mxs1677_temp_table
mxs1678_relay_master
mxs1719
mxs244_prepared_stmt_loop
mxs280_select_outfile
mxs314

View File

@ -814,6 +814,9 @@ add_test_executable(mxs781_binlog_wrong_passwrd.cpp mxs781_binlog_wrong_passwrd
# Regression case for crash if long host name is used for binlog router (in 'change master to ...')
add_test_executable(mxs813_long_hostname.cpp mxs813_long_hostname setup_binlog LABELS binlogrouter BREAKS_REPL)
# Test that masking filter can handle multi-statements.
add_test_executable(mxs1719.cpp mxs1719 mxs1719 LABELS masking REPL_BACKEND)
# configure binlog router setup, execute queries and transactions, check data;
add_test_executable(setup_binlog.cpp setup_binlog setup_binlog LABELS binlogrouter BREAKS_REPL)

View File

@ -0,0 +1,48 @@
[maxscale]
threads=###threads###
maxlog=1
log_info=1
[server1]
type=server
address=###node_server_IP_1###
port=###node_server_port_1###
protocol=MySQLBackend
[TheMonitor]
type=monitor
module=mysqlmon
servers=server1
user=maxskysql
passwd=skysql
[Masking]
type=filter
module=masking
rules=/home/vagrant/mxs1719.json
warn_type_mismatch=always
large_payload=ignore
[RWS]
type=service
router=readwritesplit
servers=server1
user=maxskysql
passwd=skysql
filters=Masking
[RWS-Listener]
type=listener
service=RWS
protocol=MySQLClient
port=4006
[CLI]
type=service
router=cli
[CLI-Listener]
type=listener
service=CLI
protocol=maxscaled
socket=default

View File

@ -0,0 +1,90 @@
/*
* Copyright (c) 2016 MariaDB Corporation Ab
*
* Use of this software is governed by the Business Source License included
* in the LICENSE.TXT file and at www.mariadb.com/bsl11.
*
* Change Date: 2020-01-01
*
* On the date above, in accordance with the Business Source License, use
* of this software will be governed by version 2 or later of the General
* Public License.
*/
#include <iostream>
#include "testconnections.h"
using namespace std;
namespace
{
void init(TestConnections& test)
{
MYSQL* pMysql = test.maxscales->conn_rwsplit[0];
test.try_query(pMysql, "DROP TABLE IF EXISTS MXS_1719");
test.try_query(pMysql, "CREATE TABLE MXS_1719 (a TEXT, b TEXT)");
test.try_query(pMysql, "INSERT INTO MXS_1719 VALUES (1, 1)");
}
void run(TestConnections& test)
{
init(test);
MYSQL* pMysql = mysql_init(NULL);
test.assert(pMysql, "Could not create MYSQL handle.");
const char* zHost = test.maxscales->IP[0];
const char* zUser = test.maxscales->user_name;
const char* zPassword = test.maxscales->password;
int port = test.maxscales->rwsplit_port[0];
if (mysql_real_connect(pMysql, test.maxscales->IP[0], zUser, zPassword, "test", port, NULL,
CLIENT_MULTI_STATEMENTS))
{
// One multi-statement with two UPDATEs.
test.try_query(pMysql, "UPDATE MXS_1719 SET a=1; UPDATE MXS_1719 SET a=1;");
// This will hang immediately, so we can shorten the timeout.
test.set_timeout(5);
test.try_query(pMysql, "SELECT * FROM MXS_1719");
}
else
{
test.assert(false, "Could not connect to MaxScale.");
}
}
}
int main(int argc, char* argv[])
{
TestConnections::skip_maxscale_start(true);
TestConnections test(argc, argv);
if (test.maxscales->copy_to_node(0, "./mxs1719.json", "/home/vagrant/mxs1719.json") == 0)
{
if (test.maxscales->start() == 0)
{
if (test.maxscales->connect_rwsplit() == 0)
{
run(test);
}
else
{
test.assert(false, "Could not connect to RWS.");
}
}
else
{
test.assert(false, "Could not start MaxScale.");
}
}
else
{
test.assert(false, "Could not copy masking file to MaxScale node.");
}
return test.global_result;
}

View File

@ -0,0 +1,12 @@
{
"rules": [
{
"replace": {
"column": "a"
},
"with": {
"fill": "X"
}
}
]
}