MXS-1786: Fix hang on COM_STATISTICS

The commands needs to be handled separately from the rest of the result
types.

Added a test case that reproduces the problem and verifies that the change
in code fixes it.
This commit is contained in:
Markus Mäkelä 2018-04-12 20:00:00 +03:00
parent 1a293c0093
commit 802b16f709
No known key found for this signature in database
GPG Key ID: 72D48FCE664F7B19
3 changed files with 34 additions and 0 deletions

View File

@ -637,6 +637,10 @@ add_test_executable(mxs1773_failing_ldli.cpp mxs1773_failing_ldli replication LA
# https://jira.mariadb.org/browse/MXS-1776
add_test_executable(mxs1776_ps_exec_hang.cpp mxs1776_ps_exec_hang replication LABELS readwritesplit REPL_BACKEND)
# MXS-1786: Hang with COM_STATISTICS
# https://jira.mariadb.org/browse/MXS-1786
add_test_executable(mxs1786_statistics.cpp mxs1786_statistics replication LABELS readwritesplit REPL_BACKEND)
# 'namedserverfilter' test
add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND)

View File

@ -0,0 +1,24 @@
/**
* MXS-1786: Hang with COM_STATISTICS
*/
#include "testconnections.h"
int main(int argc, char* argv[])
{
TestConnections test(argc, argv);
test.maxscales->connect();
for (int i = 0; i < 10; i++)
{
test.set_timeout(10);
mysql_stat(test.maxscales->conn_rwsplit[0]);
test.try_query(test.maxscales->conn_rwsplit[0], "SELECT 1");
}
test.maxscales->disconnect();
return test.global_result;
}

View File

@ -534,6 +534,12 @@ bool reply_is_complete(SRWBackend& backend, GWBUF *buffer)
backend->set_reply_state(REPLY_STATE_DONE);
}
}
else if (backend->current_command() == MXS_COM_STATISTICS)
{
// COM_STATISTICS returns a single string and thus requires special handling
LOG_RS(backend, REPLY_STATE_DONE);
backend->set_reply_state(REPLY_STATE_DONE);
}
else if (backend->get_reply_state() == REPLY_STATE_START &&
(!mxs_mysql_is_result_set(buffer) || GWBUF_IS_COLLECTED_RESULT(buffer)))
{