From 527f9d31361bd95281b1f4915e82355eed767619 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Sun, 28 Jul 2019 09:35:20 +0300 Subject: [PATCH 1/5] Rewrite open_close_connections The test now uses standard library threads and lambda functions to make the code simpler. Also made the test more robust by ignoring any errors that are caused by the exhaustion of available client side TCP ports. --- .../open_close_connections.cpp | 134 +++++++----------- 1 file changed, 50 insertions(+), 84 deletions(-) diff --git a/maxscale-system-test/open_close_connections.cpp b/maxscale-system-test/open_close_connections.cpp index 167a8bd9b..d565bb740 100644 --- a/maxscale-system-test/open_close_connections.cpp +++ b/maxscale-system-test/open_close_connections.cpp @@ -6,113 +6,79 @@ #include "testconnections.h" -typedef struct -{ - int exit_flag; - int thread_id; - long i; - int rwsplit_only; - TestConnections* Test; -} openclose_thread_data; +#include +#include -void* query_thread1(void* ptr); -int threads_num = 20; +std::atomic run {true}; + +void query_thread(TestConnections& test, int thread_id) +{ + uint64_t i = 0; + + auto validate = [&](MYSQL* conn){ + unsigned int port = 0; + const char* host = ""; + mariadb_get_infov(conn, MARIADB_CONNECTION_PORT, &port); + mariadb_get_infov(conn, MARIADB_CONNECTION_HOST, &host); + + test.expect(mysql_errno(conn) == 0 || errno == EADDRNOTAVAIL, + "Error opening conn to %s:%u, thread num is %d, iteration %ld, error is: %s\n", + host, port, thread_id, i, mysql_error(conn)); + + if (conn && mysql_errno(conn) == 0) + { + test.try_query(conn, "USE test"); + mysql_close(conn); + } + }; + + // Keep running the test until we exhaust all available ports + while (run && test.global_result == 0 && errno != EADDRNOTAVAIL) + { + validate(test.maxscales->open_rwsplit_connection(0)); + validate(test.maxscales->open_readconn_master_connection(0)); + validate(test.maxscales->open_readconn_slave_connection(0)); + i++; + } +} int main(int argc, char* argv[]) { - TestConnections* Test = new TestConnections(argc, argv); - int run_time = Test->smoke ? 10 : 300; - - openclose_thread_data data[threads_num]; - for (int i = 0; i < threads_num; i++) - { - data[i].i = 0; - data[i].exit_flag = 0; - data[i].Test = Test; - data[i].thread_id = i; - } + TestConnections test(argc, argv); // Tuning these kernel parameters removes any system limitations on how many // connections can be created within a short period - Test->maxscales->ssh_node_f(0, + test.maxscales->ssh_node_f(0, true, "sysctl net.ipv4.tcp_tw_reuse=1 net.ipv4.tcp_tw_recycle=1 " "net.core.somaxconn=10000 net.ipv4.tcp_max_syn_backlog=10000"); - Test->repl->execute_query_all_nodes((char*) "set global max_connections = 50000;"); - Test->repl->sync_slaves(); + test.repl->execute_query_all_nodes((char*) "set global max_connections = 50000;"); + test.repl->sync_slaves(); - pthread_t thread1[threads_num]; + std::vector threads; + constexpr int threads_num = 20; - /* Create independent threads each of them will execute function */ for (int i = 0; i < threads_num; i++) { - pthread_create(&thread1[i], NULL, query_thread1, &data[i]); + threads.emplace_back(query_thread, std::ref(test), i); } - Test->tprintf("Threads are running %d seconds \n", run_time); + constexpr int run_time = 10; + test.tprintf("Threads are running for %d seconds", run_time); - for (int i = 0; i < run_time && Test->global_result == 0; i++) + for (int i = 0; i < run_time && test.global_result == 0; i++) { sleep(1); } - for (int i = 0; i < threads_num; i++) + run = false; + + for (auto& a : threads) { - data[i].exit_flag = 1; - pthread_join(thread1[i], NULL); + a.join(); } - Test->check_maxscale_alive(0); - int rval = Test->global_result; - delete Test; - return rval; -} - -void* query_thread1(void* ptr) -{ - openclose_thread_data* data = (openclose_thread_data*) ptr; - - while (data->exit_flag == 0 && data->Test->global_result == 0) - { - MYSQL* conn1 = data->Test->maxscales->open_rwsplit_connection(0); - data->Test->add_result(mysql_errno(conn1), - "Error opening RWsplit conn, thread num is %d, iteration %li, error is: %s\n", - data->thread_id, data->i, mysql_error(conn1)); - MYSQL* conn2 = data->Test->maxscales->open_readconn_master_connection(0); - data->Test->add_result(mysql_errno( - conn2), - "Error opening ReadConn master conn, thread num is %d, iteration %li, error is: %s\n", - data->thread_id, - data->i, - mysql_error(conn2)); - MYSQL* conn3 = data->Test->maxscales->open_readconn_slave_connection(0); - data->Test->add_result(mysql_errno( - conn3), - "Error opening ReadConn master conn, thread num is %d, iteration %li, error is: %s\n", - data->thread_id, - data->i, - mysql_error(conn3)); - // USE test here is a hack to prevent Maxscale from failure; should be removed when fixed - if (conn1 != NULL) - { - data->Test->try_query(conn1, (char*) "USE test"); - mysql_close(conn1); - } - - if (conn2 != NULL) - { - data->Test->try_query(conn2, (char*) "USE test"); - mysql_close(conn2); - } - if (conn3 != NULL) - { - data->Test->try_query(conn3, (char*) "USE test"); - mysql_close(conn3); - } - - data->i++; - } - - return NULL; + test.check_maxscale_alive(0); + return test.global_result; } From 15461c1f8e502392bcfaae80ee93e58c7de333ab Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 2 Aug 2019 09:41:19 +0300 Subject: [PATCH 2/5] MXS-2621: Add test case The test reproduces the problem with lower_case_table_names. --- maxscale-system-test/CMakeLists.txt | 11 ++++++++ ...ale.cnf.template.mxs2621_lower_case_tables | 26 +++++++++++++++++++ .../mxs2621_lower_case_tables.cpp | 15 +++++++++++ 3 files changed, 52 insertions(+) create mode 100644 maxscale-system-test/cnf/maxscale.cnf.template.mxs2621_lower_case_tables create mode 100644 maxscale-system-test/mxs2621_lower_case_tables.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index e07a028ef..0dabd0bbc 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -389,6 +389,10 @@ add_test_executable(csmon_test.cpp csmon_test csmon_test LABELS csmon CS_BACKEND # END: ColumnStore tests # ############################################ +############################################ +# BEGIN: Normal tests # +############################################ + # Test monitor state change events when manually clearing server bits add_test_executable(false_monitor_state_change.cpp false_monitor_state_change replication LABELS mysqlmon REPL_BACKEND) @@ -972,6 +976,13 @@ add_test_executable(mxs2521_double_exec.cpp mxs2521_double_exec mxs2521_double_e # MXS-2490: Direct execution doesn't work with MaxScale add_test_executable(mxs2490_ps_execute_direct.cpp mxs2490_ps_execute_direct replication LABELS REPL_BACKEND readwritesplit) +# MXS-2621: Incorrect SQL if lower_case_table_names is used. +add_test_executable(mxs2621_lower_case_tables.cpp mxs2621_lower_case_tables mxs2621_lower_case_tables LABELS REPL_BACKEND) + +############################################ +# END: Normal tests # +############################################ + ############################################ # BEGIN: binlogrouter and avrorouter tests # ############################################ diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2621_lower_case_tables b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2621_lower_case_tables new file mode 100644 index 000000000..4c27e3f7d --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2621_lower_case_tables @@ -0,0 +1,26 @@ +[maxscale] +threads=###threads### + +###server### + +[MySQL-Monitor] +type=monitor +module=mysqlmon +servers=###server_line### +user=maxskysql +password=skysql +monitor_interval=2000 + +[RW-Split-Router] +type=service +router=readwritesplit +servers=###server_line### +user=maxskysql +password=skysql + +[RW-Split-Listener] +type=listener +service=RW-Split-Router +protocol=MySQLClient +port=4006 +authenticator_options=lower_case_table_names=true diff --git a/maxscale-system-test/mxs2621_lower_case_tables.cpp b/maxscale-system-test/mxs2621_lower_case_tables.cpp new file mode 100644 index 000000000..62351237a --- /dev/null +++ b/maxscale-system-test/mxs2621_lower_case_tables.cpp @@ -0,0 +1,15 @@ +/** + * MXS-2621: Incorrect SQL if lower_case_table_names is used. + * https://jira.mariadb.org/browse/MXS-2621 + */ + +#include "testconnections.h" + +int main(int argc, char* argv[]) +{ + TestConnections test(argc, argv); + test.maxscales->connect(); + test.try_query(test.maxscales->conn_rwsplit[0], "SELECT 123"); + test.maxscales->disconnect(); + return test.global_result; +} From 110bc32b256eba2d6a28f853172ee81e5e60816c Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 2 Aug 2019 09:42:49 +0300 Subject: [PATCH 3/5] MXS-2621 Fix broken authorization SQL --- server/modules/authenticator/MySQLAuth/mysql_auth.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/modules/authenticator/MySQLAuth/mysql_auth.h b/server/modules/authenticator/MySQLAuth/mysql_auth.h index f278ce1a0..a4ad9bc7d 100644 --- a/server/modules/authenticator/MySQLAuth/mysql_auth.h +++ b/server/modules/authenticator/MySQLAuth/mysql_auth.h @@ -71,7 +71,7 @@ static const char mysqlauth_validate_user_query[] = static const char mysqlauth_validate_user_query_lower[] = "SELECT password FROM " MYSQLAUTH_USERS_TABLE_NAME " WHERE user = '%s' AND ( '%s' = host OR '%s' LIKE host)" - " AND (anydb = '1' OR LOWER('%s') IN ('', 'information_schema') OR LOWER('%s') LIKE LOWER(db)" + " AND (anydb = '1' OR LOWER('%s') IN ('', 'information_schema') OR LOWER('%s') LIKE LOWER(db))" " LIMIT 1"; /** Query that only checks if there's a matching user */ From 36355922281a6820de63b76fb76c9203861e3988 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 2 Aug 2019 09:50:01 +0300 Subject: [PATCH 4/5] Add 2.3.11 release notes and update 2.3 change log --- Documentation/Changelog.md | 1 + .../MaxScale-2.3.11-Release-Notes.md | 33 +++++++++++++++++++ 2 files changed, 34 insertions(+) create mode 100644 Documentation/Release-Notes/MaxScale-2.3.11-Release-Notes.md diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md index bf171504f..cbd1a6af2 100644 --- a/Documentation/Changelog.md +++ b/Documentation/Changelog.md @@ -31,6 +31,7 @@ For more details, please refer to: +* [MariaDB MaxScale 2.3.11 Release Notes](Release-Notes/MaxScale-2.3.11-Release-Notes.md) * [MariaDB MaxScale 2.3.10 Release Notes](Release-Notes/MaxScale-2.3.10-Release-Notes.md) * [MariaDB MaxScale 2.3.9 Release Notes](Release-Notes/MaxScale-2.3.9-Release-Notes.md) * [MariaDB MaxScale 2.3.8 Release Notes](Release-Notes/MaxScale-2.3.8-Release-Notes.md) diff --git a/Documentation/Release-Notes/MaxScale-2.3.11-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.3.11-Release-Notes.md new file mode 100644 index 000000000..e05f9a282 --- /dev/null +++ b/Documentation/Release-Notes/MaxScale-2.3.11-Release-Notes.md @@ -0,0 +1,33 @@ +# MariaDB MaxScale 2.3.11 Release Notes + +Release 2.3.11 is a GA release. + +This document describes the changes in release 2.3.11, when compared to the +previous release in the same series. + +For any problems you encounter, please consider submitting a bug +report on [our Jira](https://jira.mariadb.org/projects/MXS). + +## Bug fixes + +* [MXS-2621](https://jira.mariadb.org/browse/MXS-2621) Incorrect SQL if lower_case_table_names is used. + +## Known Issues and Limitations + +There are some limitations and known issues within this version of MaxScale. +For more information, please refer to the [Limitations](../About/Limitations.md) document. + +## Packaging + +RPM and Debian packages are provided for supported the Linux distributions. + +Packages can be downloaded [here](https://mariadb.com/downloads/#mariadb_platform-mariadb_maxscale). + +## Source Code + +The source code of MaxScale is tagged at GitHub with a tag, which is identical +with the version of MaxScale. For instance, the tag of version X.Y.Z of MaxScale +is `maxscale-X.Y.Z`. Further, the default branch is always the latest GA version +of MaxScale. + +The source code is available [here](https://github.com/mariadb-corporation/MaxScale). From 83db2a4dc1126f85b573d856fdbfab640bb35003 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Fri, 2 Aug 2019 09:54:17 +0300 Subject: [PATCH 5/5] Update 2.3 maintenance release number --- VERSION23.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION23.cmake b/VERSION23.cmake index 2f928171c..f6d1dc661 100644 --- a/VERSION23.cmake +++ b/VERSION23.cmake @@ -5,7 +5,7 @@ set(MAXSCALE_VERSION_MAJOR "2" CACHE STRING "Major version") set(MAXSCALE_VERSION_MINOR "3" CACHE STRING "Minor version") -set(MAXSCALE_VERSION_PATCH "11" CACHE STRING "Patch version") +set(MAXSCALE_VERSION_PATCH "12" CACHE STRING "Patch version") # This should only be incremented if a package is rebuilt set(MAXSCALE_BUILD_NUMBER 1 CACHE STRING "Release number")