From f5110209f7abc2c4508fb55bc74d342eb868a718 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 5 Jul 2018 10:57:09 +0300 Subject: [PATCH 1/5] MXS-1942: Use MaxScale version in MaxCtrl Displaying the MaxScale version helps identify which package the executable was bundled with. As the MaxCtrl source is a part of MaxScale, there's no need for separate versioning. --- maxctrl/CMakeLists.txt | 3 +++ maxctrl/lib/core.js | 4 +++- maxctrl/lib/version.js.in | 14 ++++++++++++++ 3 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 maxctrl/lib/version.js.in diff --git a/maxctrl/CMakeLists.txt b/maxctrl/CMakeLists.txt index 3105cb14e..67fe828e0 100644 --- a/maxctrl/CMakeLists.txt +++ b/maxctrl/CMakeLists.txt @@ -3,6 +3,9 @@ if (BUILD_MAXCTRL) find_package(NodeJS) if (NPM_FOUND AND NODEJS_FOUND AND NODEJS_VERSION VERSION_GREATER "6.0.0") + + configure_file(${CMAKE_CURRENT_SOURCE_DIR}/lib/version.js.in ${CMAKE_CURRENT_BINARY_DIR}/lib/version.js @ONLY) + add_custom_command(OUTPUT ${CMAKE_BINARY_DIR}/maxctrl/maxctrl COMMAND ${CMAKE_CURRENT_SOURCE_DIR}/build.sh ${CMAKE_SOURCE_DIR} WORKING_DIRECTORY ${CMAKE_BINARY_DIR}) diff --git a/maxctrl/lib/core.js b/maxctrl/lib/core.js index 9c0a5a472..8cae23a53 100644 --- a/maxctrl/lib/core.js +++ b/maxctrl/lib/core.js @@ -14,7 +14,9 @@ var fs = require('fs') var program = require('yargs'); -const maxctrl_version = '1.0.0'; +// Note: The version.js file is generated at configuation time. If you are +// building in-source, manually create the file +const maxctrl_version = require('./version.js').version; program .version(maxctrl_version) diff --git a/maxctrl/lib/version.js.in b/maxctrl/lib/version.js.in new file mode 100644 index 000000000..33a73eab9 --- /dev/null +++ b/maxctrl/lib/version.js.in @@ -0,0 +1,14 @@ +/* + * Copyright (c) 2016 MariaDB Corporation Ab + * + * Use of this software is governed by the Business Source License included + * in the LICENSE.TXT file and at www.mariadb.com/bsl11. + * + * Change Date: 2020-01-01 + * + * On the date above, in accordance with the Business Source License, use + * of this software will be governed by version 2 or later of the General + * Public License. + */ + +exports.version = "@MAXSCALE_VERSION@" From 33fa9b26fe080e0be1e4367784ba3382b6308c7f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 5 Jul 2018 11:46:23 +0300 Subject: [PATCH 2/5] Make version counter in mlist_t volatile The log manager is the only one that uses the mlist_t versioned list. The counter that keeps track of the version number was not modified using atomic operations meaning that the compiler is free to optimize away parts of the lock-free versioning mechanism that uses it. To prevent this optimization, the variable is declared volatile. A rewrite is direly needed but it cannot be done in 2.2. --- server/core/internal/mlist.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/server/core/internal/mlist.h b/server/core/internal/mlist.h index 949d8aacc..48cfafec5 100644 --- a/server/core/internal/mlist.h +++ b/server/core/internal/mlist.h @@ -32,7 +32,7 @@ typedef struct mlist_st bool mlist_deleted; size_t mlist_nodecount; size_t mlist_nodecount_max; /**< size limit. 0 == no limit */ - size_t mlist_versno; + volatile size_t mlist_versno; bool mlist_flat; mlist_node_t* mlist_first; mlist_node_t* mlist_last; From f44d305a468bf8266d9673f52831b74c2b0212c4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 5 Jul 2018 12:49:46 +0300 Subject: [PATCH 3/5] MXS-1949: Fix user injection warning If a service has no active servers and users are injected, a warning would be logged. This is a misleading warning if the service has no servers and should only be logged if the failure to load any users is an unexpected situation. --- .../authenticator/MySQLAuth/mysql_auth.c | 22 ++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/server/modules/authenticator/MySQLAuth/mysql_auth.c b/server/modules/authenticator/MySQLAuth/mysql_auth.c index 162ab5872..cb4696a46 100644 --- a/server/modules/authenticator/MySQLAuth/mysql_auth.c +++ b/server/modules/authenticator/MySQLAuth/mysql_auth.c @@ -567,6 +567,19 @@ static bool add_service_user(SERV_LISTENER *port) return rval; } +static bool service_has_servers(SERVICE* service) +{ + for (SERVER_REF* s = service->dbref; s; s = s->next) + { + if (s->active) + { + return true; + } + } + + return false; +} + /** * @brief Load MySQL authentication users * @@ -623,9 +636,12 @@ static int mysql_auth_load_users(SERV_LISTENER *port) if (injected) { - MXS_NOTICE("[%s] No users were loaded but 'inject_service_user' is enabled. " - "Enabling service credentials for authentication until " - "database users have been successfully loaded.", service->name); + if (service_has_servers(service)) + { + MXS_NOTICE("[%s] No users were loaded but 'inject_service_user' is enabled. " + "Enabling service credentials for authentication until " + "database users have been successfully loaded.", service->name); + } } else if (loaded == 0 && !first_load) { From 5c610503ba325f6ce3ab13e707f7da2ff4966348 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 5 Jul 2018 13:47:08 +0300 Subject: [PATCH 4/5] MXS-1949: Add test case Added a test case that verifies the bug is fixed. --- maxscale-system-test/CMakeLists.txt | 4 ++++ .../mxs1949_warn_user_injection.cpp | 15 +++++++++++++++ 2 files changed, 19 insertions(+) create mode 100644 maxscale-system-test/mxs1949_warn_user_injection.cpp diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 92e737493..f2fc91d36 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -946,6 +946,10 @@ add_test_executable(mxs1926_killed_server.cpp mxs1926_killed_server mxs1926_kill # https://jira.mariadb.org/browse/MXS-1932 add_test_executable(mxs1932_hidden_cnf.cpp mxs1932_hidden_cnf replication LABELS REPL_BACKEND) +# MXS-1949: Warning for user load failure logged even when service has no users +# https://jira.mariadb.org/browse/MXS-1949 +add_test_executable(mxs1949_warn_user_injection.cpp mxs1949_warn_user_injection avro LABELS REPL_BACKEND) + # MXS-1958: Users with insert-only privileges don't work # https://jira.mariadb.org/browse/MXS-1958 add_test_executable(mxs1958_insert_priv.cpp mxs1958_insert_priv replication LABELS REPL_BACKEND) diff --git a/maxscale-system-test/mxs1949_warn_user_injection.cpp b/maxscale-system-test/mxs1949_warn_user_injection.cpp new file mode 100644 index 000000000..9be520f1f --- /dev/null +++ b/maxscale-system-test/mxs1949_warn_user_injection.cpp @@ -0,0 +1,15 @@ +/** + * MXS-1949: Warning for user load failure logged even when service has no users + * + * Check that the message is not logged when services have no servers and + * 'inject_service_user' is enabled. + */ + +#include "testconnections.h" + +int main(int argc, char *argv[]) +{ + TestConnections test(argc, argv); + test.check_log_err(0, " No users were loaded but 'inject_service_user' is enabled", false); + return test.global_result; +} From cb05199bac88673670cad7697ad0e26e09e9998d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Thu, 5 Jul 2018 21:03:57 +0300 Subject: [PATCH 5/5] Stop MaxScale before fixing replication Before the state of the backend servers is checked, MaxScale needs to be stopped to prevent the automated failover from interfering in the start-up process. --- maxscale-system-test/testconnections.cpp | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 7515b8232..194a804da 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -238,6 +238,15 @@ TestConnections::TestConnections(int argc, char *argv[]): maxscales->use_ipv6 = use_ipv6; maxscales->ssl = ssl; + // Stop MaxScale to prevent it from interfering with the replication setup process + if (!maxscale::manual_debug) + { + for (int i = 0; i < maxscales->N; i++) + { + maxscales->stop(i); + } + } + if (maxscale::required_repl_version.length()) { int ver_repl_required = get_int_version(maxscale::required_repl_version); @@ -643,11 +652,6 @@ void TestConnections::init_maxscale(int m) { const char * template_name = get_template_name(test_name); - if (!maxscale::manual_debug) - { - stop_maxscale(m); - } - process_template(m, template_name, maxscales->access_homedir[m]); maxscales->ssh_node_f(m, true, "cp maxscale.cnf %s;rm -rf %s/certs;mkdir -m a+wrx %s/certs;",