diff --git a/Documentation/Monitors/MariaDB-Monitor.md b/Documentation/Monitors/MariaDB-Monitor.md index f90830e16..f8db3cafc 100644 --- a/Documentation/Monitors/MariaDB-Monitor.md +++ b/Documentation/Monitors/MariaDB-Monitor.md @@ -332,34 +332,34 @@ following: 1. Select the most up-to-date slave of the old master to be the new master. The selection criteria is as follows in descending priority: - 1. gtid_IO_pos (latest event in relay log) - 2. gtid_current_pos (most processed events) - 3. log_slave_updates is on - 4. disk space is not low + 1. gtid_IO_pos (latest event in relay log) + 2. gtid_current_pos (most processed events) + 3. log_slave_updates is on + 4. disk space is not low 2. If the new master has unprocessed relay log items, cancel and try again later. 3. Prepare the new master: - 1. Remove the slave connection the new master used to replicate from the old + 1. Remove the slave connection the new master used to replicate from the old master. - 2. Disable the *read\_only*-flag. - 3. Enable scheduled server events (if event handling is on). - 4. Run the commands in `promotion_sql_file`. - 5. Start replication from external master if one existed. + 2. Disable the *read\_only*-flag. + 3. Enable scheduled server events (if event handling is on). + 4. Run the commands in `promotion_sql_file`. + 5. Start replication from external master if one existed. 4. Redirect all other slaves to replicate from the new master: - 1. STOP SLAVE and RESET SLAVE - 2. CHANGE MASTER TO - 3. START SLAVE + 1. STOP SLAVE and RESET SLAVE + 2. CHANGE MASTER TO + 3. START SLAVE 5. Check that all slaves are replicating. **Switchover** swaps a running master with a running slave. It does the following: 1. Prepare the old master for demotion: - 1. Stop any external replication. - 2. Enable the *read\_only*-flag to stop writes. - 3. Disable scheduled server events (if event handling is on). - 4. Run the commands in `demotion_sql_file`. - 5. Flush the binary log (FLUSH LOGS) so that all events are on disk. + 1. Stop any external replication. + 2. Enable the *read\_only*-flag to stop writes. + 3. Disable scheduled server events (if event handling is on). + 4. Run the commands in `demotion_sql_file`. + 5. Flush the binary log (FLUSH LOGS) so that all events are on disk. 2. Wait for the new master to catch up with the old master. 3. Promote new master and redirect slaves as in failover steps 3 and 4. Also redirect the demoted old master. @@ -383,15 +383,15 @@ cluster are out of sync while the actual data is known to be in sync. The operation proceeds as follows: 1. Reset gtid:s and delete binary logs on all servers: - 1. Stop (STOP SLAVE) and delete (RESET SLAVE ALL) all slave connections. - 2. Enable the *read\_only*-flag. - 3. Disable scheduled server events (if event handling is on). - 3. Delete binary logs (RESET MASTER). - 4. Set the sequence number of *gtid\_slave\_pos* to zero. This also affects + 1. Stop (STOP SLAVE) and delete (RESET SLAVE ALL) all slave connections. + 2. Enable the *read\_only*-flag. + 3. Disable scheduled server events (if event handling is on). + 3. Delete binary logs (RESET MASTER). + 4. Set the sequence number of *gtid\_slave\_pos* to zero. This also affects *gtid\_current\_pos*. 2. Prepare new master: - 1. Disable the *read\_only*-flag. - 2. Enable scheduled server events (if event handling is on). + 1. Disable the *read\_only*-flag. + 2. Enable scheduled server events (if event handling is on). 3. Direct other servers to replicate from the new master as in the other operations. diff --git a/maxscale-system-test/CMakeLists.txt b/maxscale-system-test/CMakeLists.txt index 8e8f86b3f..163322f2f 100644 --- a/maxscale-system-test/CMakeLists.txt +++ b/maxscale-system-test/CMakeLists.txt @@ -917,7 +917,10 @@ add_test_executable(mxs2273_being_drained.cpp mxs2273_being_drained mxs2273_bein add_test_executable(mxs2295_change_user_loop.cpp mxs2295_change_user_loop mxs2295_change_user_loop LABELS REPL_BACKEND) # MXS-2300: Prune session command history -add_test_executable(mxs2300_history_pruning.cpp mxs2300_history_pruning mxs2300_history_pruning LABELS REPL_BACKEND) +add_test_executable(mxs2300_history_pruning.cpp mxs2300_history_pruning mxs2300_history_pruning LABELS readwritesplit REPL_BACKEND) + +# MXS-2326: Routing hints aren't cloned in gwbuf_clone +add_test_executable(mxs2326_hint_clone.cpp mxs2326_hint_clone mxs2326_hint_clone LABELS readwritesplit REPL_BACKEND) ############################################ # BEGIN: binlogrouter and avrorouter tests # diff --git a/maxscale-system-test/cnf/maxscale.cnf.template.mxs2326_hint_clone b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2326_hint_clone new file mode 100755 index 000000000..292912ad1 --- /dev/null +++ b/maxscale-system-test/cnf/maxscale.cnf.template.mxs2326_hint_clone @@ -0,0 +1,53 @@ +[maxscale] +threads=###threads### +log_info=1 + +[server1] +type=server +address=###node_server_IP_1### +port=###node_server_port_1### +protocol=MySQLBackend + +[server2] +type=server +address=###node_server_IP_2### +port=###node_server_port_2### +protocol=MySQLBackend + +[server3] +type=server +address=###node_server_IP_3### +port=###node_server_port_3### +protocol=MySQLBackend + +[server4] +type=server +address=###node_server_IP_4### +port=###node_server_port_4### +protocol=MySQLBackend + +[MySQL Monitor] +type=monitor +module=mysqlmon +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +monitor_interval=1000 + +[hint] +type=filter +module=hintfilter + +[RW Split Router] +type=service +router=readwritesplit +servers=server1,server2,server3,server4 +user=maxskysql +password=skysql +filters=hint + +[RW Split Listener] +type=listener +service=RW Split Router +protocol=MySQLClient +port=4006 diff --git a/maxscale-system-test/mxs2057_systemd_watchdog.cpp b/maxscale-system-test/mxs2057_systemd_watchdog.cpp index 633d1c193..bf8852ea9 100644 --- a/maxscale-system-test/mxs2057_systemd_watchdog.cpp +++ b/maxscale-system-test/mxs2057_systemd_watchdog.cpp @@ -65,6 +65,7 @@ void test_watchdog(TestConnections& test, int argc, char* argv[]) if (test.global_result == 0) { test.tprintf("Maxscale was killed by systemd - ok"); + test.maxscales->ssh_node_f(0, true, "rm -f /tmp/*core"); } } } diff --git a/maxscale-system-test/mxs2326_hint_clone.cpp b/maxscale-system-test/mxs2326_hint_clone.cpp new file mode 100644 index 000000000..3224a31dd --- /dev/null +++ b/maxscale-system-test/mxs2326_hint_clone.cpp @@ -0,0 +1,29 @@ +/** + * MXS-2326: Routing hints aren't cloned in gwbuf_clone + */ + +#include "testconnections.h" + +int main(int argc, char** argv) +{ + TestConnections test(argc, argv); + Connection c = test.maxscales->rwsplit(); + test.expect(c.connect(), "Connection should work: %s", c.error()); + + std::string correct_id = c.field("SELECT @@server_id -- maxscale route to server server4"); + + test.tprintf("Executing session command"); + test.expect(c.query("SET @a = 1"), "SET should work: %s", c.error()); + + test.tprintf("Forcing a reconnection to occur on the next query by blocking the server"); + test.repl->block_node(3); + test.maxscales->wait_for_monitor(); + test.repl->unblock_node(3); + test.maxscales->wait_for_monitor(); + + test.tprintf("Executing a query with a routing hint to a server that the session is not connected to"); + test.expect(c.check("SELECT @@server_id -- maxscale route to server server4", + correct_id), "Hint should be routed to the same server"); + + return test.global_result; +} diff --git a/server/core/buffer.cc b/server/core/buffer.cc index 2846ebe38..65fa81e21 100644 --- a/server/core/buffer.cc +++ b/server/core/buffer.cc @@ -179,6 +179,7 @@ static GWBUF* gwbuf_clone_one(GWBUF* buf) rval->end = buf->end; rval->gwbuf_type = buf->gwbuf_type; rval->tail = rval; + rval->hint = hint_dup(buf->hint); rval->next = NULL; return rval;