MXS-1804: Fix hanging of large session commands

Large session commands weren't properly handled which caused the router to
think that the trailing end of a multi-packet query was actually a new
query.

This cannot be confidently solved in 2.2 which is why the router session
is now closed the moment a large session command is noticed.
This commit is contained in:
Markus Mäkelä
2018-04-17 14:57:54 +03:00
parent 232f807ef3
commit 3a1c2119fb
4 changed files with 67 additions and 12 deletions

View File

@ -648,6 +648,10 @@ add_test_executable(mxs1786_statistics.cpp mxs1786_statistics replication LABELS
# https://jira.mariadb.org/browse/MXS-1787
add_test_executable(mxs1787_call_ps.cpp mxs1787_call_ps replication LABELS readwritesplit REPL_BACKEND)
# MXS-1804: request 16M-1 stmt_prepare command packet connect hang
# https://jira.mariadb.org/browse/MXS-1804
add_test_executable(mxs1804_long_ps_hang.cpp mxs1804_long_ps_hang replication LABELS readwritesplit REPL_BACKEND)
# MXS-1808: Crash with mysql_stmt_send_long_data
# https://jira.mariadb.org/browse/MXS-1808
add_test_executable(mxs1808_long_data.cpp mxs1808_long_data replication LABELS readwritesplit REPL_BACKEND)

View File

@ -0,0 +1,41 @@
/**
* MXS-1804: request 16M-1 stmt_prepare command packet connect hang
*
* https://jira.mariadb.org/browse/MXS-1804
*/
#include "testconnections.h"
int sql_str_size(int sqlsize)
{
char prefx[] = "select ''";
return sqlsize - strlen(prefx) - 1;
}
void gen_select_sqlstr(char *sqlstr, unsigned int strsize, int sqlsize)
{
strcpy(sqlstr, "select '");
memset(sqlstr + strlen("select '"), 'f', strsize);
sqlstr[sqlsize - 2] = '\'';
sqlstr[sqlsize - 1] = '\0';
}
int main(int argc, char** argv)
{
TestConnections test(argc, argv);
int sqlsize = 16777215;
int strsize = sql_str_size(sqlsize);
char* sqlstr = (char *)malloc(sqlsize);
gen_select_sqlstr(sqlstr, strsize, sqlsize);
test.set_timeout(30);
test.maxscales->connect();
MYSQL_STMT* stmt = mysql_stmt_init(test.maxscales->conn_rwsplit[0]);
test.assert(mysql_stmt_prepare(stmt, sqlstr, strlen(sqlstr)) != 0, "Prepare should fail in 2.2 but not hang",
mysql_stmt_error(stmt));
mysql_stmt_close(stmt);
return test.global_result;
}