Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
markus456 committed Apr 12, 2018
1 parent 1a293c0 commit 802b16f
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 0 deletions.
4 changes: 4 additions & 0 deletions maxscale-system-test/CMakeLists.txt
Expand Up @@ -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)

Expand Down
24 changes: 24 additions & 0 deletions maxscale-system-test/mxs1786_statistics.cpp
@@ -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;
}
6 changes: 6 additions & 0 deletions server/modules/routing/readwritesplit/readwritesplit.cc
Expand Up @@ -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)))
{
Expand Down

0 comments on commit 802b16f

Please sign in to comment.