From 627c1945bc722353773c382b5005684050bd8b6d Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Wed, 4 Apr 2018 13:45:18 +0300 Subject: [PATCH 1/7] Update version number in 2.1 --- VERSION21.cmake | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/VERSION21.cmake b/VERSION21.cmake index 32d2ff0f4..0df03b735 100644 --- a/VERSION21.cmake +++ b/VERSION21.cmake @@ -5,7 +5,7 @@ set(MAXSCALE_VERSION_MAJOR "2" CACHE STRING "Major version") set(MAXSCALE_VERSION_MINOR "1" CACHE STRING "Minor version") -set(MAXSCALE_VERSION_PATCH "16" CACHE STRING "Patch version") +set(MAXSCALE_VERSION_PATCH "17" CACHE STRING "Patch version") # This should only be incremented if a package is rebuilt set(MAXSCALE_BUILD_NUMBER 1 CACHE STRING "Release number") From 65260c365d4b93dede82dc86f7ac7971e85131c7 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 24 Apr 2018 10:02:47 +0300 Subject: [PATCH 2/7] MXS-1819 Also log info messages to syslog If info messages are enabled, they will be logged to syslog just like any other messages. --- Documentation/Getting-Started/Configuration-Guide.md | 5 +++-- server/core/log_manager.cc | 3 ++- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/Documentation/Getting-Started/Configuration-Guide.md b/Documentation/Getting-Started/Configuration-Guide.md index 127444a3b..3d81f5130 100644 --- a/Documentation/Getting-Started/Configuration-Guide.md +++ b/Documentation/Getting-Started/Configuration-Guide.md @@ -261,9 +261,10 @@ not regularly. Since *MariaDB MaxScale* can log to both file and *syslog* an approach that provides maximum flexibility is to enable *syslog* and *log_to_shm*, and to disable *maxlog*. That way messages will normally be logged to *syslog*, but if -there is something to investigate, *log_info* and *maxlog* can be enabled from +there is something to investigate, *log_debug* and *maxlog* can be enabled from *maxadmin*, in which case informational messages will be logged to the -*maxscale.log* file that resides in shared memory. +*maxscale.log* file that resides in shared memory. But note that *log_debug* +messages will only be available if MaxScale has been built in debug mode. By default, logging to shared memory is disabled. diff --git a/server/core/log_manager.cc b/server/core/log_manager.cc index f9781d171..5711dda8c 100644 --- a/server/core/log_manager.cc +++ b/server/core/log_manager.cc @@ -895,11 +895,12 @@ static int logmanager_write_log(int priority, case LOG_ERR: case LOG_WARNING: case LOG_NOTICE: + case LOG_INFO: syslog(priority, "%s", message); break; default: - // LOG_INFO and LOG_DEBUG messages are never written to syslog. + // LOG_DEBUG messages are never written to syslog. break; } } From 7a81f77649c151d82da814e388c1b52374015aef Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 24 Apr 2018 10:12:29 +0300 Subject: [PATCH 3/7] Add release notes for 2.1.17 Update Changelog as well. --- Documentation/Changelog.md | 1 + .../MaxScale-2.1.17-Release-Notes.md | 38 +++++++++++++++++++ 2 files changed, 39 insertions(+) create mode 100644 Documentation/Release-Notes/MaxScale-2.1.17-Release-Notes.md diff --git a/Documentation/Changelog.md b/Documentation/Changelog.md index 99d1c7e74..feaf07879 100644 --- a/Documentation/Changelog.md +++ b/Documentation/Changelog.md @@ -21,6 +21,7 @@ * MaxScale now supports IPv6 For more details, please refer to: +* [MariaDB MaxScale 2.1.17 Release Notes](Release-Notes/MaxScale-2.1.17-Release-Notes.md) * [MariaDB MaxScale 2.1.16 Release Notes](Release-Notes/MaxScale-2.1.16-Release-Notes.md) * [MariaDB MaxScale 2.1.15 Release Notes](Release-Notes/MaxScale-2.1.15-Release-Notes.md) * [MariaDB MaxScale 2.1.14 Release Notes](Release-Notes/MaxScale-2.1.14-Release-Notes.md) diff --git a/Documentation/Release-Notes/MaxScale-2.1.17-Release-Notes.md b/Documentation/Release-Notes/MaxScale-2.1.17-Release-Notes.md new file mode 100644 index 000000000..87ae9ae51 --- /dev/null +++ b/Documentation/Release-Notes/MaxScale-2.1.17-Release-Notes.md @@ -0,0 +1,38 @@ +# MariaDB MaxScale 2.1.17 Release Notes + +Release 2.1.17 is a GA release. + +This document describes the changes in release 2.1.17, when compared +to release [2.1.16](MaxScale-2.1.15-Release-Notes.md). + +For any problems you encounter, please consider submitting a bug report at +[Jira](https://jira.mariadb.org). + +## Changed Features + +* Info level messages will now also be logged to syslog, if logging to + syslog is enabled. + +## Bug fixes + +[Here is a list of bugs fixed in MaxScale 2.1.17.](https://jira.mariadb.org/issues/?jql=project%20%3D%20MXS%20AND%20issuetype%20%3D%20Bug%20AND%20status%20%3D%20Closed%20AND%20fixVersion%20%3D%202.1.17) + +* [MXS-1819](https://jira.mariadb.org/browse/MXS-1819) log_info does not log to syslog +* [MXS-1788](https://jira.mariadb.org/browse/MXS-1788) MaxInfo crash +* [MXS-1767](https://jira.mariadb.org/browse/MXS-1767) Server capabilities are not correct +* [MXS-1762](https://jira.mariadb.org/browse/MXS-1762) The client IP should be considered when choosing a persistent connection + +## Packaging + +RPM and Debian packages are provided for the Linux distributions supported by +MariaDB Enterprise. + +Packages can be downloaded [here](https://mariadb.com/resources/downloads). + +## 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. + +The source code is available [here](https://github.com/mariadb-corporation/MaxScale). From bafe8f5eeb83f46cf833ff2b6ab6fb3277f1a438 Mon Sep 17 00:00:00 2001 From: Johan Wikman Date: Tue, 24 Apr 2018 12:31:08 +0300 Subject: [PATCH 4/7] MXS-1618 Use right type for the return value of getopt_long getopt_long returns an 'int'. If 'char' is used on a big-endian platform you'll end up with an infinite loop. --- client/maxadmin.c | 2 +- server/modules/routing/binlogrouter/maxbinlogcheck.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/client/maxadmin.c b/client/maxadmin.c index d7e4856cd..305ae3700 100644 --- a/client/maxadmin.c +++ b/client/maxadmin.c @@ -142,7 +142,7 @@ main(int argc, char **argv) bool use_unix_socket = false; int option_index = 0; - char c; + int c; while ((c = getopt_long(argc, argv, "h:p::P:u:S:v?ei", long_options, &option_index)) >= 0) { diff --git a/server/modules/routing/binlogrouter/maxbinlogcheck.c b/server/modules/routing/binlogrouter/maxbinlogcheck.c index 820b9aa3d..1585a4789 100644 --- a/server/modules/routing/binlogrouter/maxbinlogcheck.c +++ b/server/modules/routing/binlogrouter/maxbinlogcheck.c @@ -86,7 +86,7 @@ int main(int argc, char **argv) char *key_file = NULL; char *aes_algo = NULL; int report_header = 0; - char c; + int c; while ((c = getopt_long(argc, argv, "dVfMHK:A:?", long_options, &option_index)) >= 0) { From 2aeed3ffabf59d121991d50bfd74e626872b5210 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Mon, 23 Apr 2018 14:51:33 +0300 Subject: [PATCH 5/7] MXS-1639 Add documentation on promotion/demotion sql files --- Documentation/Monitors/MariaDB-Monitor.md | 33 +++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/Documentation/Monitors/MariaDB-Monitor.md b/Documentation/Monitors/MariaDB-Monitor.md index 68dffc808..fb0358b4d 100644 --- a/Documentation/Monitors/MariaDB-Monitor.md +++ b/Documentation/Monitors/MariaDB-Monitor.md @@ -287,6 +287,10 @@ With `auto_rejoin` active, the monitor will try to rejoin any server matching the above requirements. When activating rejoin manually, the user-designated server must fulfill the same requirements. +The user can define files with SQL statements which are executed on any server +being demoted or promoted by cluster manipulation commands. See the sections on +`promotion_sql_file` and `demotion_sql_file` for more information. + ### Limitations and requirements Switchover and failover only understand simple topologies. They will not work if @@ -440,6 +444,35 @@ replication to break. servers_no_promotion=backup_dc_server1,backup_dc_server2 ``` +#### `promotion_sql_file` and `demotion_sql_file` + +These are paths to text files with SQL statements in them. During promotion or +demotion, the contents are read line-by-line and executed on the backend. Empty +lines or lines starting with '#' are ignored. All statements must succeed and +none may return results, otherwise the switchover or failover fails. + +When promoting a slave to master during switchover or failover, the +`promotion_sql_file` is read and executed on the new master server after its +read-only flag is disabled. The commands are ran *before* starting replication +from an external master if any. + +`demotion_sql_file` is ran on an old master during demotion to slave, before the +old master starts replicating from the new master. The file is also ran before +rejoining a standalone server to the cluster, as the standalone server is +typically a former master server. + +Since the queries in the files are ran during operations which modify +replication topology, care is required. If `promotion_sql_file` contains data +modification (DML) queries, the new master server may not be able to +successfully replicate from an external master. `demotion_sql_file` should never +contain DML queries, as these may not replicate to the slave servers before +slave threads are stopped, breaking replication. + +``` +promotion_sql_file=/home/root/scripts/promotion.sql +demotion_sql_file=/home/root/scripts/demotion.sql +``` + ### Manual switchover and failover Both failover and switchover can be activated manually through the REST API or From fa7cd9450affa07f0b62de12301f257022e7f3ec Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Mon, 23 Apr 2018 16:05:47 +0300 Subject: [PATCH 6/7] MXS-1639 Do not run demote_sql_file if the server already has a slave connection In this case, the server was already a slave and is not being demoted. Also, the file may contain queries which cannot be ran while a slave connection is running. --- Documentation/Monitors/MariaDB-Monitor.md | 3 +- .../modules/monitor/mariadbmon/mariadbmon.cc | 39 ++++++++++--------- 2 files changed, 22 insertions(+), 20 deletions(-) diff --git a/Documentation/Monitors/MariaDB-Monitor.md b/Documentation/Monitors/MariaDB-Monitor.md index fb0358b4d..0ceff9a34 100644 --- a/Documentation/Monitors/MariaDB-Monitor.md +++ b/Documentation/Monitors/MariaDB-Monitor.md @@ -459,7 +459,8 @@ from an external master if any. `demotion_sql_file` is ran on an old master during demotion to slave, before the old master starts replicating from the new master. The file is also ran before rejoining a standalone server to the cluster, as the standalone server is -typically a former master server. +typically a former master server. When redirecting a slave replicating from a +wrong master, the sql-file is not executed. Since the queries in the files are ran during operations which modify replication topology, care is required. If `promotion_sql_file` contains data diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index 72d59a875..464fd3ef9 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -4793,30 +4793,30 @@ static uint32_t do_rejoin(MYSQL_MONITOR* mon, const ServerVector& joinable_serve const char* master_name = master->unique_name; MySqlServerInfo* redir_info = get_server_info(mon, joinable); - if (*mon->demote_sql_file && !run_sql_from_file(joinable, mon->demote_sql_file, output)) + bool op_success = false; + if (redir_info->n_slaves_configured == 0) { - PRINT_MXS_JSON_ERROR(output, "%s execution failed when attempting to rejoin server '%s'.", - CN_DEMOTION_SQL_FILE, joinable->server->unique_name); - } - else - { - bool op_success; - if (redir_info->n_slaves_configured == 0) + if (*mon->demote_sql_file && !run_sql_from_file(joinable, mon->demote_sql_file, output)) + { + PRINT_MXS_JSON_ERROR(output, "%s execution failed when attempting to rejoin server '%s'.", + CN_DEMOTION_SQL_FILE, joinable->server->unique_name); + } + else { MXS_NOTICE("Directing standalone server '%s' to replicate from '%s'.", name, master_name); op_success = join_cluster(joinable, change_cmd.c_str()); } - else - { - MXS_NOTICE("Server '%s' is replicating from a server other than '%s', " - "redirecting it to '%s'.", name, master_name, master_name); - op_success = redirect_one_slave(joinable, change_cmd.c_str()); - } + } + else + { + MXS_NOTICE("Server '%s' is replicating from a server other than '%s', " + "redirecting it to '%s'.", name, master_name, master_name); + op_success = redirect_one_slave(joinable, change_cmd.c_str()); + } - if (op_success) - { - servers_joined++; - } + if (op_success) + { + servers_joined++; } } } @@ -4933,7 +4933,8 @@ static bool run_sql_from_file(MXS_MONITORED_SERVER* server, const string& path, std::ifstream sql_file(path); if (sql_file.is_open()) { - MXS_NOTICE("Executing sql queries from file '%s'.", path.c_str()); + MXS_NOTICE("Executing sql queries from file '%s' on server '%s'.", path.c_str(), + server->server->unique_name); int lines_executed = 0; while (!sql_file.eof() && !error) From 2a38902aa640efa40f06c33b49bf8cdfca1f8f78 Mon Sep 17 00:00:00 2001 From: Esa Korhonen Date: Tue, 24 Apr 2018 10:59:00 +0300 Subject: [PATCH 7/7] MXS-1639 Discard results when executing sql text files This removes the limitation of not returning resultsets. --- Documentation/Monitors/MariaDB-Monitor.md | 13 +++++++++---- server/modules/monitor/mariadbmon/mariadbmon.cc | 9 ++++++++- 2 files changed, 17 insertions(+), 5 deletions(-) diff --git a/Documentation/Monitors/MariaDB-Monitor.md b/Documentation/Monitors/MariaDB-Monitor.md index 0ceff9a34..5528c3408 100644 --- a/Documentation/Monitors/MariaDB-Monitor.md +++ b/Documentation/Monitors/MariaDB-Monitor.md @@ -446,10 +446,15 @@ servers_no_promotion=backup_dc_server1,backup_dc_server2 #### `promotion_sql_file` and `demotion_sql_file` -These are paths to text files with SQL statements in them. During promotion or -demotion, the contents are read line-by-line and executed on the backend. Empty -lines or lines starting with '#' are ignored. All statements must succeed and -none may return results, otherwise the switchover or failover fails. +These optional settings are paths to text files with SQL statements in them. +During promotion or demotion, the contents are read line-by-line and executed on +the backend. Use these settings to execute custom statements on the servers to +complement the built-in operations. + +Empty lines or lines starting with '#' are ignored. Any results returned by the +statements are ignored. All statements must succeed for the failover, switchover +or rejoin to continue. The monitor user may require additional privileges and +grants for the custom commands to succeed. When promoting a slave to master during switchover or failover, the `promotion_sql_file` is read and executed on the new master server after its diff --git a/server/modules/monitor/mariadbmon/mariadbmon.cc b/server/modules/monitor/mariadbmon/mariadbmon.cc index 464fd3ef9..33e89ac77 100644 --- a/server/modules/monitor/mariadbmon/mariadbmon.cc +++ b/server/modules/monitor/mariadbmon/mariadbmon.cc @@ -4919,7 +4919,8 @@ static int64_t scan_server_id(const char* id_string) } /** - * Read the file contents and send them as sql queries to the server. Queries should not return any data. + * Read the file contents and send them as sql queries to the server. Any data returned by the queries is + * discarded. * * @param server Server to send queries to * @param path Text file path. @@ -4953,6 +4954,12 @@ static bool run_sql_from_file(MXS_MONITORED_SERVER* server, const string& path, if (mxs_mysql_query(conn, line.c_str()) == 0) { lines_executed++; + // Discard results if any. + MYSQL_RES* res = mysql_store_result(conn); + if (res != NULL) + { + mysql_free_result(res); + } } else {