From 2023ee4dc748e446d6375d9095d528f439debcdf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sat, 10 Mar 2018 12:47:53 +0200 Subject: [PATCH] MXS-1713: Fix resultset collection code The resultset collection was not detected early enough in the code which caused partial results to be returned to the router. --- maxscale-system-test/CMakeLists.txt | 4 ++ ...ale.cnf.template.mxs1713_lots_of_databases | 39 +++++++++++++ .../mxs1713_lots_of_databases.cpp | 58 +++++++++++++++++++ .../MySQL/mariadbbackend/mysql_backend.c | 1 + 4 files changed, 102 insertions(+) create mode 100644 maxscale-system-test/cnf/maxscale.cnf.template.mxs1713_lots_of_databases create mode 100644 maxscale-system-test/mxs1713_lots_of_databases.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 503be6b89..7fd0d424a 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -613,6 +613,10 @@ add_test_executable(mxs1677_temp_table.cpp mxs1677_temp_table replication LABELS # https://jira.mariadb.org/browse/MXS-1678 add_test_executable(mxs1678_relay_master.cpp mxs1678_relay_master replication LABELS REPL_BACKEND) +# MXS-1713: SchemaRouter unable to process SHOW DATABASES for a lot of schemas +# https://jira.mariadb.org/browse/MXS-1713 +add_test_executable(mxs1713_lots_of_databases.cpp mxs1713_lots_of_databases mxs1713_lots_of_databases LABELS REPL_BACKEND) + # 'namedserverfilter' test add_test_executable(namedserverfilter.cpp namedserverfilter namedserverfilter LABELS namedserverfilter LIGHT REPL_BACKEND) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs1713_lots_of_databases b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1713_lots_of_databases new file mode 100644 index 000000000..ff7ef6122 --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs1713_lots_of_databases @@ -0,0 +1,39 @@ +[maxscale] +threads=###threads### + +[MySQL Monitor] +type=monitor +module=mysqlmon +###repl51### +servers=server1 +user=maxskysql +passwd=skysql + +[Sharding router] +type=service +router=schemarouter +servers=server1 +user=maxskysql +passwd=skysql + +[Sharding Listener] +type=listener +service=Sharding 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 diff --git a/maxscale-system-test/mxs1713_lots_of_databases.cpp b/maxscale-system-test/mxs1713_lots_of_databases.cpp new file mode 100644 index 000000000..5e79c638c --- /dev/null +++ b/maxscale-system-test/mxs1713_lots_of_databases.cpp @@ -0,0 +1,58 @@ +/** + * MXS-1713: SchemaRouter unable to process SHOW DATABASES for a lot of schemas + * + * https://jira.mariadb.org/browse/MXS-1713 + */ +#include "testconnections.h" +#include +#include +#include + +int main(int argc, char** argv) +{ + TestConnections test(argc, argv); + const int n_db = 2000; + std::vector db_list; + + for (int i = 0; i < n_db; i++) + { + db_list.push_back("db" + std::to_string(i)); + } + + test.tprintf("Create %lu databases...", db_list.size()); + test.repl->connect(); + for (auto db : db_list) + { + execute_query(test.repl->nodes[0], "CREATE DATABASE %s", db.c_str()); + } + test.tprintf("Done!"); + + test.tprintf("Opening a connection with each database as the default database...", db_list.size()); + std::set errors; + + for (auto db : db_list) + { + MYSQL* conn = open_conn_db(test.maxscales->port(), test.maxscales->ip(), db, + test.maxscales->user_name, test.maxscales->password); + if (execute_query_silent(conn, "SELECT 1") || + execute_query_silent(conn, "SHOW DATABASES")) + { + errors.insert(mysql_error(conn)); + } + mysql_close(conn); + } + test.tprintf("Done!"); + + test.assert(errors.empty(), "None of the queries should fail: %s", + std::accumulate(errors.begin(), errors.end(), std::string(), + [](const std::string &a, const std::string &b){return a + b + " ";})); + + test.tprintf("Dropping databases..."); + for (auto db : db_list) + { + execute_query(test.repl->nodes[0], "DROP DATABASE %s", db.c_str()); + } + test.tprintf("Done!"); + + return test.global_result; +} diff --git a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c index 7917d8889..adc8acbd7 100644 --- a/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c +++ b/server/modules/protocol/MySQL/mariadbbackend/mysql_backend.c @@ -752,6 +752,7 @@ gw_read_and_write(DCB *dcb) if (rcap_type_required(capabilities, RCAP_TYPE_PACKET_OUTPUT) || rcap_type_required(capabilities, RCAP_TYPE_CONTIGUOUS_OUTPUT) || + proto->collect_result || proto->ignore_replies != 0) { GWBUF *tmp = modutil_get_complete_packets(&read_buffer);