From 8d91e8e2342517e530488000a0d98e23c78c8b6d Mon Sep 17 00:00:00 2001 From: Andrey Vasilyev Date: Tue, 2 Jul 2019 10:44:11 +0300 Subject: [PATCH 1/8] Install TCL from the source code only when the system version of the library is older than 8.6.5 --- BUILD/install_build_deps.sh | 42 ++++++++++++++++++++++++------------- 1 file changed, 27 insertions(+), 15 deletions(-) diff --git a/BUILD/install_build_deps.sh b/BUILD/install_build_deps.sh index a8777e603..698d914fc 100755 --- a/BUILD/install_build_deps.sh +++ b/BUILD/install_build_deps.sh @@ -52,7 +52,7 @@ else sudo zypper -n update sudo zypper -n install gcc gcc-c++ ncurses-devel bison glibc-devel libgcc_s1 perl \ make libtool libopenssl-devel libaio libaio-devel flex \ - pcre-devel git wget tcl libuuid-devel \ + pcre-devel git wget tcl tcl-devel libuuid-devel \ xz-devel sqlite3 sqlite3-devel pkg-config lua lua-devel \ gnutls-devel libgcrypt-devel pam-devel sudo zypper -n install rpm-build @@ -69,7 +69,7 @@ else sudo yum install -y --nogpgcheck gcc gcc-c++ ncurses-devel bison glibc-devel \ libgcc perl make libtool openssl-devel libaio libaio-devel libedit-devel \ libedit-devel systemtap-sdt-devel rpm-sign wget \ - gnupg pcre-devel flex rpmdevtools git wget tcl openssl libuuid-devel xz-devel \ + gnupg pcre-devel flex rpmdevtools git wget tcl tcl-devel openssl libuuid-devel xz-devel \ sqlite sqlite-devel pkgconfig lua lua-devel rpm-build createrepo yum-utils \ gnutls-devel libgcrypt-devel pam-devel @@ -124,23 +124,35 @@ sudo make install cd ../../ # TCL -mkdir tcl -cd tcl -wget -q --no-check-certificate http://prdownloads.sourceforge.net/tcl/tcl8.6.5-src.tar.gz +# Methods allow to compare software versions according to semantic versioning +verlte() { + [ "$1" = "`echo -e "$1\n$2" | sort -V | head -n1`" ] +} -if [ $? != 0 ] +verlt() { + [ "$1" = "$2" ] && return 1 || verlte $1 $2 +} + +system_tcl_version=$(tclsh <<< 'puts [info patchlevel]') +if verlt "$system_tcl_version" "8.6.5" then - echo "Error getting tcl" - exit 1 + mkdir tcl + cd tcl + wget -q --no-check-certificate http://prdownloads.sourceforge.net/tcl/tcl8.6.5-src.tar.gz + + if [ $? != 0 ] + then + echo "Error getting tcl" + exit 1 + fi + + tar xzf tcl8.6.5-src.tar.gz + cd tcl8.6.5/unix + ./configure + sudo make install + cd ../../.. fi -tar xzf tcl8.6.5-src.tar.gz -cd tcl8.6.5/unix -./configure -sudo make install -cd ../../.. - - # Jansson git clone https://github.com/akheron/jansson.git if [ $? != 0 ] From 66d6ce6fa598a43b20af052ef6c9f637a3279fa1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Wed, 3 Jul 2019 09:00:31 +0300 Subject: [PATCH 2/8] Create /var/lib/maxscale via systemd Systemd provides the facilities to run commands before startup which can be used to prevent the problem that fixing MXS-2578 caused: upon upgrading from 2.3.8 to 2.3.9 the /var/lib/maxscale directory would be removed if it was empty. --- etc/maxscale.service.in | 1 + 1 file changed, 1 insertion(+) diff --git a/etc/maxscale.service.in b/etc/maxscale.service.in index ddccbcf85..fd46da89d 100644 --- a/etc/maxscale.service.in +++ b/etc/maxscale.service.in @@ -10,6 +10,7 @@ Restart=on-abort # Make sure /var/run/maxscale exists PermissionsStartOnly=true ExecStartPre=/usr/bin/install -d @MAXSCALE_VARDIR@/run/maxscale -o maxscale -g maxscale +ExecStartPre=/usr/bin/install -d @MAXSCALE_VARDIR@/lib/maxscale -o maxscale -g maxscale PIDFile=@MAXSCALE_VARDIR@/run/maxscale/maxscale.pid From 990208d0fdcef3496126af68b2e9143addf3604f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Jun 2019 08:04:36 +0300 Subject: [PATCH 3/8] Enable log_info for stale_slaves This would help explain any odd test failures. --- maxscale-system-test/cnf/maxscale.cnf.template.stale_slaves | 1 + 1 file changed, 1 insertion(+) diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.stale_slaves b/maxscale-system-test/cnf/maxscale.cnf.template.stale_slaves index 42fe0c742..3c5302162 100644 --- a/maxscale-system-test/cnf/maxscale.cnf.template.stale_slaves +++ b/maxscale-system-test/cnf/maxscale.cnf.template.stale_slaves @@ -1,5 +1,6 @@ [maxscale] threads=###threads### +log_info=1 [MySQL-Monitor] type=monitor From 02395102ed4590140828438fea4241ce83a0dc76 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Jun 2019 08:25:00 +0300 Subject: [PATCH 4/8] Add log message injection to tests By injecting messages into the maxscale.log from the test, the reader of the log can easily see the "synchronization" with the test case. This does affect the test timing so it can only be used to see whether non-timing related functionality is correct. --- maxscale-system-test/testconnections.cpp | 16 ++++++++++++++++ maxscale-system-test/testconnections.h | 5 +++++ 2 files changed, 21 insertions(+) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 70380ae4f..18f71be0b 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -1885,6 +1885,22 @@ void TestConnections::tprintf(const char* format, ...) fflush(stderr); } +void TestConnections::log_printf(const char* format, ...) +{ + va_list argp; + va_start(argp, format); + int n = vsnprintf(nullptr, 0, format, argp); + va_end(argp); + + va_start(argp, format); + char buf[n + 1]; + vsnprintf(buf, sizeof(buf), format, argp); + va_end(argp); + + maxscales->ssh_node_f(0, true, "echo '--- %s ---' >> /var/log/maxscale/maxscale.log", buf); + tprintf("%s", buf); +} + int TestConnections::get_master_server_id(int m) { int master_id = -1; diff --git a/maxscale-system-test/testconnections.h b/maxscale-system-test/testconnections.h index 4157ef86f..694bb474c 100644 --- a/maxscale-system-test/testconnections.h +++ b/maxscale-system-test/testconnections.h @@ -505,6 +505,11 @@ public: */ void tprintf(const char* format, ...); + /** + * @brief injects a message into maxscale.log + */ + void log_printf(const char* format, ...) mxb_attribute((format(printf, 2, 3))); + /** * @brief Creats t1 table, insert data into it and checks if data can be correctly read from all Maxscale * services From 760f887566b16ba2e15af384bf8d937f6e6c470e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20M=C3=A4kel=C3=A4?= Date: Fri, 28 Jun 2019 08:48:03 +0300 Subject: [PATCH 5/8] Skip unnecessary reconfiguration The coredump configuration needs to be done only if nodes were restored or if MaxScale was reinstalled. --- maxscale-system-test/testconnections.cpp | 24 +++++++++++++++++------- 1 file changed, 17 insertions(+), 7 deletions(-) diff --git a/maxscale-system-test/testconnections.cpp b/maxscale-system-test/testconnections.cpp index 18f71be0b..139fa8a55 100644 --- a/maxscale-system-test/testconnections.cpp +++ b/maxscale-system-test/testconnections.cpp @@ -415,9 +415,11 @@ TestConnections::TestConnections(int argc, char* argv[]) bool repl_ok = no_repl || repl_future.get(); bool galera_ok = no_galera || galera_future.get(); bool node_error = !maxscale_ok || !repl_ok || !galera_ok; + bool initialize = false; if (node_error || too_many_maxscales()) { + initialize = true; tprintf("Recreating VMs: %s", node_error ? "node check failed" : "too many maxscales"); if (call_mdbci("--recreate")) @@ -426,16 +428,24 @@ TestConnections::TestConnections(int argc, char* argv[]) } } - if (reinstall_maxscale && reinstall_maxscales()) + if (reinstall_maxscale) { - tprintf("Failed to install Maxscale: target is %s", target); - exit(MDBCI_FAUILT); + initialize = true; + + if (reinstall_maxscales()) + { + tprintf("Failed to install Maxscale: target is %s", target); + exit(MDBCI_FAUILT); + } } - std::string src = std::string(test_dir) + "/mdbci/add_core_cnf.sh"; - maxscales->copy_to_node(0, src.c_str(), maxscales->access_homedir[0]); - maxscales->ssh_node_f(0, true, "%s/add_core_cnf.sh %s", maxscales->access_homedir[0], - verbose ? "verbose" : ""); + if (initialize) + { + std::string src = std::string(test_dir) + "/mdbci/add_core_cnf.sh"; + maxscales->copy_to_node(0, src.c_str(), maxscales->access_homedir[0]); + maxscales->ssh_node_f(0, true, "%s/add_core_cnf.sh %s", maxscales->access_homedir[0], + verbose ? "verbose" : ""); + } maxscales->use_ipv6 = use_ipv6; From 1d4d05be6f4872de7d8ef463ae869f30006ae056 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 2 Jul 2019 10:38:25 +0300 Subject: [PATCH 6/8] Add missing documentation link --- Documentation/Documentation-Contents.md | 1 + 1 file changed, 1 insertion(+) diff --git a/Documentation/Documentation-Contents.md b/Documentation/Documentation-Contents.md index e0f9cdf9b..8434430a9 100644 --- a/Documentation/Documentation-Contents.md +++ b/Documentation/Documentation-Contents.md @@ -15,6 +15,7 @@ ## Upgrading MariaDB MaxScale +- [Upgrading MariaDB MaxScale from 2.3 to 2.4](Upgrading/Upgrading-To-MaxScale-2.4.md) - [Upgrading MariaDB MaxScale from 2.2 to 2.3](Upgrading/Upgrading-To-MaxScale-2.3.md) - [Upgrading MariaDB MaxScale from 2.1 to 2.2](Upgrading/Upgrading-To-MaxScale-2.2.md) - [Upgrading MariaDB MaxScale from 2.0 to 2.1](Upgrading/Upgrading-To-MaxScale-2.1.md) From 26a4f0d859286ebfb431f2413dfe3c39e1aa589e Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 2 Jul 2019 12:23:18 +0300 Subject: [PATCH 7/8] MXS-2446 Provide access to used urls Makes it possible to later verify that results are for the urls one expects them to be. --- maxutils/maxbase/include/maxbase/http.hh | 12 ++++++++++++ maxutils/maxbase/src/http.cc | 18 ++++++++++++++++-- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/maxutils/maxbase/include/maxbase/http.hh b/maxutils/maxbase/include/maxbase/http.hh index fcf5a2e03..d38297cad 100644 --- a/maxutils/maxbase/include/maxbase/http.hh +++ b/maxutils/maxbase/include/maxbase/http.hh @@ -172,6 +172,8 @@ public: virtual long wait_no_more_than() const = 0; virtual const std::vector& results() const = 0; + + virtual const std::vector& urls() const = 0; }; /** @@ -258,6 +260,16 @@ public: return m_sImp->results(); } + /** + * The URLs the async operation was invoked with. + * + * @return Vector of urls. + */ + const std::vector& urls() const + { + return m_sImp->urls(); + } + public: Async(const std::shared_ptr& sImp) : m_sImp(sImp) diff --git a/maxutils/maxbase/src/http.cc b/maxutils/maxbase/src/http.cc index f6672eb42..c3853f296 100644 --- a/maxutils/maxbase/src/http.cc +++ b/maxutils/maxbase/src/http.cc @@ -197,14 +197,20 @@ public: return 0; } - const std::vector& results() const + const vector& results() const { return m_results; } + const vector& urls() const + { + return m_urls; + } + private: Async::status_t m_status; vector m_results; + vector m_urls; }; class HttpImp : public Async::Imp @@ -248,6 +254,8 @@ public: { mxb_assert(m_status == Async::ERROR); + m_urls = urls; + m_results.reserve(urls.size()); m_errbufs.reserve(urls.size()); @@ -417,11 +425,16 @@ public: return m_wait_no_more_than; } - const std::vector& results() const + const vector& results() const { return m_results; } + const vector& urls() const + { + return m_urls; + } + private: void update_timeout() { @@ -441,6 +454,7 @@ private: unordered_map m_curls; int m_still_running; long m_wait_no_more_than; + vector m_urls; }; } From baf9e4078a0eb207874935753c648c634b277e4b Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 3 Jul 2019 12:12:31 +0300 Subject: [PATCH 8/8] MXS-2446 Ensure that the URLs reflects m_nodes_by_id If code that may remove items from m_nodes_by_id (Clustrix nodes keyed by id) succeeds, we must update the vector of health check URLs also in the case that code that _may_ add items to m_nodes_by_id fails. --- .../modules/monitor/clustrixmon/clustrixmonitor.cc | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/server/modules/monitor/clustrixmon/clustrixmonitor.cc b/server/modules/monitor/clustrixmon/clustrixmonitor.cc index b5e1c1e45..0c3737c05 100644 --- a/server/modules/monitor/clustrixmon/clustrixmonitor.cc +++ b/server/modules/monitor/clustrixmon/clustrixmonitor.cc @@ -408,11 +408,7 @@ void ClustrixMonitor::tick() case http::Async::READY: update_server_statuses(); - - if (!m_health_urls.empty()) - { - make_health_check(); - } + make_health_check(); break; } @@ -743,7 +739,6 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) node.set_running(false, ClustrixNode::APPROACH_OVERRIDE); } - update_http_urls(); cluster_checked(); } else @@ -757,6 +752,11 @@ bool ClustrixMonitor::refresh_nodes(MYSQL* pHub_con) MXS_ERROR("%s: Could not execute '%s' on %s: %s", name(), ZQUERY, mysql_get_host_info(pHub_con), mysql_error(pHub_con)); } + + // Since we are here, the call above to check_cluster_membership() succeeded. As that + // function may change the content of m_nodes_by_ids, we must always update the urls, + // irrespective of whether the SQL of this function succeeds or not. + update_http_urls(); } return refreshed; @@ -1112,6 +1112,7 @@ bool ClustrixMonitor::check_http(Call::action_t action) case http::Async::READY: { + mxb_assert(m_health_urls == m_http.urls()); // There are as many results as there are nodes, // and the results are in node order. const vector& results = m_http.results();