diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 18:07:14 +0000 |
commit | a175314c3e5827eb193872241446f2f8f5c9d33c (patch) | |
tree | cd3d60ca99ae00829c52a6ca79150a5b6e62528b /mysql-test/suite/multi_source | |
parent | Initial commit. (diff) | |
download | mariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.tar.xz mariadb-10.5-a175314c3e5827eb193872241446f2f8f5c9d33c.zip |
Adding upstream version 1:10.5.12.upstream/1%10.5.12upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'mysql-test/suite/multi_source')
41 files changed, 4391 insertions, 0 deletions
diff --git a/mysql-test/suite/multi_source/disabled.def b/mysql-test/suite/multi_source/disabled.def new file mode 100644 index 00000000..e69de29b --- /dev/null +++ b/mysql-test/suite/multi_source/disabled.def diff --git a/mysql-test/suite/multi_source/gtid.cnf b/mysql-test/suite/multi_source/gtid.cnf new file mode 100644 index 00000000..b47ebb2c --- /dev/null +++ b/mysql-test/suite/multi_source/gtid.cnf @@ -0,0 +1,24 @@ +!include my.cnf + +[mysqld.1] +log-slave-updates +loose-innodb + +[mysqld.2] +log-slave-updates +loose-innodb + +[mysqld.3] +log-bin=server3-bin +log-slave-updates +loose-innodb + +[mysqld.4] +server-id=4 +log-bin=server4-bin +log-slave-updates +loose-innodb + +[ENV] +SERVER_MYPORT_4= @mysqld.4.port +SERVER_MYSOCK_4= @mysqld.4.socket diff --git a/mysql-test/suite/multi_source/gtid.result b/mysql-test/suite/multi_source/gtid.result new file mode 100644 index 00000000..0ed1062b --- /dev/null +++ b/mysql-test/suite/multi_source/gtid.result @@ -0,0 +1,130 @@ +connect slave1,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect slave2,127.0.0.1,root,,,$SERVER_MYPORT_4; +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connection slave1; +CHANGE MASTER 'slave1' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root'; +CHANGE MASTER 'slave2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root'; +set default_master_connection = 'slave1'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = 'slave2'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection slave2; +CHANGE MASTER TO master_port=MYPORT_3, master_host='127.0.0.1', master_user='root'; +start all slaves; +Warnings: +Note 1937 SLAVE '' started +include/wait_for_slave_to_start.inc +connection master1; +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +CREATE TABLE t3 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)); +INSERT INTO t1 VALUES (1, "initial"); +INSERT INTO t3 VALUES (101, "initial 1"); +connection slave1; +connection master2; +SET GLOBAL gtid_domain_id= 2; +SET SESSION gtid_domain_id= 2; +CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, "initial"); +SET SQL_LOG_BIN=0; +CREATE TABLE t3 (a INT PRIMARY KEY, b VARCHAR(10)); +SET SQL_LOG_BIN=1; +INSERT INTO t3 VALUES (201, "initial 2"); +connection slave2; +*** Now move slave2 to replicate from both master1 and master2 instead of just slave1 *** +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE '' stopped +connection master1; +INSERT INTO t1 VALUES (2, "switch1"); +INSERT INTO t3 VALUES (102, "switch1 a"); +connection master2; +INSERT INTO t2 VALUES (2, "switch1"); +INSERT INTO t3 VALUES (202, "switch1 b"); +connection slave2; +CHANGE MASTER 'slave1' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos; +CHANGE MASTER 'slave2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos; +SET default_master_connection = 'slave1'; +START SLAVE; +include/wait_for_slave_to_start.inc +SET default_master_connection = 'slave2'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +*** Move slave1 to replicate from slave2 instead of from master1 and master2 *** +connection slave1; +STOP SLAVE 'slave1'; +connection master1; +INSERT INTO t1 VALUES (3, "switch 2"); +INSERT INTO t3 VALUES (103, "switch 2 a"); +connection slave2; +connection master2; +INSERT INTO t2 VALUES (3, "switch 2"); +INSERT INTO t3 VALUES (203, "switch 2 b"); +include/save_master_gtid.inc +connection slave1; +STOP SLAVE 'slave2'; +connection master2; +INSERT INTO t2 VALUES (4, "switch 3"); +INSERT INTO t3 VALUES (204, "switch 3 b"); +connection slave2; +include/sync_with_master_gtid.inc +connection slave1; +CHANGE MASTER TO master_port=MYPORT_4, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos; +START SLAVE; +SELECT * FROM t1 ORDER BY a; +a b +1 initial +2 switch1 +3 switch 2 +SELECT * FROM t2 ORDER BY a; +a b +1 initial +2 switch1 +3 switch 2 +4 switch 3 +SELECT * FROM t3 ORDER BY a; +a b +101 initial 1 +102 switch1 a +103 switch 2 a +201 initial 2 +202 switch1 b +203 switch 2 b +204 switch 3 b +connection master1; +DROP TABLE t1; +SET SQL_LOG_BIN=0; +DROP TABLE t3; +SET SQL_LOG_BIN=1; +connection master2; +DROP TABLE t2; +DROP TABLE t3; +connection slave1; +SET GLOBAL gtid_domain_id=0; +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE '' stopped +include/reset_master_slave.inc +disconnect slave1; +connection slave2; +SET GLOBAL gtid_domain_id=0; +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE 'slave1' stopped +Note 1938 SLAVE 'slave2' stopped +include/reset_master_slave.inc +disconnect slave2; +connection master1; +SET GLOBAL gtid_domain_id=0; +include/reset_master_slave.inc +disconnect master1; +connection master2; +SET GLOBAL gtid_domain_id=0; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/gtid.test b/mysql-test/suite/multi_source/gtid.test new file mode 100644 index 00000000..c81ca20a --- /dev/null +++ b/mysql-test/suite/multi_source/gtid.test @@ -0,0 +1,171 @@ +--source include/not_embedded.inc +--source include/have_innodb.inc + +# +# Test GTID with multi-source +# + +--connect (slave1,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (slave2,127.0.0.1,root,,,$SERVER_MYPORT_4) +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) + +--connection slave1 +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'slave1' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'slave2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root'; +set default_master_connection = 'slave1'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'slave2'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + +--connection slave2 +--replace_result $SERVER_MYPORT_3 MYPORT_3 +eval CHANGE MASTER TO master_port=$SERVER_MYPORT_3, master_host='127.0.0.1', master_user='root'; +start all slaves; +--source include/wait_for_slave_to_start.inc + +--connection master1 +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +CREATE TABLE t3 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)); +INSERT INTO t1 VALUES (1, "initial"); +INSERT INTO t3 VALUES (101, "initial 1"); + +# Make sure we have CREATE TABLE t3 from master1 before replicating INSERT INTO +# t3 from master2. +--connection slave1 +--let $wait_condition= SELECT COUNT(*)=1 FROM information_schema.tables WHERE table_name = "t3" AND table_schema = "test" +--source include/wait_condition.inc + +--connection master2 +SET GLOBAL gtid_domain_id= 2; +SET SESSION gtid_domain_id= 2; +CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, "initial"); +SET SQL_LOG_BIN=0; +CREATE TABLE t3 (a INT PRIMARY KEY, b VARCHAR(10)); +SET SQL_LOG_BIN=1; +INSERT INTO t3 VALUES (201, "initial 2"); + +--connection slave2 +--let $wait_condition= SELECT COUNT(*)=3 FROM information_schema.tables WHERE table_name IN ("t1", "t2", "t3") AND table_schema = "test" +--source include/wait_condition.inc +--let $wait_condition= SELECT (SELECT COUNT(*) FROM t1)=1 AND (SELECT COUNT(*) FROM t2)=1 AND (SELECT COUNT(*) FROM t3)=2 +--source include/wait_condition.inc + +--echo *** Now move slave2 to replicate from both master1 and master2 instead of just slave1 *** +STOP ALL SLAVES; + +# Let us have a couple extra transactions on the masters to check that +# we resume replication at the right place even in the middle of the logs. +--connection master1 +INSERT INTO t1 VALUES (2, "switch1"); +INSERT INTO t3 VALUES (102, "switch1 a"); +--connection master2 +INSERT INTO t2 VALUES (2, "switch1"); +INSERT INTO t3 VALUES (202, "switch1 b"); + +--connection slave2 +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'slave1' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'slave2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos; +SET default_master_connection = 'slave1'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = 'slave2'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; +--let $wait_condition= SELECT (SELECT COUNT(*) FROM t1)=2 AND (SELECT COUNT(*) FROM t2)=2 AND (SELECT COUNT(*) FROM t3)=4 +--source include/wait_condition.inc + + +--echo *** Move slave1 to replicate from slave2 instead of from master1 and master2 *** +--connection slave1 +# Set up so that slave1 will have to start from two different positions +# in the slave2 binlog (one for each domain_id). +--let $wait_condition= SELECT (SELECT COUNT(*) FROM t1)=2 AND (SELECT COUNT(*) FROM t2)=2 AND (SELECT COUNT(*) FROM t3)=4 +--source include/wait_condition.inc +STOP SLAVE 'slave1'; + +--connection master1 +INSERT INTO t1 VALUES (3, "switch 2"); +INSERT INTO t3 VALUES (103, "switch 2 a"); + +--connection slave2 +--let $wait_condition= SELECT (SELECT COUNT(*) FROM t1)=3 AND (SELECT COUNT(*) FROM t2)=2 AND (SELECT COUNT(*) FROM t3)=5 +--source include/wait_condition.inc + +--connection master2 +INSERT INTO t2 VALUES (3, "switch 2"); +INSERT INTO t3 VALUES (203, "switch 2 b"); +--source include/save_master_gtid.inc + +--connection slave1 +--let $wait_condition= SELECT (SELECT COUNT(*) FROM t1)=2 AND (SELECT COUNT(*) FROM t2)=3 AND (SELECT COUNT(*) FROM t3)=5 +--source include/wait_condition.inc +STOP SLAVE 'slave2'; + +--connection master2 +INSERT INTO t2 VALUES (4, "switch 3"); +INSERT INTO t3 VALUES (204, "switch 3 b"); + +--connection slave2 +# Make sure that slave2 has replicated far enough before connecting slave1 to +# it (otherwise we get an error that slave1 requested to start from a GTID +# which is not in slave2's binlogs). +--source include/sync_with_master_gtid.inc + +--connection slave1 +--replace_result $SERVER_MYPORT_4 MYPORT_4 +eval CHANGE MASTER TO master_port=$SERVER_MYPORT_4, master_host='127.0.0.1', master_user='root', master_use_gtid=current_pos; +START SLAVE; +--let $wait_condition= SELECT (SELECT COUNT(*) FROM t1)=3 AND (SELECT COUNT(*) FROM t2)=4 AND (SELECT COUNT(*) FROM t3)=7 +--source include/wait_condition.inc +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t2 ORDER BY a; +SELECT * FROM t3 ORDER BY a; + +# Cleanup. +--connection master1 +DROP TABLE t1; +SET SQL_LOG_BIN=0; +DROP TABLE t3; +SET SQL_LOG_BIN=1; + +--connection master2 +DROP TABLE t2; +DROP TABLE t3; + +--connection slave1 +SET GLOBAL gtid_domain_id=0; +--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.tables WHERE table_name IN ("t1", "t2", "t3") AND table_schema = "test" +--source include/wait_condition.inc +--sorted_result +STOP ALL SLAVES; +--source include/reset_master_slave.inc +--disconnect slave1 + +--connection slave2 +SET GLOBAL gtid_domain_id=0; +--sorted_result +STOP ALL SLAVES; +--source include/reset_master_slave.inc +--disconnect slave2 + +--connection master1 +SET GLOBAL gtid_domain_id=0; +--source include/reset_master_slave.inc +--disconnect master1 + +--connection master2 +SET GLOBAL gtid_domain_id=0; +--source include/reset_master_slave.inc +--disconnect master2 diff --git a/mysql-test/suite/multi_source/gtid_ignore_duplicates.cnf b/mysql-test/suite/multi_source/gtid_ignore_duplicates.cnf new file mode 100644 index 00000000..ba1ffee4 --- /dev/null +++ b/mysql-test/suite/multi_source/gtid_ignore_duplicates.cnf @@ -0,0 +1,28 @@ +!include my.cnf + +[mysqld.1] +log-slave-updates +loose-innodb +binlog-format=mixed + +[mysqld.2] +log-slave-updates +loose-innodb +binlog-format=mixed + +[mysqld.3] +log-bin=server3-bin +log-slave-updates +loose-innodb +binlog-format=mixed + +[mysqld.4] +server-id=4 +log-bin=server4-bin +log-slave-updates +loose-innodb +binlog-format=mixed + +[ENV] +SERVER_MYPORT_4= @mysqld.4.port +SERVER_MYSOCK_4= @mysqld.4.socket diff --git a/mysql-test/suite/multi_source/gtid_ignore_duplicates.result b/mysql-test/suite/multi_source/gtid_ignore_duplicates.result new file mode 100644 index 00000000..e142ff8b --- /dev/null +++ b/mysql-test/suite/multi_source/gtid_ignore_duplicates.result @@ -0,0 +1,512 @@ +*** Test all-to-all replication with --gtid-ignore-duplicates *** +connect server_1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect server_2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect server_3,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect server_4,127.0.0.1,root,,,$SERVER_MYPORT_4; +connection server_1; +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +CHANGE MASTER 'b2a' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +CHANGE MASTER 'c2a' TO master_port=MYPORT_3, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'b2a'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = 'c2a'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection server_2; +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 2; +SET SESSION gtid_domain_id= 2; +CHANGE MASTER 'a2b' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +CHANGE MASTER 'c2b' TO master_port=MYPORT_3, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'a2b'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = 'c2b'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection server_3; +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 3; +SET SESSION gtid_domain_id= 3; +CHANGE MASTER 'a2c' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +CHANGE MASTER 'b2c' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'a2c'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = 'b2c'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection server_4; +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +CHANGE MASTER 'a2d' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'a2d'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection server_1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CALL mtr.add_suppression("This change will not take full effect until all SQL threads have been restarted"); +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +BEGIN; +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +COMMIT; +INSERT INTO t1 VALUES (4), (5); +INSERT INTO t1 VALUES (6); +include/save_master_gtid.inc +connection server_2; +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +6 +connection server_3; +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +6 +connection server_4; +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +6 +connection server_1; +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a +1 +2 +3 +4 +5 +6 +connection server_3; +INSERT INTO t1 VALUES (10); +include/save_master_gtid.inc +connection server_2; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +a +10 +STOP SLAVE "c2b"; +SET default_master_connection = "c2b"; +include/wait_for_slave_to_stop.inc +STOP SLAVE "a2b"; +SET default_master_connection = "a2b"; +include/wait_for_slave_to_stop.inc +connection server_3; +INSERT INTO t1 VALUES (11); +include/save_master_gtid.inc +connection server_1; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +a +10 +11 +SET default_master_connection = "b2a"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +connection server_2; +INSERT INTO t1 VALUES (12); +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +a +10 +12 +include/save_master_gtid.inc +connection server_1; +START SLAVE "b2a"; +SET default_master_connection = "b2a"; +include/wait_for_slave_to_start.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +a +10 +11 +12 +connection server_2; +START SLAVE "c2b"; +SET default_master_connection = "c2b"; +include/wait_for_slave_to_start.inc +START SLAVE "a2b"; +SET default_master_connection = "a2b"; +include/wait_for_slave_to_start.inc +connection server_1; +include/save_master_gtid.inc +connection server_2; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +a +10 +11 +12 +*** Test also with not using parallel replication. +connection server_1; +SET default_master_connection = "b2a"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET default_master_connection = "c2a"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "b2a"; +START SLAVE; +include/wait_for_slave_to_start.inc +SET default_master_connection = "c2a"; +START SLAVE; +include/wait_for_slave_to_start.inc +connection server_2; +SET default_master_connection = "a2b"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET default_master_connection = "c2b"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "a2b"; +START SLAVE; +include/wait_for_slave_to_start.inc +SET default_master_connection = "c2b"; +START SLAVE; +include/wait_for_slave_to_start.inc +connection server_3; +SET default_master_connection = "a2c"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET default_master_connection = "b2c"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "a2c"; +START SLAVE; +include/wait_for_slave_to_start.inc +SET default_master_connection = "b2c"; +START SLAVE; +include/wait_for_slave_to_start.inc +connection server_4; +SET default_master_connection = "a2d"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "a2d"; +START SLAVE; +include/wait_for_slave_to_start.inc +connection server_2; +INSERT INTO t1 VALUES (21); +BEGIN; +INSERT INTO t1 VALUES (22); +INSERT INTO t1 VALUES (23); +COMMIT; +INSERT INTO t1 VALUES (24), (25); +INSERT INTO t1 VALUES (26); +include/save_master_gtid.inc +connection server_1; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; +a +21 +22 +23 +24 +25 +26 +connection server_3; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; +a +21 +22 +23 +24 +25 +26 +connection server_4; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; +a +21 +22 +23 +24 +25 +26 +connection server_2; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; +a +21 +22 +23 +24 +25 +26 +*** MDEV-8354: out-of-order error with --gtid-ignore-duplicates and row-based replication *** +connection server_1; +SET default_master_connection = "b2a"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET default_master_connection = "c2a"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +connection server_2; +SET default_master_connection = "c2b"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +connection server_3; +SET default_master_connection = "b2c"; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +SET @old_slave_mode=@@GLOBAL.slave_exec_mode; +SET GLOBAL slave_exec_mode=IDEMPOTENT; +SET @old_strict=@@GLOBAL.gtid_strict_mode; +SET GLOBAL gtid_strict_mode=1; +SET @old_dbug=@@GLOBAL.debug_dbug; +SET GLOBAL debug_dbug="+d,inject_sleep_gtid_100_x_x"; +connection server_1; +SET @old_domain=@@SESSION.gtid_domain_id; +SET @old_format=@@SESSION.binlog_format; +SET SESSION gtid_domain_id=100; +SET SESSION binlog_format='row'; +INSERT INTO t1 VALUES (30); +INSERT INTO t1 VALUES (31); +INSERT INTO t1 VALUES (32); +INSERT INTO t1 VALUES (33); +INSERT INTO t1 VALUES (34); +INSERT INTO t1 VALUES (35); +INSERT INTO t1 VALUES (36); +INSERT INTO t1 VALUES (37); +INSERT INTO t1 VALUES (38); +INSERT INTO t1 VALUES (39); +INSERT INTO t1 VALUES (40); +INSERT INTO t1 VALUES (41); +INSERT INTO t1 VALUES (42); +INSERT INTO t1 VALUES (43); +INSERT INTO t1 VALUES (44); +INSERT INTO t1 VALUES (45); +INSERT INTO t1 VALUES (46); +INSERT INTO t1 VALUES (47); +INSERT INTO t1 VALUES (48); +INSERT INTO t1 VALUES (49); +SET SESSION gtid_domain_id=@old_domain; +SET SESSION binlog_format=@old_format; +include/save_master_gtid.inc +connection server_2; +include/sync_with_master_gtid.inc +INSERT INTO t1 VALUES (50); +include/save_master_gtid.inc +connection server_3; +SET default_master_connection = "b2c"; +START SLAVE; +include/wait_for_slave_to_start.inc +SELECT MASTER_GTID_WAIT("GTID", 30); +MASTER_GTID_WAIT("GTID", 30) +0 +connection server_1; +SET default_master_connection = "b2a"; +START SLAVE; +include/wait_for_slave_to_start.inc +SET default_master_connection = "c2a"; +START SLAVE; +include/wait_for_slave_to_start.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 30 ORDER BY a; +a +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +connection server_2; +SET default_master_connection = "c2b"; +START SLAVE; +include/wait_for_slave_to_start.inc +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 30 ORDER BY a; +a +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +connection server_3; +include/sync_with_master_gtid.inc +SET GLOBAL debug_dbug=@old_dbug; +SELECT * FROM t1 WHERE a >= 30 ORDER BY a; +a +30 +31 +32 +33 +34 +35 +36 +37 +38 +39 +40 +41 +42 +43 +44 +45 +46 +47 +48 +49 +50 +SET GLOBAL slave_exec_mode=@old_slave_mode; +SET GLOBAL gtid_strict_mode=@old_strict; +*** MDEV-8496: gtid_ignore_duplicates treats gtid_seq_no as 32-bit *** +connection server_1; +SET @old_domain= @@SESSION.gtid_domain_id; +SET SESSION gtid_domain_id=102; +SET SESSION gtid_seq_no=4294967294; +INSERT INTO t1 VALUES (60); +INSERT INTO t1 VALUES (61); +INSERT INTO t1 VALUES (62); +SET SESSION gtid_domain_id= @old_domain; +include/save_master_gtid.inc +connection server_4; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 60 ORDER BY a; +a +60 +61 +62 +connection server_2; +SET default_master_connection = "c2b"; +include/sync_with_master_gtid.inc +SET default_master_connection = "a2b"; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 60 ORDER BY a; +a +60 +61 +62 +connection server_3; +SET default_master_connection = "b2c"; +include/sync_with_master_gtid.inc +SET default_master_connection = "a2c"; +include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 60 ORDER BY a; +a +60 +61 +62 +connection server_1; +SET GLOBAL gtid_domain_id=0; +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE 'b2a' stopped +Note 1938 SLAVE 'c2a' stopped +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; +connection server_2; +SET GLOBAL gtid_domain_id=0; +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE 'a2b' stopped +Note 1938 SLAVE 'c2b' stopped +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; +connection server_3; +SET GLOBAL gtid_domain_id=0; +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE 'a2c' stopped +Note 1938 SLAVE 'b2c' stopped +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; +connection server_4; +SET GLOBAL gtid_domain_id=0; +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE 'a2d' stopped +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; +connection server_1; +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +include/reset_master_slave.inc +disconnect server_1; +connection server_2; +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +include/reset_master_slave.inc +disconnect server_2; +connection server_3; +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +include/reset_master_slave.inc +disconnect server_3; +connection server_4; +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +include/reset_master_slave.inc +disconnect server_4; diff --git a/mysql-test/suite/multi_source/gtid_ignore_duplicates.test b/mysql-test/suite/multi_source/gtid_ignore_duplicates.test new file mode 100644 index 00000000..3d2d151b --- /dev/null +++ b/mysql-test/suite/multi_source/gtid_ignore_duplicates.test @@ -0,0 +1,455 @@ +--source include/not_embedded.inc +--source include/have_innodb.inc +--source include/have_debug.inc + + +--echo *** Test all-to-all replication with --gtid-ignore-duplicates *** + +--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (server_4,127.0.0.1,root,,,$SERVER_MYPORT_4) + +# Setup A <-> B, B <-> C, C <-> A, and A -> D. + +--connection server_1 +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'b2a' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--replace_result $SERVER_MYPORT_3 MYPORT_3 +eval CHANGE MASTER 'c2a' TO master_port=$SERVER_MYPORT_3, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'b2a'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'c2a'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + +--connection server_2 +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 2; +SET SESSION gtid_domain_id= 2; +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'a2b' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--replace_result $SERVER_MYPORT_3 MYPORT_3 +eval CHANGE MASTER 'c2b' TO master_port=$SERVER_MYPORT_3, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'a2b'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'c2b'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + +--connection server_3 +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 3; +SET SESSION gtid_domain_id= 3; +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'a2c' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'b2c' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'a2c'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'b2c'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + +--connection server_4 +SET @old_parallel= @@GLOBAL.slave_parallel_threads; +SET GLOBAL slave_parallel_threads=5; +SET @old_ignore_duplicates= @@GLOBAL.gtid_ignore_duplicates; +SET GLOBAL gtid_ignore_duplicates=1; +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'a2d' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'a2d'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + + +--connection server_1 +ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; +CALL mtr.add_suppression("This change will not take full effect until all SQL threads have been restarted"); +CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; +INSERT INTO t1 VALUES (1); +BEGIN; +INSERT INTO t1 VALUES (2); +INSERT INTO t1 VALUES (3); +COMMIT; +INSERT INTO t1 VALUES (4), (5); +INSERT INTO t1 VALUES (6); + +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +--connection server_3 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +--connection server_4 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +--connection server_1 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; + +# Test that we can connect at a GTID position that has not yet reached +# that master server. +# We stop the connections C->B and A->B, create an event on C, Check that +# the event has reached A (but not B). Then let A stop and re-connect to +# B, which will connect at the new event, which is in the future for B. + +--connection server_3 +INSERT INTO t1 VALUES (10); +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +STOP SLAVE "c2b"; +SET default_master_connection = "c2b"; +--source include/wait_for_slave_to_stop.inc +STOP SLAVE "a2b"; +SET default_master_connection = "a2b"; +--source include/wait_for_slave_to_stop.inc + +--connection server_3 +INSERT INTO t1 VALUES (11); +--source include/save_master_gtid.inc + +--connection server_1 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +SET default_master_connection = "b2a"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc + +--connection server_2 +INSERT INTO t1 VALUES (12); +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; +--source include/save_master_gtid.inc + +--connection server_1 +START SLAVE "b2a"; +SET default_master_connection = "b2a"; +--source include/wait_for_slave_to_start.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; + +--connection server_2 +START SLAVE "c2b"; +SET default_master_connection = "c2b"; +--source include/wait_for_slave_to_start.inc +START SLAVE "a2b"; +SET default_master_connection = "a2b"; +--source include/wait_for_slave_to_start.inc + +--connection server_1 +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 10 ORDER BY a; + + +--echo *** Test also with not using parallel replication. + +--connection server_1 +SET default_master_connection = "b2a"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = "c2a"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "b2a"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = "c2a"; +START SLAVE; +--source include/wait_for_slave_to_start.inc + + +--connection server_2 +SET default_master_connection = "a2b"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = "c2b"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "a2b"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = "c2b"; +START SLAVE; +--source include/wait_for_slave_to_start.inc + + +--connection server_3 +SET default_master_connection = "a2c"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = "b2c"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "a2c"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = "b2c"; +START SLAVE; +--source include/wait_for_slave_to_start.inc + + +--connection server_4 +SET default_master_connection = "a2d"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET GLOBAL slave_parallel_threads=0; +SET default_master_connection = "a2d"; +START SLAVE; +--source include/wait_for_slave_to_start.inc + + +--connection server_2 +INSERT INTO t1 VALUES (21); +BEGIN; +INSERT INTO t1 VALUES (22); +INSERT INTO t1 VALUES (23); +COMMIT; +INSERT INTO t1 VALUES (24), (25); +INSERT INTO t1 VALUES (26); + +--source include/save_master_gtid.inc + +--connection server_1 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; + +--connection server_3 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; + +--connection server_4 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; + +--connection server_2 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 20 ORDER BY a; + + +--echo *** MDEV-8354: out-of-order error with --gtid-ignore-duplicates and row-based replication *** + +# Have only A->C A->B initially. +--connection server_1 +SET default_master_connection = "b2a"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = "c2a"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc + +--connection server_2 +SET default_master_connection = "c2b"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc + +--connection server_3 +SET default_master_connection = "b2c"; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +SET @old_slave_mode=@@GLOBAL.slave_exec_mode; +SET GLOBAL slave_exec_mode=IDEMPOTENT; +SET @old_strict=@@GLOBAL.gtid_strict_mode; +SET GLOBAL gtid_strict_mode=1; + +SET @old_dbug=@@GLOBAL.debug_dbug; +# This will inject a small sleep that helps trigger the race. I did not manage +# to create a non-sleeping version with debug_sync for this; the problem is +# that once the bug is fixed, the race becomes impossible, so even with +# debug_sync at best we can check that the debug_sync times out. Which is +# just another way of adding a sleep. +# +# The bug was a race at this point where another multi-source connection +# could incorrectly re-apply the same GTID, in case of row-based replication. +SET GLOBAL debug_dbug="+d,inject_sleep_gtid_100_x_x"; + +--connection server_1 +SET @old_domain=@@SESSION.gtid_domain_id; +SET @old_format=@@SESSION.binlog_format; +SET SESSION gtid_domain_id=100; +SET SESSION binlog_format='row'; +INSERT INTO t1 VALUES (30); +INSERT INTO t1 VALUES (31); +INSERT INTO t1 VALUES (32); +INSERT INTO t1 VALUES (33); +INSERT INTO t1 VALUES (34); +INSERT INTO t1 VALUES (35); +INSERT INTO t1 VALUES (36); +INSERT INTO t1 VALUES (37); +INSERT INTO t1 VALUES (38); +INSERT INTO t1 VALUES (39); +INSERT INTO t1 VALUES (40); +INSERT INTO t1 VALUES (41); +INSERT INTO t1 VALUES (42); +INSERT INTO t1 VALUES (43); +INSERT INTO t1 VALUES (44); +INSERT INTO t1 VALUES (45); +INSERT INTO t1 VALUES (46); +INSERT INTO t1 VALUES (47); +INSERT INTO t1 VALUES (48); +INSERT INTO t1 VALUES (49); +SET SESSION gtid_domain_id=@old_domain; +SET SESSION binlog_format=@old_format; +--source include/save_master_gtid.inc + +--connection server_2 +--source include/sync_with_master_gtid.inc +INSERT INTO t1 VALUES (50); +--let $gtid=`SELECT @@last_gtid` +--source include/save_master_gtid.inc + +--connection server_3 +SET default_master_connection = "b2c"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +--replace_result $gtid GTID +eval SELECT MASTER_GTID_WAIT("$gtid", 30); +# The bug occurred here, the slave would get an out-of-order binlog error +# due to trying to re-apply the 100-x-x transaction. + +# Restart stopped multi-source connections, and sync up. +--connection server_1 +SET default_master_connection = "b2a"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = "c2a"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 30 ORDER BY a; + +--connection server_2 +SET default_master_connection = "c2b"; +START SLAVE; +--source include/wait_for_slave_to_start.inc +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 30 ORDER BY a; + +--connection server_3 +--source include/sync_with_master_gtid.inc +SET GLOBAL debug_dbug=@old_dbug; +SELECT * FROM t1 WHERE a >= 30 ORDER BY a; +SET GLOBAL slave_exec_mode=@old_slave_mode; +SET GLOBAL gtid_strict_mode=@old_strict; + + +--echo *** MDEV-8496: gtid_ignore_duplicates treats gtid_seq_no as 32-bit *** + +--connection server_1 +SET @old_domain= @@SESSION.gtid_domain_id; +SET SESSION gtid_domain_id=102; +SET SESSION gtid_seq_no=4294967294; +INSERT INTO t1 VALUES (60); +INSERT INTO t1 VALUES (61); +INSERT INTO t1 VALUES (62); +# The bug was an overflow, the seq_no value 4294967296 (2**32) was treated +# as 0, causing the last transaction to be ignored. +SET SESSION gtid_domain_id= @old_domain; +--source include/save_master_gtid.inc + +--connection server_4 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 60 ORDER BY a; + +--connection server_2 +SET default_master_connection = "c2b"; +--source include/sync_with_master_gtid.inc +SET default_master_connection = "a2b"; +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 60 ORDER BY a; + +--connection server_3 +SET default_master_connection = "b2c"; +--source include/sync_with_master_gtid.inc +SET default_master_connection = "a2c"; +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 WHERE a >= 60 ORDER BY a; + + + +# Clean up. +--connection server_1 +SET GLOBAL gtid_domain_id=0; +--sorted_result +STOP ALL SLAVES; +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; + +--connection server_2 +SET GLOBAL gtid_domain_id=0; +--sorted_result +STOP ALL SLAVES; +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; + +--connection server_3 +SET GLOBAL gtid_domain_id=0; +--sorted_result +STOP ALL SLAVES; +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; + +--connection server_4 +SET GLOBAL gtid_domain_id=0; +--sorted_result +STOP ALL SLAVES; +SET GLOBAL slave_parallel_threads= @old_parallel; +SET GLOBAL gtid_ignore_duplicates= @old_ignore_duplicates; + +--connection server_1 +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +--source include/reset_master_slave.inc +--disconnect server_1 + +--connection server_2 +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +--source include/reset_master_slave.inc +--disconnect server_2 + +--connection server_3 +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +--source include/reset_master_slave.inc +--disconnect server_3 + +--connection server_4 +DROP TABLE t1; +ALTER TABLE mysql.gtid_slave_pos ENGINE=Aria; +--source include/reset_master_slave.inc +--disconnect server_4 diff --git a/mysql-test/suite/multi_source/gtid_slave_pos.result b/mysql-test/suite/multi_source/gtid_slave_pos.result new file mode 100644 index 00000000..d57cfc17 --- /dev/null +++ b/mysql-test/suite/multi_source/gtid_slave_pos.result @@ -0,0 +1,155 @@ +connect slave1,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connection slave1; +CHANGE MASTER 'slave1' TO master_port=MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +CHANGE MASTER 'slave2' TO master_port=MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'slave1'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = 'slave2'; +START SLAVE; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection master1; +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +CREATE TABLE t3 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)); +INSERT INTO t1 VALUES (1, "initial"); +INSERT INTO t3 VALUES (101, "initial 1"); +include/save_master_gtid.inc +connection master2; +SET GLOBAL gtid_domain_id= 2; +SET SESSION gtid_domain_id= 2; +CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, "initial"); +connection slave1; +include/sync_with_master_gtid.inc +connection master2; +include/save_master_gtid.inc +connection slave1; +include/sync_with_master_gtid.inc +*** Add an innodb gtid_slave_pos table. It is not used yet as slaves are already running *** +SET sql_log_bin=0; +CREATE TABLE mysql.gtid_slave_pos_innodb LIKE mysql.gtid_slave_pos; +ALTER TABLE mysql.gtid_slave_pos_innodb ENGINE=InnoDB; +SET sql_log_bin=0; +connection master1; +INSERT INTO t3 VALUES (102, "secondary"); +include/save_master_gtid.inc +connection slave1; +include/sync_with_master_gtid.inc +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; +domain_id max(seq_no) +1 5 +2 2 +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos_innodb GROUP BY domain_id; +domain_id max(seq_no) +*** Restart one slave thread, the other keeps running. Now the new table is used *** +connection slave1; +set default_master_connection = 'slave1'; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +START SLAVE; +include/wait_for_slave_to_start.inc +connection master1; +INSERT INTO t1 VALUES (2, "followup"); +include/save_master_gtid.inc +connection slave1; +include/sync_with_master_gtid.inc +connection master2; +INSERT INTO t2 VALUES (2, "secondary2"); +include/save_master_gtid.inc +connection slave1; +include/sync_with_master_gtid.inc +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; +domain_id max(seq_no) +1 6 +2 2 +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos_innodb GROUP BY domain_id; +domain_id max(seq_no) +2 3 +*** Remove a gtid_slave_posXXX table, restart one slave *** +*** Get a warning that the change is not yet picked up *** +*** See that updates fail due to trying to use the missing table *** +connection slave1; +SET sql_log_bin=0; +DROP TABLE mysql.gtid_slave_pos_innodb; +SET sql_log_bin=1; +set default_master_connection = 'slave2'; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +START SLAVE; +include/wait_for_slave_to_start.inc +CALL mtr.add_suppression("The table mysql.gtid_slave_pos_innodb was removed."); +connection master2; +INSERT INTO t2 VALUES (3, "tertiary 2"); +connection slave1; +include/wait_for_slave_sql_error.inc [errno=1942] +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; +domain_id max(seq_no) +1 6 +2 2 +*** Stop both slaves, see that the drop of mysql.gtid_slave_pos_innodb is now picked up *** +connection slave1; +set default_master_connection = 'slave1'; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +set default_master_connection = 'slave2'; +STOP SLAVE; +include/wait_for_slave_to_stop.inc +set default_master_connection = 'slave1'; +START SLAVE; +include/wait_for_slave_to_start.inc +connection master1; +INSERT INTO t1 VALUES (3, "more stuff"); +include/save_master_gtid.inc +connection slave1; +include/sync_with_master_gtid.inc +set default_master_connection = 'slave2'; +START SLAVE; +include/wait_for_slave_to_start.inc +connection master2; +include/save_master_gtid.inc +connection slave1; +include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +a b +1 initial +2 followup +3 more stuff +SELECT * FROM t2 ORDER BY a; +a b +1 initial +2 secondary2 +3 tertiary 2 +SELECT * FROM t3 ORDER BY a; +a b +101 initial 1 +102 secondary +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; +domain_id max(seq_no) +1 7 +2 4 +connection master1; +DROP TABLE t1; +DROP TABLE t3; +connection master2; +DROP TABLE t2; +connection slave1; +SET GLOBAL gtid_domain_id=0; +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE 'slave1' stopped +Note 1938 SLAVE 'slave2' stopped +include/reset_master_slave.inc +disconnect slave1; +connection master1; +SET GLOBAL gtid_domain_id=0; +include/reset_master_slave.inc +disconnect master1; +connection master2; +SET GLOBAL gtid_domain_id=0; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/gtid_slave_pos.test b/mysql-test/suite/multi_source/gtid_slave_pos.test new file mode 100644 index 00000000..c01130f8 --- /dev/null +++ b/mysql-test/suite/multi_source/gtid_slave_pos.test @@ -0,0 +1,173 @@ +--source include/not_embedded.inc +--source include/have_innodb.inc + +# +# Test multiple mysql.gtid_slave_posXXX tables with multiple master connections +# + +--connect (slave1,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) + +--connection slave1 +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'slave1' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'slave2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root', master_use_gtid=slave_pos; +set default_master_connection = 'slave1'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'slave2'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + + +--connection master1 +SET GLOBAL gtid_domain_id= 1; +SET SESSION gtid_domain_id= 1; +CREATE TABLE t3 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)); +INSERT INTO t1 VALUES (1, "initial"); +INSERT INTO t3 VALUES (101, "initial 1"); +--source include/save_master_gtid.inc + +--connection master2 +SET GLOBAL gtid_domain_id= 2; +SET SESSION gtid_domain_id= 2; +CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; +INSERT INTO t2 VALUES (1, "initial"); + + +--connection slave1 +--source include/sync_with_master_gtid.inc + +--connection master2 +--source include/save_master_gtid.inc + +--connection slave1 +--source include/sync_with_master_gtid.inc + + +--echo *** Add an innodb gtid_slave_pos table. It is not used yet as slaves are already running *** + +SET sql_log_bin=0; +CREATE TABLE mysql.gtid_slave_pos_innodb LIKE mysql.gtid_slave_pos; +ALTER TABLE mysql.gtid_slave_pos_innodb ENGINE=InnoDB; +SET sql_log_bin=0; + +--connection master1 +INSERT INTO t3 VALUES (102, "secondary"); +--source include/save_master_gtid.inc + +--connection slave1 +--source include/sync_with_master_gtid.inc +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos_innodb GROUP BY domain_id; + +--echo *** Restart one slave thread, the other keeps running. Now the new table is used *** +--connection slave1 +set default_master_connection = 'slave1'; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +START SLAVE; +--source include/wait_for_slave_to_start.inc + +# Send through a transaction on the slave1 connection, to be sure that it has +# had time to update the state with the new table. +--connection master1 +INSERT INTO t1 VALUES (2, "followup"); +--source include/save_master_gtid.inc +--connection slave1 +--source include/sync_with_master_gtid.inc + +--connection master2 +INSERT INTO t2 VALUES (2, "secondary2"); +--source include/save_master_gtid.inc + +--connection slave1 +--source include/sync_with_master_gtid.inc +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos_innodb GROUP BY domain_id; + +--echo *** Remove a gtid_slave_posXXX table, restart one slave *** +--echo *** Get a warning that the change is not yet picked up *** +--echo *** See that updates fail due to trying to use the missing table *** +--connection slave1 +SET sql_log_bin=0; +DROP TABLE mysql.gtid_slave_pos_innodb; +SET sql_log_bin=1; +set default_master_connection = 'slave2'; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +START SLAVE; +--source include/wait_for_slave_to_start.inc +CALL mtr.add_suppression("The table mysql.gtid_slave_pos_innodb was removed."); + +--connection master2 +INSERT INTO t2 VALUES (3, "tertiary 2"); + +--connection slave1 +--let $slave_sql_errno= 1942 +--source include/wait_for_slave_sql_error.inc +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; + +--echo *** Stop both slaves, see that the drop of mysql.gtid_slave_pos_innodb is now picked up *** +--connection slave1 +set default_master_connection = 'slave1'; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +set default_master_connection = 'slave2'; +STOP SLAVE; +--source include/wait_for_slave_to_stop.inc +set default_master_connection = 'slave1'; +START SLAVE; +--source include/wait_for_slave_to_start.inc +# Send through a transaction on the slave1 connection, to be sure that it has +# had time to update the state with the new table. +--connection master1 +INSERT INTO t1 VALUES (3, "more stuff"); +--source include/save_master_gtid.inc +--connection slave1 +--source include/sync_with_master_gtid.inc +set default_master_connection = 'slave2'; +START SLAVE; +--source include/wait_for_slave_to_start.inc + +--connection master2 +--source include/save_master_gtid.inc +--connection slave1 +--source include/sync_with_master_gtid.inc +SELECT * FROM t1 ORDER BY a; +SELECT * FROM t2 ORDER BY a; +SELECT * FROM t3 ORDER BY a; +SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; + + +# Cleanup. +--connection master1 +DROP TABLE t1; +DROP TABLE t3; + +--connection master2 +DROP TABLE t2; + +--connection slave1 +SET GLOBAL gtid_domain_id=0; +--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.tables WHERE table_name IN ("t1", "t2", "t3") AND table_schema = "test" +--source include/wait_condition.inc +--sorted_result +STOP ALL SLAVES; +--source include/reset_master_slave.inc +--disconnect slave1 + + +--connection master1 +SET GLOBAL gtid_domain_id=0; +--source include/reset_master_slave.inc +--disconnect master1 + +--connection master2 +SET GLOBAL gtid_domain_id=0; +--source include/reset_master_slave.inc +--disconnect master2 diff --git a/mysql-test/suite/multi_source/info_logs-master.opt b/mysql-test/suite/multi_source/info_logs-master.opt new file mode 100644 index 00000000..8b83537f --- /dev/null +++ b/mysql-test/suite/multi_source/info_logs-master.opt @@ -0,0 +1 @@ +--relay-log=relay.bin --relay-log-info-file=relay.bin.info diff --git a/mysql-test/suite/multi_source/info_logs.result b/mysql-test/suite/multi_source/info_logs.result new file mode 100644 index 00000000..b0a112aa --- /dev/null +++ b/mysql-test/suite/multi_source/info_logs.result @@ -0,0 +1,125 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +# +# List of files matching '*info*' pattern before starting any slaves +multi-master.info +# End of list +# +# Contents of multi-master.info +# EOF +# +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +start slave 'master1'; +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +# +# List of files matching '*info*' pattern while 'master1' is running +master-master1.info +multi-master.info +relay.bin-master1.info +# End of list +# +# Contents of multi-master.info +master1 +# EOF +# +change master 'MASTER 2.2' to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root'; +start slave 'MASTER 2.2'; +set default_master_connection = 'MASTER 2.2'; +include/wait_for_slave_to_start.inc +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connection slave; +# +# List of files matching '*info*' pattern +# while 'master1' and 'MASTER 2.2' are running +master-master1.info +master-master@00202@002e2.info +multi-master.info +relay.bin-master1.info +relay.bin-master@00202@002e2.info +# End of list +# +# Contents of multi-master.info +master1 +MASTER 2.2 +# EOF +# +stop slave 'master1'; +set default_master_connection = 'master1'; +include/wait_for_slave_to_stop.inc +reset slave 'master1' all; +# +# List of files matching '*info*' pattern +# after 'master1' was completely reset, 'MASTER 2.2' still running +master-master@00202@002e2.info +multi-master.info +relay.bin-master@00202@002e2.info +# End of list +# +# Contents of multi-master.info +MASTER 2.2 +# EOF +# +set default_master_connection = ''; +change master to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +start slave; +include/wait_for_slave_to_start.inc +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connection slave; +# +# List of files matching '*info*' pattern +# while 'MASTER 2.2' and '' are running +master-master@00202@002e2.info +master.info +multi-master.info +relay.bin-master@00202@002e2.info +relay.bin.info +# End of list +# +# Contents of multi-master.info +MASTER 2.2 +# EOF +# +show all slaves status; +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos + Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +include/wait_for_slave_to_start.inc +set default_master_connection = 'MASTER 2.2'; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +show all slaves status; +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos + Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> relay.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 +MASTER 2.2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> relay-master@00202@002e2.000004 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space2> None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 6 0 60.000 +# +# List of files matching '*info*' pattern +# after slave server restart +# while 'MASTER 2.2' and '' are running +master-master@00202@002e2.info +master.info +multi-master.info +relay.bin-master@00202@002e2.info +relay.bin.info +# End of list +# +# Contents of multi-master.info +MASTER 2.2 +# EOF +# +include/reset_master_slave.inc +disconnect slave; +connection master1; +include/reset_master_slave.inc +disconnect master1; +connection master2; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/info_logs.test b/mysql-test/suite/multi_source/info_logs.test new file mode 100644 index 00000000..234e317e --- /dev/null +++ b/mysql-test/suite/multi_source/info_logs.test @@ -0,0 +1,200 @@ +# +# Check log files with multi-source +# + +--source include/not_embedded.inc +--source include/binlog_start_pos.inc +--let $rpl_server_count= 0 + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +--let $datadir = `SELECT @@datadir` + +# +# Check creation and updating of multi-source *info* logs +# + +--echo # +--echo # List of files matching '*info*' pattern before starting any slaves +--list_files $datadir *info* +--echo # End of list +--echo # +--echo # Contents of multi-master.info +--cat_file $datadir/multi-master.info +--echo # EOF +--echo # + +# Start replication from the first master + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'master1' to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root'; + +start slave 'master1'; +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_start.inc + +# Check the files + +--echo # +--echo # List of files matching '*info*' pattern while 'master1' is running +--list_files $datadir *info* +--echo # End of list +--echo # +--echo # Contents of multi-master.info +--cat_file $datadir/multi-master.info +--echo # EOF +--echo # + +# Start replication from the second master + +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'MASTER 2.2' to +master_port=$SERVER_MYPORT_2, +master_host='127.0.0.1', +master_user='root'; + +start slave 'MASTER 2.2'; +set default_master_connection = 'MASTER 2.2'; +--source include/wait_for_slave_to_start.inc + +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--save_master_pos + +--connection slave +--sync_with_master 0,'MASTER 2.2' + +# Check the files + +--echo # +--echo # List of files matching '*info*' pattern +--echo # while 'master1' and 'MASTER 2.2' are running +--list_files $datadir *info* +--echo # End of list +--echo # +--echo # Contents of multi-master.info +--cat_file $datadir/multi-master.info +--echo # EOF +--echo # + +# Remove master1 configuration + +stop slave 'master1'; +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_stop.inc +reset slave 'master1' all; + +# Check the files + +--echo # +--echo # List of files matching '*info*' pattern +--echo # after 'master1' was completely reset, 'MASTER 2.2' still running +--list_files $datadir *info* +--echo # End of list +--echo # +--echo # Contents of multi-master.info +--cat_file $datadir/multi-master.info +--echo # EOF +--echo # + +# Start replication from the first master, +# now with the default empty name + +set default_master_connection = ''; +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root'; + +start slave; +--source include/wait_for_slave_to_start.inc + +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--save_master_pos + +--connection slave +--sync_with_master + +# Check the files + +--echo # +--echo # List of files matching '*info*' pattern +--echo # while 'MASTER 2.2' and '' are running +--list_files $datadir *info* +--echo # End of list +--echo # +--echo # Contents of multi-master.info +--cat_file $datadir/multi-master.info +--echo # EOF +--echo # + +let $wait_for_all= 1; +let $show_statement= SHOW ALL SLAVES STATUS; +let $field= Slave_IO_State; +let $condition= = 'Waiting for master to send event'; +--source include/wait_show_condition.inc + +let read_master_log_pos=`select $binlog_start_pos + 73`; +let relay_log_pos=`select 2*$binlog_start_pos + 117`; +let relay_log_space1=`select 3*$binlog_start_pos + 160`; +let relay_log_space2=`select 3*$binlog_start_pos + 179`; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +show all slaves status; + +# Restart the slave server + +--enable_reconnect +--append_file $MYSQLTEST_VARDIR/tmp/mysqld.3.expect +restart +EOF +--shutdown_server +--source include/wait_until_connected_again.inc +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'MASTER 2.2'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + +let $wait_for_all= 1; +let $show_statement= SHOW ALL SLAVES STATUS; +let $field= Slave_IO_State; +let $condition= = 'Waiting for master to send event'; +--source include/wait_show_condition.inc + + +let relay_log_pos=`select 2*$binlog_start_pos + 44`; +let relay_log_space1=`select 3*$binlog_start_pos + 87`; +let relay_log_space2=`select 3*$binlog_start_pos + 106`; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +show all slaves status; + +# Check the files + +--echo # +--echo # List of files matching '*info*' pattern +--echo # after slave server restart +--echo # while 'MASTER 2.2' and '' are running +--list_files $datadir *info* +--echo # End of list +--echo # +--echo # Contents of multi-master.info +--cat_file $datadir/multi-master.info +--echo # EOF +--echo # + + +# Cleanup + +--source include/reset_master_slave.inc +--disconnect slave + +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 + +--connection master2 +--source include/reset_master_slave.inc +--disconnect master2 + diff --git a/mysql-test/suite/multi_source/load_data.result b/mysql-test/suite/multi_source/load_data.result new file mode 100644 index 00000000..21b1bfff --- /dev/null +++ b/mysql-test/suite/multi_source/load_data.result @@ -0,0 +1,50 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connection slave; +change master '' to master_port=MYPORT_1, master_host='127.0.0.1', master_user='root'; +change master 'master2' to master_port=MYPORT_2, master_host='127.0.0.1', master_user='root'; +start all slaves; +Warnings: +Note 1937 SLAVE 'master2' started +Note 1937 SLAVE '' started +set default_master_connection = ''; +include/wait_for_slave_to_start.inc +set default_master_connection = 'master2'; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection master1; +create table t1 (a varchar(10) character set utf8); +load data infile '../../std_data/loaddata6.dat' into table t1; +connection slave; +connection master2; +create table t2 (a varchar(10) character set utf8); +load data infile '../../std_data/loaddata6.dat' into table t2; +connection slave; +select count(*) from t1; +count(*) +1 +select count(*) from t2; +count(*) +1 +connection master1; +drop table t1; +connection master2; +drop table t2; +connection master1; +connection slave; +connection master2; +connection slave; +connection slave; +stop all slaves; +Warnings: +Note 1938 SLAVE '' stopped +Note 1938 SLAVE 'master2' stopped +include/reset_master_slave.inc +disconnect slave; +connection master1; +include/reset_master_slave.inc +disconnect master1; +connection master2; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/load_data.test b/mysql-test/suite/multi_source/load_data.test new file mode 100644 index 00000000..94b328d5 --- /dev/null +++ b/mysql-test/suite/multi_source/load_data.test @@ -0,0 +1,71 @@ +# +# Simple multi-master test +# + +--source include/not_embedded.inc +--let $rpl_server_count= 0 + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connection slave + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master '' to master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'master2' to master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root'; +start all slaves; + +set default_master_connection = ''; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'master2'; +--source include/wait_for_slave_to_start.inc + +# +# Now test doing a load data infile from both connections +# +set default_master_connection = ''; +--connection master1 +create table t1 (a varchar(10) character set utf8); +load data infile '../../std_data/loaddata6.dat' into table t1; +--save_master_pos +--connection slave +--sync_with_master 0,'' +--connection master2 +create table t2 (a varchar(10) character set utf8); +load data infile '../../std_data/loaddata6.dat' into table t2; +--save_master_pos +--connection slave +--sync_with_master 0,'master2' +select count(*) from t1; +select count(*) from t2; +--connection master1 +drop table t1; +--connection master2 +drop table t2; + +# +# clean up +# + +--connection master1 +--save_master_pos +--connection slave +--sync_with_master 0,'' +--connection master2 +--save_master_pos +--connection slave +--sync_with_master 0,'master2' + +--connection slave +--sorted_result +stop all slaves; + +--source include/reset_master_slave.inc +--disconnect slave +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 +--connection master2 +--source include/reset_master_slave.inc +--disconnect master2 diff --git a/mysql-test/suite/multi_source/mdev-8874.cnf b/mysql-test/suite/multi_source/mdev-8874.cnf new file mode 100644 index 00000000..dc89db72 --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-8874.cnf @@ -0,0 +1,25 @@ +!include my.cnf + +[mysqld.1] +log-bin +log-slave-updates + +[mysqld.2] +log-bin +log-slave-updates + +[mysqld.3] +log-bin +log-slave-updates + +[mysqld.4] +server-id=4 +log-bin=server4-bin +log-slave-updates +m1.replicate_ignore_table='a.t1' +m2.replicate_ignore_table='b.t1' +replicate_ignore_table='c.t1' + +[ENV] +SERVER_MYPORT_4= @mysqld.4.port +SERVER_MYSOCK_4= @mysqld.4.socket diff --git a/mysql-test/suite/multi_source/mdev-8874.result b/mysql-test/suite/multi_source/mdev-8874.result new file mode 100644 index 00000000..aa9cc39b --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-8874.result @@ -0,0 +1,126 @@ +connect server_1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect server_2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect server_3,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect server_4,127.0.0.1,root,,,$SERVER_MYPORT_4; +connection server_1; +create database a; +use a; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +connection server_2; +create database b; +use b; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +connection server_3; +create database c; +use c; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +connection server_4; +change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root'; +change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root'; +change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root'; +start all slaves; +set default_master_connection = 'm1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +include/wait_for_slave_to_start.inc +select @@global.'m1'.replicate_ignore_table; +@@global.'m1'.replicate_ignore_table +a.t1 +select @@global.'m2'.replicate_ignore_table; +@@global.'m2'.replicate_ignore_table +b.t1 +select @@global.replicate_ignore_table; +@@global.replicate_ignore_table +c.t1 +use a; +#No t1 table +show tables; +Tables_in_a +t2 +use b; +#No t1 table +show tables; +Tables_in_b +t2 +use c; +#No t1 table +show tables; +Tables_in_c +t2 +#TEST +STOP ALL SLAVES; +Warnings: +Note 1938 SLAVE 'm2' stopped +Note 1938 SLAVE '' stopped +Note 1938 SLAVE 'm1' stopped +RESET SLAVE 'm1' ALL ; +RESET SLAVE 'm2' ALL ; +RESET SLAVE ALL ; +drop database a; +drop database b; +drop database c; +change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root'; +change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root'; +change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root'; +start all slaves; +Warnings: +Note 1937 SLAVE 'm2' started +Note 1937 SLAVE '' started +Note 1937 SLAVE 'm1' started +set default_master_connection = 'm1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +include/wait_for_slave_to_start.inc +#Replication Filter should be intact (t1 still not replicated) +select @@global.'m1'.replicate_ignore_table; +@@global.'m1'.replicate_ignore_table +a.t1 +select @@global.'m2'.replicate_ignore_table; +@@global.'m2'.replicate_ignore_table +b.t1 +select @@global.replicate_ignore_table; +@@global.replicate_ignore_table +c.t1 +use a; +#No t1 table +show tables; +Tables_in_a +t2 +use b; +#No t1 table +show tables; +Tables_in_b +t2 +use c; +#No t1 table +show tables; +Tables_in_c +t2 +#CleanUp +connection server_1; +drop database a; +connection server_2; +drop database b; +connection server_3; +drop database c; +connection server_4; +stop all slaves; +SET default_master_connection = "m1"; +include/wait_for_slave_to_stop.inc +SET default_master_connection = "m2"; +include/wait_for_slave_to_stop.inc +SET default_master_connection = ""; +include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/multi_source/mdev-8874.test b/mysql-test/suite/multi_source/mdev-8874.test new file mode 100644 index 00000000..d03c255b --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-8874.test @@ -0,0 +1,141 @@ +--source include/not_embedded.inc +--source include/have_innodb.inc +--source include/have_debug.inc +# MDEV-8874 +# In Named Master slave connection if we do reset slave 'connection_name' ALL and then +# if we reconnect slave, replication filters are ignored. +# This patch fixes this issue. +--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (server_4,127.0.0.1,root,,,$SERVER_MYPORT_4) + +--connection server_1 +create database a; +use a; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +--save_master_pos + +--connection server_2 +create database b; +use b; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +--save_master_pos + +--connection server_3 +create database c; +use c; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +--save_master_pos + +--connection server_4 +--disable_warnings +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_3 MYPORT_3 +eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root'; +start all slaves; +set default_master_connection = 'm1'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; +--source include/wait_for_slave_to_start.inc +select @@global.'m1'.replicate_ignore_table; +select @@global.'m2'.replicate_ignore_table; +select @@global.replicate_ignore_table; + +--enable_warnings +--sync_with_master 0,'m1' +--sync_with_master 0,'m2' +--sync_with_master 0,'' +use a; +--echo #No t1 table +show tables; +use b; +--echo #No t1 table +show tables; +use c; +--echo #No t1 table +show tables; +--echo #TEST +STOP ALL SLAVES; +RESET SLAVE 'm1' ALL ; +RESET SLAVE 'm2' ALL ; +RESET SLAVE ALL ; +drop database a; +drop database b; +drop database c; +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_3 MYPORT_3 +eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root'; +start all slaves; +set default_master_connection = 'm1'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; +--source include/wait_for_slave_to_start.inc +--sync_with_master 0,'m1' +--sync_with_master 0,'m2' +--sync_with_master 0,'' + +--echo #Replication Filter should be intact (t1 still not replicated) +select @@global.'m1'.replicate_ignore_table; +select @@global.'m2'.replicate_ignore_table; +select @@global.replicate_ignore_table; +use a; +--echo #No t1 table +show tables; +use b; +--echo #No t1 table +show tables; +use c; +--echo #No t1 table +show tables; + + +#--echo #restart the server +#--source include/restart_mysqld.inc + + +--echo #CleanUp +--connection server_1 +drop database a; +--save_master_pos + +--connection server_2 +drop database b; +--save_master_pos + +--connection server_3 +drop database c; +--save_master_pos + +--connection server_4 +--sync_with_master 0,'m1' +--sync_with_master 0,'m2' +--sync_with_master 0,'' +--disable_warnings +stop all slaves; +--enable_warnings +SET default_master_connection = "m1"; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = "m2"; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = ""; +--source include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/multi_source/mdev-9544.cnf b/mysql-test/suite/multi_source/mdev-9544.cnf new file mode 100644 index 00000000..b43aca53 --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-9544.cnf @@ -0,0 +1,22 @@ +!include my.cnf + +[mysqld.1] +log-bin +log-slave-updates + +[mysqld.2] +log-bin +log-slave-updates + +[mysqld.3] +log-bin +log-slave-updates + +[mysqld.4] +server-id=4 +log-bin=server4-bin +log-slave-updates + +[ENV] +SERVER_MYPORT_4= @mysqld.4.port +SERVER_MYSOCK_4= @mysqld.4.socket diff --git a/mysql-test/suite/multi_source/mdev-9544.result b/mysql-test/suite/multi_source/mdev-9544.result new file mode 100644 index 00000000..42e6b6a9 --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-9544.result @@ -0,0 +1,90 @@ +connect server_1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect server_2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect server_3,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect server_4,127.0.0.1,root,,,$SERVER_MYPORT_4; +connection server_1; +create database a; +use a; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +connection server_2; +create database b; +use b; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +connection server_3; +create database c; +use c; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +connection server_4; +change master 'm1' to master_port=MYPORT_1 , master_host='127.0.0.1', master_user='root'; +change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root'; +change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root'; +start all slaves; +set default_master_connection = 'm1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +include/wait_for_slave_to_start.inc +use a; +show tables; +Tables_in_a +t1 +t2 +use b; +show tables; +Tables_in_b +t1 +t2 +use c; +show tables; +Tables_in_c +t1 +t2 +#TEST +SET default_master_connection = "m1"; +SET default_master_connection = "m2"; +SET default_master_connection = ""; +flush logs; +SET default_master_connection = "m1"; +#log Rotated +mysqld-relay-bin.000002 +mysqld-relay-bin.000003 +mysqld-relay-bin.index +SET default_master_connection = "m2"; +#log Rotated +mysqld-relay-bin-m1.000002 +mysqld-relay-bin-m1.000003 +mysqld-relay-bin-m1.index +SET default_master_connection = ""; +#log Rotated +mysqld-relay-bin-m2.000002 +mysqld-relay-bin-m2.000003 +mysqld-relay-bin-m2.index +#CleanUp +connection server_1; +drop database a; +connection server_2; +drop database b; +connection server_3; +drop database c; +connection server_4; +stop all slaves; +Warnings: +Note 1938 SLAVE 'm2' stopped +Note 1938 SLAVE '' stopped +Note 1938 SLAVE 'm1' stopped +SET default_master_connection = "m1"; +include/wait_for_slave_to_stop.inc +SET default_master_connection = "m2"; +include/wait_for_slave_to_stop.inc +SET default_master_connection = ""; +include/wait_for_slave_to_stop.inc diff --git a/mysql-test/suite/multi_source/mdev-9544.test b/mysql-test/suite/multi_source/mdev-9544.test new file mode 100644 index 00000000..f532a63a --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-9544.test @@ -0,0 +1,116 @@ +--source include/not_embedded.inc +--source include/have_innodb.inc +--source include/have_debug.inc + +--connect (server_1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (server_2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (server_3,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (server_4,127.0.0.1,root,,,$SERVER_MYPORT_4) + +--connection server_1 +create database a; +use a; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +--save_master_pos + +--connection server_2 +create database b; +use b; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +--save_master_pos + +--connection server_3 +create database c; +use c; +create table t1(a int); +insert into t1 values(1); +create table t2(a int); +insert into t2 values(1); +--save_master_pos + +--connection server_4 +--disable_warnings +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'm1' to master_port=$SERVER_MYPORT_1 , master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'm2' to master_port=$SERVER_MYPORT_2 , master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_3 MYPORT_3 +eval change master to master_port=$SERVER_MYPORT_3 , master_host='127.0.0.1', master_user='root'; +start all slaves; +set default_master_connection = 'm1'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'm2'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; +--source include/wait_for_slave_to_start.inc + +--enable_warnings +--sync_with_master 0,'m1' +--sync_with_master 0,'m2' +--sync_with_master 0,'' +use a; +show tables; +use b; +show tables; +use c; +show tables; +--echo #TEST +SET default_master_connection = "m1"; +--let $old_m1 = query_get_value("show relaylog events;", "Log_name",1) +SET default_master_connection = "m2"; +--let $old_m2 = query_get_value("show relaylog events;", "Log_name",1) +SET default_master_connection = ""; +--let $old__ = query_get_value("show relaylog events;", "Log_name",1) +flush logs; +--sleep 2 +--let $MYSQLD_DATADIR = `select @@datadir` +SET default_master_connection = "m1"; +--let $new_m1 = query_get_value("show relaylog events;", "Log_name",1) +--if ($new_m1 != $old_m1) { + --echo #log Rotated + --exec ls $MYSQLD_DATADIR | grep "mysqld-relay-bin\." +} +SET default_master_connection = "m2"; +--let $new_m2 = query_get_value("show relaylog events;", "Log_name",1) +--if ($new_m2 != $old_m2) { + --echo #log Rotated + --exec ls $MYSQLD_DATADIR | grep "mysqld-relay-bin-m1" +} +SET default_master_connection = ""; +--let $new__ = query_get_value("show relaylog events;", "Log_name",1) +--if ($new__ != $old__) { + --echo #log Rotated + --exec ls $MYSQLD_DATADIR | grep "mysqld-relay-bin-m2" +} + +--echo #CleanUp +--connection server_1 +drop database a; +--save_master_pos + +--connection server_2 +drop database b; +--save_master_pos + +--connection server_3 +drop database c; +--save_master_pos + +--connection server_4 +--sync_with_master 0,'m1' +--sync_with_master 0,'m2' +--sync_with_master 0,'' +stop all slaves; +SET default_master_connection = "m1"; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = "m2"; +--source include/wait_for_slave_to_stop.inc +SET default_master_connection = ""; +--source include/wait_for_slave_to_stop.inc + diff --git a/mysql-test/suite/multi_source/multi_parallel.cnf b/mysql-test/suite/multi_source/multi_parallel.cnf new file mode 100644 index 00000000..0f0dc5c9 --- /dev/null +++ b/mysql-test/suite/multi_source/multi_parallel.cnf @@ -0,0 +1,6 @@ +!include my.cnf +[mysqld.1] +gtid_domain_id=1 + +[mysqld.2] +gtid_domain_id=2 diff --git a/mysql-test/suite/multi_source/multi_parallel.result b/mysql-test/suite/multi_source/multi_parallel.result new file mode 100644 index 00000000..bca01d57 --- /dev/null +++ b/mysql-test/suite/multi_source/multi_parallel.result @@ -0,0 +1,64 @@ +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +set global slave_parallel_threads=10; +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +change master 'master2' to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root'; +start all slaves; +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'master2'; +include/wait_for_slave_to_start.inc +## Slave status variable +set default_master_connection = 'master1'; +show status like 'slave_running'; +Variable_name Value +Slave_running ON +set default_master_connection = 'master2'; +show status like 'slave_running'; +Variable_name Value +Slave_running ON +#master 1 +connection master1; +##Running CURD operation +connection slave; +Slave_DDL_Groups= 20; +Slave_Non_Transactional_Groups= 20; +Slave_Transactional_Groups= 0; +#master 2 +connection master2; +##Running CURD operation +connection slave; +Slave_DDL_Groups= 20; +Slave_Non_Transactional_Groups= 20; +Slave_Transactional_Groups= 0; +#master 1 +connection master1; +##Running CURD operation +connection slave; +Slave_DDL_Groups= 40; +Slave_Non_Transactional_Groups= 20; +Slave_Transactional_Groups= 20; +stop all slaves; +Warnings: +Note 1938 SLAVE 'master2' stopped +Note 1938 SLAVE 'master1' stopped +set default_master_connection = 'master1'; +include/wait_for_slave_to_stop.inc +set default_master_connection = 'master2'; +include/wait_for_slave_to_stop.inc +set global slave_parallel_threads=0; +include/reset_master_slave.inc +disconnect slave; +connection master1; +include/reset_master_slave.inc +disconnect master1; +connection master2; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/multi_parallel.test b/mysql-test/suite/multi_source/multi_parallel.test new file mode 100644 index 00000000..a1385198 --- /dev/null +++ b/mysql-test/suite/multi_source/multi_parallel.test @@ -0,0 +1,125 @@ +# This test file tests events counter like Slave_ddl_groups, +# Slave_non_transactional_groups, Slave_transactional_groups +--source include/not_embedded.inc +--source include/have_innodb.inc +--let $rpl_server_count= 0 + +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +#save state +--let $par_thd= `select @@slave_parallel_threads;` + +set global slave_parallel_threads=10; + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'master1' to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root'; + +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'master2' to +master_port=$SERVER_MYPORT_2, +master_host='127.0.0.1', +master_user='root'; + + +#start all slaves +--disable_warnings +start all slaves; +--enable_warnings +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_start.inc + +set default_master_connection = 'master2'; +--source include/wait_for_slave_to_start.inc + +--echo ## Slave status variable + +set default_master_connection = 'master1'; +show status like 'slave_running'; + +set default_master_connection = 'master2'; +show status like 'slave_running'; + + +--echo #master 1 +--connection master1 + +--let $loop_counter=10 +--let $table_engine=myisam +--source multi_parallel_loop.inc +--save_master_pos + +--connection slave + +--sync_with_master 0,'master1' +--let $status= query_get_value(show slave 'master1' status, Slave_DDL_Groups, 1) +--echo Slave_DDL_Groups= $status; + +--let $status= query_get_value(show slave 'master1' status, Slave_Non_Transactional_Groups, 1) +--echo Slave_Non_Transactional_Groups= $status; + +--let $status= query_get_value(show slave 'master1' status, Slave_Transactional_Groups, 1) +--echo Slave_Transactional_Groups= $status; + +--echo #master 2 +--connection master2 + +--let $loop_counter=10 +--let $table_engine=myisam +--source multi_parallel_loop.inc +--save_master_pos + +--connection slave +--sync_with_master 0,'master2' +--let $status= query_get_value(show slave 'master2' status, Slave_DDL_Groups, 1) +--echo Slave_DDL_Groups= $status; + +--let $status= query_get_value(show slave 'master2' status, Slave_Non_Transactional_Groups, 1) +--echo Slave_Non_Transactional_Groups= $status; + +--let $status= query_get_value(show slave 'master2' status, Slave_Transactional_Groups, 1) +--echo Slave_Transactional_Groups= $status; + +--echo #master 1 +--connection master1 + +--let $loop_counter=10 +--let $table_engine=innodb +--source multi_parallel_loop.inc +--save_master_pos + +--connection slave + +--sync_with_master 0,'master1' +--let $status= query_get_value(show slave 'master1' status, Slave_DDL_Groups, 1) +--echo Slave_DDL_Groups= $status; + +--let $status= query_get_value(show slave 'master1' status, Slave_Non_Transactional_Groups, 1) +--echo Slave_Non_Transactional_Groups= $status; + +--let $status= query_get_value(show slave 'master1' status, Slave_Transactional_Groups, 1) +--echo Slave_Transactional_Groups= $status; + + +# Cleanup +stop all slaves; +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_stop.inc + +set default_master_connection = 'master2'; +--source include/wait_for_slave_to_stop.inc + +--eval set global slave_parallel_threads=$par_thd + +--source include/reset_master_slave.inc +--disconnect slave +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 +--connection master2 +--source include/reset_master_slave.inc +--disconnect master2 diff --git a/mysql-test/suite/multi_source/multi_parallel_loop.inc b/mysql-test/suite/multi_source/multi_parallel_loop.inc new file mode 100644 index 00000000..bf692b28 --- /dev/null +++ b/mysql-test/suite/multi_source/multi_parallel_loop.inc @@ -0,0 +1,19 @@ +#create a table,insert data and drop table + +#parameters +# loop_counter +# table_engine +--echo ##Running CURD operation +--disable_query_log +while ($loop_counter) +{ + #DDL statement + --eval create table t1(a int primary key) engine=$table_engine; + + #non trans update statement + insert into t1 values(1); + insert into t1 values(2); + drop table t1; + --dec $loop_counter +} +--enable_query_log diff --git a/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result new file mode 100644 index 00000000..b1aa31d0 --- /dev/null +++ b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result @@ -0,0 +1,157 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connection slave; +CHANGE MASTER 'slave1' TO MASTER_PORT=MYPORT_1, MASTER_HOST='127.0.0.1', MASTER_USER='root'; +CHANGE MASTER 'slave2' TO MASTER_PORT=MYPORT_2, MASTER_HOST='127.0.0.1', MASTER_USER='root'; +START REPLICA 'slave1'; +SET default_master_connection = 'slave1'; +include/wait_for_slave_to_start.inc +SET default_master_connection = 'slave2'; +"Command: START ALL SLAVES --> START ALL REPLICAS" +START ALL REPLICAS; +Warnings: +Note 1937 SLAVE 'slave2' started +include/wait_for_slave_to_start.inc +SET default_master_connection = ''; +connection master1; +connection slave; +connection master2; +connection slave; +"Command: SHOW ALL STAVES STATUS --> SHOW ALL REPLICAS STATUS" +SHOW ALL REPLICAS STATUS; +Connection_name slave1 +Slave_SQL_State Slave has read all relay log; waiting for more updates +Slave_IO_State Waiting for master to send event +Master_Host 127.0.0.1 +Master_User root +Master_Port MYPORT_1 +Connect_Retry 60 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos <read_master_log_pos> +Relay_Log_File mysqld-relay-bin-slave1.000002 +Relay_Log_Pos <relay_log_pos> +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running Yes +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos <read_master_log_pos> +Relay_Log_Space <relay_log_space1> +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master 0 +Master_SSL_Verify_Server_Cert No +Last_IO_Errno 0 +Last_IO_Error +Last_SQL_Errno 0 +Last_SQL_Error +Replicate_Ignore_Server_Ids +Master_Server_Id 1 +Master_SSL_Crl +Master_SSL_Crlpath +Using_Gtid No +Gtid_IO_Pos +Replicate_Do_Domain_Ids +Replicate_Ignore_Domain_Ids +Parallel_Mode optimistic +SQL_Delay 0 +SQL_Remaining_Delay NULL +Slave_SQL_Running_State Slave has read all relay log; waiting for more updates +Slave_DDL_Groups 0 +Slave_Non_Transactional_Groups 0 +Slave_Transactional_Groups 0 +Retried_transactions 0 +Max_relay_log_size 1073741824 +Executed_log_entries 7 +Slave_received_heartbeats 0 +Slave_heartbeat_period 60.000 +Gtid_Slave_Pos +Connection_name slave2 +Slave_SQL_State Slave has read all relay log; waiting for more updates +Slave_IO_State Waiting for master to send event +Master_Host 127.0.0.1 +Master_User root +Master_Port MYPORT_2 +Connect_Retry 60 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos <read_master_log_pos> +Relay_Log_File mysqld-relay-bin-slave2.000002 +Relay_Log_Pos <relay_log_pos> +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running Yes +Slave_SQL_Running Yes +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos <read_master_log_pos> +Relay_Log_Space <relay_log_space1> +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master 0 +Master_SSL_Verify_Server_Cert No +Last_IO_Errno 0 +Last_IO_Error +Last_SQL_Errno 0 +Last_SQL_Error +Replicate_Ignore_Server_Ids +Master_Server_Id 2 +Master_SSL_Crl +Master_SSL_Crlpath +Using_Gtid No +Gtid_IO_Pos +Replicate_Do_Domain_Ids +Replicate_Ignore_Domain_Ids +Parallel_Mode optimistic +SQL_Delay 0 +SQL_Remaining_Delay NULL +Slave_SQL_Running_State Slave has read all relay log; waiting for more updates +Slave_DDL_Groups 0 +Slave_Non_Transactional_Groups 0 +Slave_Transactional_Groups 0 +Retried_transactions 0 +Max_relay_log_size 1073741824 +Executed_log_entries 7 +Slave_received_heartbeats 0 +Slave_heartbeat_period 60.000 +Gtid_Slave_Pos +"Command: STOP ALL SLAVES --> STOP ALL REPLICAS" +STOP ALL REPLICAS; +Warnings: +Note 1938 SLAVE 'slave2' stopped +Note 1938 SLAVE 'slave1' stopped +include/reset_master_slave.inc +disconnect slave; +connection master1; +include/reset_master_slave.inc +disconnect master1; +connection master2; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/multi_source_slave_alias_replica.test b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.test new file mode 100644 index 00000000..409718dd --- /dev/null +++ b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.test @@ -0,0 +1,80 @@ +# ==== Purpose ==== +# +# Test verifies that SQL statements which use keyword 'REPLICA' a synonym for +# 'SLAVE' work as expected. +# +# ==== Implementation ==== +# +# List of commands being verified are +# +# START ALL REPLICAS +# STOP ALL REPLICAS +# SHOW ALL REPLICAS STATUS +# +# ==== References ==== +# +# MDEV-20601: Make REPLICA a synonym for SLAVE in SQL statements +# + +--source include/not_embedded.inc +--source include/binlog_start_pos.inc +--let $rpl_server_count= 0 + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) + +--connection slave +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval CHANGE MASTER 'slave1' TO MASTER_PORT=$SERVER_MYPORT_1, MASTER_HOST='127.0.0.1', MASTER_USER='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval CHANGE MASTER 'slave2' TO MASTER_PORT=$SERVER_MYPORT_2, MASTER_HOST='127.0.0.1', MASTER_USER='root'; +START REPLICA 'slave1'; +SET default_master_connection = 'slave1'; +--source include/wait_for_slave_to_start.inc +SET default_master_connection = 'slave2'; +--echo "Command: START ALL SLAVES --> START ALL REPLICAS" +START ALL REPLICAS; + +--source include/wait_for_slave_to_start.inc +SET default_master_connection = ''; + +# Ensure that all data is in the relay log +--connection master1 +--save_master_pos +--connection slave +--sync_with_master 0,'slave1' +--connection master2 +--save_master_pos +--connection slave +--sync_with_master 0,'slave2' + +--echo "Command: SHOW ALL STAVES STATUS --> SHOW ALL REPLICAS STATUS" +let $show_statement = SHOW ALL REPLICAS STATUS; +let $field = Executed_log_entries; +let $condition = = 7; +let $wait_for_all = 1; +--source include/wait_show_condition.inc + +let read_master_log_pos=`select $binlog_start_pos + 73`; +let relay_log_pos=`select 2*$binlog_start_pos + 117`; +let relay_log_space1=`select 3*$binlog_start_pos + 178`; +let relay_log_space2=`select 3*$binlog_start_pos + 178`; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +--query_vertical SHOW ALL REPLICAS STATUS + +--echo "Command: STOP ALL SLAVES --> STOP ALL REPLICAS" +STOP ALL REPLICAS; + +# +# clean up +# + +--source include/reset_master_slave.inc +--disconnect slave +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 +--connection master2 +--source include/reset_master_slave.inc +--disconnect master2 diff --git a/mysql-test/suite/multi_source/multisource.result b/mysql-test/suite/multi_source/multisource.result new file mode 100644 index 00000000..928c9799 --- /dev/null +++ b/mysql-test/suite/multi_source/multisource.result @@ -0,0 +1,230 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +change master 'abc' to relay_log_file=''; +ERROR HY000: Failed initializing relay log position: Could not find target log during relay log initialization +change master 'abc2' to master_host=''; +ERROR HY000: Incorrect arguments to MASTER_HOST +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +start slave 'master1'; +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connection slave; +# +# Checking SHOW SLAVE 'master1' STATUS +# +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000002' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_SQL_Errno = '0' +# +# Checking SHOW SLAVE STATUS +# +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000002' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_SQL_Errno = '0' +# +# Checking SHOW ALL SLAVES STATUS +# +Connection_name = 'master1' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000002' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_SQL_Errno = '0' +Slave_heartbeat_period = '60.000' +# +connection master1; +drop database if exists db1; +create database db1; +use db1; +create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM; +Warnings: +Warning 1280 Name 'pk' ignored for PRIMARY key. +insert into t1 (f1) values ('one'),('two'); +connection slave; +select * from db1.t1; +i f1 +1 one +2 two +# List of relay log files in the datadir +mysqld-relay-bin-master1.000001 +mysqld-relay-bin-master1.000002 +mysqld-relay-bin-master1.index +include/show_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-relay-bin-master1.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin-master1.000001 # Rotate # # mysqld-relay-bin-master1.000002;pos=4 +include/show_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-relay-bin-master1.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin-master1.000002 # Rotate # # master-bin.000001;pos=POS +mysqld-relay-bin-master1.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin-master1.000002 # Gtid_list # # [] +mysqld-relay-bin-master1.000002 # Binlog_checkpoint # # master-bin.000001 +mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin-master1.000002 # Query # # drop database if exists db1 +mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin-master1.000002 # Query # # create database db1 +mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin-master1.000002 # Query # # use `db1`; create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM +mysqld-relay-bin-master1.000002 # Gtid # # BEGIN GTID #-#-# +mysqld-relay-bin-master1.000002 # Intvar # # INSERT_ID=1 +mysqld-relay-bin-master1.000002 # Query # # use `db1`; insert into t1 (f1) values ('one'),('two') +mysqld-relay-bin-master1.000002 # Query # # COMMIT +change master 'master1' to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root'; +ERROR HY000: This operation cannot be performed as you have a running slave 'master1'; run STOP SLAVE 'master1' first +change master to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root'; +ERROR HY000: This operation cannot be performed as you have a running slave 'master1'; run STOP SLAVE 'master1' first +change master 'master2' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +ERROR HY000: Connection 'master2' conflicts with existing connection 'master1' +set default_master_connection = ''; +change master to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root'; +start slave; +include/wait_for_slave_to_start.inc +# +# Checking SHOW ALL SLAVES STATUS +# +Connection_name = '' +Connection_name = 'master1' +Master_Port = 'MYPORT_2' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin.000002' +Relay_Log_File = 'mysqld-relay-bin-master1.000002' +Slave_IO_Running = 'Yes' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_Errno = '0' +Last_SQL_Errno = '0' +Last_SQL_Errno = '0' +Slave_heartbeat_period = '60.000' +Slave_heartbeat_period = '60.000' +# +connection master1; +insert into t1 (f1) values ('three'); +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +drop database if exists db2; +create database db2; +use db2; +create table t1 (pk int auto_increment primary key, f1 int) engine=InnoDB; +begin; +insert into t1 (f1) values (1),(2); +connection slave; +connection master2; +connection slave; +select * from db1.t1; +i f1 +1 one +2 two +3 three +select * from db2.t1; +pk f1 +connection master2; +commit; +connection slave; +select * from db2.t1; +pk f1 +1 1 +2 2 +connection master1; +flush logs; +connection slave; +connection master1; +purge binary logs to 'master-bin.000002'; +show binary logs; +Log_name File_size +master-bin.000002 filesize +insert into t1 (f1) values ('four'); +create table db1.t3 (f1 int) engine=InnoDB; +connection slave; +# +# Checking SHOW ALL SLAVES STATUS +# +Connection_name = '' +Connection_name = 'master1' +Master_Port = 'MYPORT_2' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin.000002' +Relay_Log_File = 'mysqld-relay-bin-master1.000004' +Slave_IO_Running = 'Yes' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_Errno = '0' +Last_SQL_Errno = '0' +Last_SQL_Errno = '0' +Slave_heartbeat_period = '60.000' +Slave_heartbeat_period = '60.000' +# +select * from db1.t1; +i f1 +1 one +2 two +3 three +4 four +include/show_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-relay-bin.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin.000001 # Rotate # # mysqld-relay-bin.000002;pos=4 +include/show_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-relay-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin.000002 # Rotate # # master-bin.000001;pos=POS +mysqld-relay-bin.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin.000002 # Gtid_list # # [] +mysqld-relay-bin.000002 # Binlog_checkpoint # # master-bin.000001 +mysqld-relay-bin.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin.000002 # Query # # drop database if exists db2 +mysqld-relay-bin.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin.000002 # Query # # create database db2 +mysqld-relay-bin.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin.000002 # Query # # use `db2`; create table t1 (pk int auto_increment primary key, f1 int) engine=InnoDB +mysqld-relay-bin.000002 # Gtid # # BEGIN GTID #-#-# +mysqld-relay-bin.000002 # Intvar # # INSERT_ID=1 +mysqld-relay-bin.000002 # Query # # use `db2`; insert into t1 (f1) values (1),(2) +mysqld-relay-bin.000002 # Xid # # COMMIT /* XID */ +disconnect slave; +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +stop slave io_thread; +show status like 'Slave_running'; +Variable_name Value +Slave_running OFF +set default_master_connection = 'master1'; +show status like 'Slave_running'; +Variable_name Value +Slave_running ON +drop database db1; +drop database db2; +include/reset_master_slave.inc +disconnect slave; +connection master1; +drop database db1; +include/reset_master_slave.inc +disconnect master1; +connection master2; +drop database db2; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/multisource.test b/mysql-test/suite/multi_source/multisource.test new file mode 100644 index 00000000..53d9f408 --- /dev/null +++ b/mysql-test/suite/multi_source/multisource.test @@ -0,0 +1 @@ +--source suite/rpl/include/multisource.inc diff --git a/mysql-test/suite/multi_source/my.cnf b/mysql-test/suite/multi_source/my.cnf new file mode 100644 index 00000000..d98e6b62 --- /dev/null +++ b/mysql-test/suite/multi_source/my.cnf @@ -0,0 +1,26 @@ +# cat t/multisource1.cnf +!include include/default_mysqld.cnf +!include include/default_client.cnf + +[mysqld.1] +server-id=1 +log-bin=master-bin +log-warnings=2 + +[mysqld.2] +server-id=2 +log-bin=master-bin +log-warnings=2 + +[mysqld.3] +server-id=3 +log-warnings=2 + +[ENV] +MASTER_MYPORT= @mysqld.1.port +SERVER_MYPORT_1= @mysqld.1.port +SERVER_MYSOCK_1= @mysqld.1.socket +SERVER_MYPORT_2= @mysqld.2.port +SERVER_MYSOCK_2= @mysqld.2.socket +SERVER_MYPORT_3= @mysqld.3.port +SERVER_MYSOCK_3= @mysqld.3.socket diff --git a/mysql-test/suite/multi_source/relaylog_events.result b/mysql-test/suite/multi_source/relaylog_events.result new file mode 100644 index 00000000..5a4f480b --- /dev/null +++ b/mysql-test/suite/multi_source/relaylog_events.result @@ -0,0 +1,38 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +start slave 'master1'; +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +drop table if exists t1; +create table t1 (i int) engine=MyISAM; +connection slave; +mysqld-relay-bin-master1.000001 +mysqld-relay-bin-master1.000002 +mysqld-relay-bin-master1.index +include/show_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-relay-bin-master1.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin-master1.000002 # Rotate # # master-bin.000001;pos=POS +mysqld-relay-bin-master1.000002 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin-master1.000002 # Gtid_list # # [] +mysqld-relay-bin-master1.000002 # Binlog_checkpoint # # master-bin.000001 +mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin-master1.000002 # Query # # use `test`; DROP TABLE IF EXISTS `t1` /* generated by server */ +mysqld-relay-bin-master1.000002 # Gtid # # GTID #-#-# +mysqld-relay-bin-master1.000002 # Query # # use `test`; create table t1 (i int) engine=MyISAM +include/show_events.inc +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-relay-bin-master1.000001 # Format_desc # # SERVER_VERSION, BINLOG_VERSION +mysqld-relay-bin-master1.000001 # Rotate # # mysqld-relay-bin-master1.000002;pos=4 +connection master1; +drop table t1; +connection slave; +include/reset_master_slave.inc +disconnect slave; +connection master1; +include/reset_master_slave.inc +disconnect master1; diff --git a/mysql-test/suite/multi_source/relaylog_events.test b/mysql-test/suite/multi_source/relaylog_events.test new file mode 100644 index 00000000..7e5257af --- /dev/null +++ b/mysql-test/suite/multi_source/relaylog_events.test @@ -0,0 +1,53 @@ +# +# Check that SHOW RELAYLOG EVENTS can be used +# for a named master connection +# + +--source include/not_embedded.inc +--let $rpl_server_count= 0 + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'master1' to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root'; + +start slave 'master1'; +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_start.inc + +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--disable_warnings +drop table if exists t1; +--enable_warnings +create table t1 (i int) engine=MyISAM; +--save_master_pos + +--connection slave +--sync_with_master 0,'master1' + +--let $datadir = `SELECT @@datadir` +--list_files $datadir mysqld-relay-bin-master1.* + +let binlog_start=4; +let binlog_file= mysqld-relay-bin-master1.000002; +source include/show_relaylog_events.inc; +let binlog_file=; +source include/show_relaylog_events.inc; + +--connection master1 +drop table t1; +--save_master_pos + +--connection slave +--sync_with_master 0,'master1' + +--source include/reset_master_slave.inc +--disconnect slave + +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 + diff --git a/mysql-test/suite/multi_source/reset_slave.result b/mysql-test/suite/multi_source/reset_slave.result new file mode 100644 index 00000000..c048784e --- /dev/null +++ b/mysql-test/suite/multi_source/reset_slave.result @@ -0,0 +1,34 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +start slave 'master1'; +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +drop table if exists t1; +create table t1 (i int) engine=MyISAM; +insert into t1 values (1),(2); +connection slave; +stop slave 'master1'; +show slave 'master1' status; +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups + 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-master1.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space> None 0 No NULL No 0 0 1 No optimistic 0 NULL 2 1 0 +mysqld-relay-bin-master1.000001 +mysqld-relay-bin-master1.000002 +mysqld-relay-bin-master1.index +reset slave 'master1'; +show slave 'master1' status; +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups + 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space> None 0 No NULL No 0 0 1 No optimistic 0 NULL 2 1 0 +reset slave 'master1' all; +show slave 'master1' status; +ERROR HY000: There is no master connection 'master1' +drop table t1; +include/reset_master_slave.inc +disconnect slave; +connection master1; +drop table t1; +include/reset_master_slave.inc +disconnect master1; diff --git a/mysql-test/suite/multi_source/reset_slave.test b/mysql-test/suite/multi_source/reset_slave.test new file mode 100644 index 00000000..63a1f9c3 --- /dev/null +++ b/mysql-test/suite/multi_source/reset_slave.test @@ -0,0 +1,73 @@ +# +# Check RESET SLAVE [name] [ALL] for multi-source replication +# + +--source include/not_embedded.inc +--source include/binlog_start_pos.inc +--let $rpl_server_count= 0 + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'master1' to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root'; + +start slave 'master1'; + +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_start.inc + +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) + +--disable_warnings +drop table if exists t1; +--enable_warnings + +create table t1 (i int) engine=MyISAM; +insert into t1 values (1),(2); + +--save_master_pos + +--connection slave + +--sync_with_master 0,'master1' +stop slave 'master1'; + +--wait_for_slave_to_stop + +--let $datadir = `SELECT @@datadir` + +let read_master_log_pos=`select $binlog_start_pos + 590`; +let relay_log_pos=`select 2*$binlog_start_pos + 634`; +let relay_log_space=`select 3*$binlog_start_pos + 696`; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space <relay_log_space> +show slave 'master1' status; +--list_files $datadir mysqld* + +reset slave 'master1'; + +--replace_result $SERVER_MYPORT_1 MYPORT_1 $relay_log_pos <relay_log_pos> $relay_log_space <relay_log_space> +show slave 'master1' status; +--list_files $datadir mysqld* + +reset slave 'master1' all; + +--error WARN_NO_MASTER_INFO +show slave 'master1' status; +--list_files $datadir mysqld* + +# Cleanup + +drop table t1; +--source include/reset_master_slave.inc +--disconnect slave + +--connection master1 +drop table t1; +--source include/reset_master_slave.inc +--disconnect master1 + + + diff --git a/mysql-test/suite/multi_source/simple.result b/mysql-test/suite/multi_source/simple.result new file mode 100644 index 00000000..a66d49e8 --- /dev/null +++ b/mysql-test/suite/multi_source/simple.result @@ -0,0 +1,103 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +connection slave; +change master 'slave1' to master_port=MYPORT_1, master_host='127.0.0.1', master_user='root'; +change master 'slave2' to master_port=MYPORT_2, master_host='127.0.0.1', master_user='root'; +start slave 'slave1'; +set default_master_connection = 'slave1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'slave2'; +start all slaves; +Warnings: +Note 1937 SLAVE 'slave2' started +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection master1; +connection slave; +connection master2; +connection slave; +show all slaves status; +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos +slave1 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_1 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave1.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 1 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +slave2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +start all slaves; +stop slave 'slave1'; +show slave 'slave1' status; +Slave_IO_State +Master_Host 127.0.0.1 +Master_User root +Master_Port MYPORT_1 +Connect_Retry 60 +Master_Log_File master-bin.000001 +Read_Master_Log_Pos <read_master_log_pos> +Relay_Log_File mysqld-relay-bin-slave1.000002 +Relay_Log_Pos <relay_log_pos> +Relay_Master_Log_File master-bin.000001 +Slave_IO_Running No +Slave_SQL_Running No +Replicate_Do_DB +Replicate_Ignore_DB +Replicate_Do_Table +Replicate_Ignore_Table +Replicate_Wild_Do_Table +Replicate_Wild_Ignore_Table +Last_Errno 0 +Last_Error +Skip_Counter 0 +Exec_Master_Log_Pos <read_master_log_pos> +Relay_Log_Space <relay_log_space1> +Until_Condition None +Until_Log_File +Until_Log_Pos 0 +Master_SSL_Allowed No +Master_SSL_CA_File +Master_SSL_CA_Path +Master_SSL_Cert +Master_SSL_Cipher +Master_SSL_Key +Seconds_Behind_Master NULL +Master_SSL_Verify_Server_Cert No +Last_IO_Errno 0 +Last_IO_Error +Last_SQL_Errno 0 +Last_SQL_Error +Replicate_Ignore_Server_Ids +Master_Server_Id 1 +Master_SSL_Crl +Master_SSL_Crlpath +Using_Gtid No +Gtid_IO_Pos +Replicate_Do_Domain_Ids +Replicate_Ignore_Domain_Ids +Parallel_Mode optimistic +SQL_Delay 0 +SQL_Remaining_Delay NULL +Slave_SQL_Running_State +Slave_DDL_Groups 0 +Slave_Non_Transactional_Groups 0 +Slave_Transactional_Groups 0 +reset slave 'slave1'; +show all slaves status; +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos +slave1 127.0.0.1 root MYPORT_1 60 4 <relay_log_pos> No No 0 0 0 <relay_log_space1> None 0 No NULL No 0 0 1 No optimistic 0 NULL 0 0 0 0 1073741824 7 0 60.000 +slave2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +reset slave 'slave1' all; +show all slaves status; +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos +slave2 Slave has read all relay log; waiting for more updates Waiting for master to send event 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 Yes Yes 0 0 <read_master_log_pos> <relay_log_space1> None 0 No 0 No 0 0 2 No optimistic 0 NULL Slave has read all relay log; waiting for more updates 0 0 0 0 1073741824 7 0 60.000 +stop all slaves; +Warnings: +Note 1938 SLAVE 'slave2' stopped +show all slaves status; +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos +slave2 127.0.0.1 root MYPORT_2 60 master-bin.000001 <read_master_log_pos> mysqld-relay-bin-slave2.000002 <relay_log_pos> master-bin.000001 No No 0 0 <read_master_log_pos> <relay_log_space1> None 0 No NULL No 0 0 2 No optimistic 0 NULL 0 0 0 0 1073741824 7 0 60.000 +stop all slaves; +include/reset_master_slave.inc +disconnect slave; +connection master1; +include/reset_master_slave.inc +disconnect master1; +connection master2; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/simple.test b/mysql-test/suite/multi_source/simple.test new file mode 100644 index 00000000..95291c53 --- /dev/null +++ b/mysql-test/suite/multi_source/simple.test @@ -0,0 +1,86 @@ +# +# Simple multi-master test +# + +--source include/not_embedded.inc +--source include/binlog_start_pos.inc +--let $rpl_server_count= 0 + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) +--connection slave + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'slave1' to master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root'; +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'slave2' to master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root'; +start slave 'slave1'; +set default_master_connection = 'slave1'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = 'slave2'; +start all slaves; + +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + +# Ensure that all data is in the relay log +--connection master1 +--save_master_pos +--connection slave +--sync_with_master 0,'slave1' +--connection master2 +--save_master_pos +--connection slave +--sync_with_master 0,'slave2' + +# MDEV-7074 (Sporadic test failure due to a race condition) +let $show_statement = SHOW ALL SLAVES STATUS; +let $field = Executed_log_entries; +let $condition = = 7; +let $wait_for_all = 1; +--source include/wait_show_condition.inc + +let read_master_log_pos=`select $binlog_start_pos + 73`; +let relay_log_pos=`select 2*$binlog_start_pos + 117`; +let relay_log_space1=`select 3*$binlog_start_pos + 178`; +let relay_log_space2=`select 3*$binlog_start_pos + 178`; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +show all slaves status; + +# Ensure that start all slaves doesn't do anything as all slaves are started +start all slaves; + +stop slave 'slave1'; + +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +query_vertical show slave 'slave1' status; + +reset slave 'slave1'; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +show all slaves status; + +reset slave 'slave1' all; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +show all slaves status; + +stop all slaves; +--replace_result $SERVER_MYPORT_1 MYPORT_1 $SERVER_MYPORT_2 MYPORT_2 $read_master_log_pos <read_master_log_pos> $relay_log_pos <relay_log_pos> $relay_log_space1 <relay_log_space1> $relay_log_space2 <relay_log_space2> +show all slaves status; + +# Ensure that start all slaves doesn't do anything as all slaves are stopped +stop all slaves; + +# +# clean up +# + +--source include/reset_master_slave.inc +--disconnect slave +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 +--connection master2 +--source include/reset_master_slave.inc +--disconnect master2 + diff --git a/mysql-test/suite/multi_source/skip_counter.result b/mysql-test/suite/multi_source/skip_counter.result new file mode 100644 index 00000000..03103af2 --- /dev/null +++ b/mysql-test/suite/multi_source/skip_counter.result @@ -0,0 +1,127 @@ +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +drop database if exists db; +create database db; +create table db.this_will_not_be_replicated (i int) engine=MyISAM; +create table db.t1 (i int) engine=MyISAM; +create table db.t2 (i int) engine=MyISAM; +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +drop database if exists db; +create database db; +create table db.t3 (i int) engine=MyISAM; +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root'; +start slave 'master1'; +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +set default_master_connection = 'master2'; +change master 'master2' to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root'; +set global sql_slave_skip_counter = 2; +select @@global.sql_slave_skip_counter; +@@global.sql_slave_skip_counter +2 +select @@session.sql_slave_skip_counter; +@@session.sql_slave_skip_counter +2 +set session sql_slave_skip_counter = 3; +select @@global.sql_slave_skip_counter; +@@global.sql_slave_skip_counter +3 +select @@session.sql_slave_skip_counter; +@@session.sql_slave_skip_counter +3 +set global sql_slave_skip_counter= default; +select @@global.sql_slave_skip_counter; +@@global.sql_slave_skip_counter +0 +select @@session.sql_slave_skip_counter; +@@session.sql_slave_skip_counter +0 +set global sql_slave_skip_counter= 4; +set default_master_connection = 'master1'; +select @@session.sql_slave_skip_counter; +@@session.sql_slave_skip_counter +0 +set default_master_connection = 'qqq'; +select @@session.sql_slave_skip_counter; +@@session.sql_slave_skip_counter +0 +Warnings: +Warning 1617 There is no master connection 'qqq' +set default_master_connection = 'master2'; +select @@session.sql_slave_skip_counter; +@@session.sql_slave_skip_counter +4 +select @@global.max_relay_log_size; +@@global.max_relay_log_size +1073741824 +set global max_relay_log_size = 1*1024*1024; +select @@global.max_relay_log_size; +@@global.max_relay_log_size +1048576 +select @@session.max_relay_log_size; +@@session.max_relay_log_size +1048576 +set session max_relay_log_size = 3*1024*1024; +select @@global.max_relay_log_size; +@@global.max_relay_log_size +3145728 +select @@session.max_relay_log_size; +@@session.max_relay_log_size +3145728 +set global max_relay_log_size= default; +select @@global.max_relay_log_size; +@@global.max_relay_log_size +1073741824 +select @@session.max_relay_log_size; +@@session.max_relay_log_size +1073741824 +set global max_relay_log_size= 3*1024*1024; +set default_master_connection = 'master1'; +select @@session.max_relay_log_size; +@@session.max_relay_log_size +1073741824 +set default_master_connection = 'qqq'; +select @@session.max_relay_log_size; +@@session.max_relay_log_size +0 +Warnings: +Warning 1617 There is no master connection 'qqq' +set default_master_connection = 'master2'; +select @@session.max_relay_log_size; +@@session.max_relay_log_size +3145728 +set global max_binlog_size= 4*1024*1024; +select @@global.max_relay_log_size; +@@global.max_relay_log_size +3145728 +start slave 'master2'; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +connection master2; +connection slave; +show tables in db; +Tables_in_db +t1 +t2 +t3 +this_will_not_be_replicated +drop database db; +set global sql_slave_skip_counter = 0; +set global max_relay_log_size = 1073741824; +set global max_binlog_size = 1073741824; +include/reset_master_slave.inc +disconnect slave; +connection master1; +drop database db; +include/reset_master_slave.inc +disconnect master1; +connection master2; +drop database db; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/skip_counter.test b/mysql-test/suite/multi_source/skip_counter.test new file mode 100644 index 00000000..e53d0276 --- /dev/null +++ b/mysql-test/suite/multi_source/skip_counter.test @@ -0,0 +1,149 @@ +# +# Test of sql_slave_skip_counter and rpl_max_size +# + +# Create a schema and a table i +# on the 1st master + +--source include/not_embedded.inc +--let $rpl_server_count= 0 + +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) + +--disable_warnings +drop database if exists db; +--enable_warnings +create database db; +create table db.this_will_not_be_replicated (i int) engine=MyISAM; +create table db.t1 (i int) engine=MyISAM; +create table db.t2 (i int) engine=MyISAM; +--save_master_pos + +# Create the same schema and another table +# on the 2nd master + +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) + +--disable_warnings +drop database if exists db; +--enable_warnings +create database db; +create table db.t3 (i int) engine=MyISAM; + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +# Start replication from the first master + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'master1' to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root'; + +start slave 'master1'; +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_start.inc +--sync_with_master 0,'master1' + +# Start replication from the second master + +set default_master_connection = 'master2'; + +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master 'master2' to +master_port=$SERVER_MYPORT_2, +master_host='127.0.0.1', +master_user='root'; + +# the schema creation will be replicated from the 1st master, +# so we want to skip it in the second replication connection +# The events we want to skip are: +# +# The start format statement event +# drop database if exists db +# create database db +# Create table db.t1 +# - > 4 events in total + +--let $skip_counter_saved = `select @@global.sql_slave_skip_counter` +--let $max_relay_log_size_saved= `select @@global.max_relay_log_size` +--let $max_binlog_size_saved= `select @@global.max_binlog_size` +set global sql_slave_skip_counter = 2; +select @@global.sql_slave_skip_counter; +select @@session.sql_slave_skip_counter; +set session sql_slave_skip_counter = 3; +select @@global.sql_slave_skip_counter; +select @@session.sql_slave_skip_counter; +set global sql_slave_skip_counter= default; +select @@global.sql_slave_skip_counter; +select @@session.sql_slave_skip_counter; +set global sql_slave_skip_counter= 4; + +set default_master_connection = 'master1'; +select @@session.sql_slave_skip_counter; +set default_master_connection = 'qqq'; +select @@session.sql_slave_skip_counter; +set default_master_connection = 'master2'; +select @@session.sql_slave_skip_counter; + +# Test of setting max_relay_log_size +select @@global.max_relay_log_size; +set global max_relay_log_size = 1*1024*1024; +select @@global.max_relay_log_size; +select @@session.max_relay_log_size; +set session max_relay_log_size = 3*1024*1024; +select @@global.max_relay_log_size; +select @@session.max_relay_log_size; +set global max_relay_log_size= default; +select @@global.max_relay_log_size; +select @@session.max_relay_log_size; +set global max_relay_log_size= 3*1024*1024; +set default_master_connection = 'master1'; +select @@session.max_relay_log_size; +set default_master_connection = 'qqq'; +select @@session.max_relay_log_size; +set default_master_connection = 'master2'; +select @@session.max_relay_log_size; +set global max_binlog_size= 4*1024*1024; +select @@global.max_relay_log_size; + +start slave 'master2'; +--source include/wait_for_slave_to_start.inc +set default_master_connection = ''; + +--connection master2 +--save_master_pos + +--connection slave + +--sync_with_master 0,'master2' + +# If the skip_counter worked as expected, we should +# get here (replication shouldn't have broken) +# and should see both tables here +# (drop database which came from master2 shouldn't have been executed +# so t1 should still exist) + +show tables in db; + +# Cleanup + +drop database db; + +--eval set global sql_slave_skip_counter = $skip_counter_saved +--eval set global max_relay_log_size = $max_relay_log_size_saved +--eval set global max_binlog_size = $max_binlog_size_saved + +--source include/reset_master_slave.inc +--disconnect slave + +--connection master1 +drop database db; +--source include/reset_master_slave.inc +--disconnect master1 + +--connection master2 +drop database db; +--source include/reset_master_slave.inc +--disconnect master2 + diff --git a/mysql-test/suite/multi_source/status_vars.result b/mysql-test/suite/multi_source/status_vars.result new file mode 100644 index 00000000..35a58e0f --- /dev/null +++ b/mysql-test/suite/multi_source/status_vars.result @@ -0,0 +1,107 @@ +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +call mtr.add_suppression("Connection 'master1' already exists"); +change master 'master1' to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period = 25; +start slave 'master1'; +set default_master_connection = 'master1'; +include/wait_for_slave_to_start.inc +set default_master_connection = ''; +change master to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period=35; +start slave; +include/wait_for_slave_to_start.inc +# +# Check how status works for the default connection, anonymous or named +# +# Slave_running and Slave_heartbeat_period should be local for a connection +# +set default_master_connection = ''; +show status like 'Slave_running'; +Variable_name Value +Slave_running ON +show status like 'Slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 35.000 +stop slave io_thread; +include/wait_for_slave_io_to_stop.inc +show status like 'Slave_running'; +Variable_name Value +Slave_running OFF +set default_master_connection = 'master1'; +show status like 'Slave_running'; +Variable_name Value +Slave_running ON +show status like 'Slave_heartbeat_period'; +Variable_name Value +Slave_heartbeat_period 25.000 +# +# Slave_received_heartbeats should also be local +# +set default_master_connection = ''; +stop slave sql_thread; +include/wait_for_slave_sql_to_stop.inc +change master to master_heartbeat_period=1; +show status like 'Slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 0 +start slave; +include/wait_for_slave_to_start.inc +show status like 'Slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 2 +stop slave; +include/wait_for_slave_to_stop.inc +set default_master_connection = 'master1'; +show status like 'Slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 0 +stop slave; +include/wait_for_slave_to_stop.inc +change master to master_heartbeat_period=2; +start slave; +include/wait_for_slave_to_start.inc +show status like 'Slave_received_heartbeats'; +Variable_name Value +Slave_received_heartbeats 1 +# +# Slave_open_temp_tables should be global +# +set default_master_connection = ''; +start slave; +include/wait_for_slave_to_start.inc +connect master1,127.0.0.1,root,,,$SERVER_MYPORT_1; +set binlog_format = statement; +create temporary table tmp1 (i int) engine=MyISAM; +connection slave; +show status like 'Slave_open_temp_tables'; +Variable_name Value +Slave_open_temp_tables 1 +set default_master_connection = 'master1'; +show status like 'Slave_open_temp_tables'; +Variable_name Value +Slave_open_temp_tables 1 +connect master2,127.0.0.1,root,,,$SERVER_MYPORT_2; +set binlog_format = statement; +create temporary table tmp1 (i int) engine=MyISAM; +connection slave; +show status like 'Slave_open_temp_tables'; +Variable_name Value +Slave_open_temp_tables 2 +set default_master_connection = ''; +show status like 'Slave_open_temp_tables'; +Variable_name Value +Slave_open_temp_tables 2 +include/reset_master_slave.inc +disconnect slave; +connection master1; +include/reset_master_slave.inc +disconnect master1; +connection master2; +include/reset_master_slave.inc +disconnect master2; diff --git a/mysql-test/suite/multi_source/status_vars.test b/mysql-test/suite/multi_source/status_vars.test new file mode 100644 index 00000000..e76a403d --- /dev/null +++ b/mysql-test/suite/multi_source/status_vars.test @@ -0,0 +1,139 @@ +# +# Status variables related to a replication connection +# + +--source include/not_embedded.inc +--let $rpl_server_count= 0 + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +call mtr.add_suppression("Connection 'master1' already exists"); + +# Start replication from the first master + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +eval change master 'master1' to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period = 25; + +start slave 'master1'; +set default_master_connection = 'master1'; +--source include/wait_for_slave_to_start.inc + + +# Set up a proper 'default' connection to master2 + +set default_master_connection = ''; + +--replace_result $SERVER_MYPORT_2 MYPORT_2 +eval change master to +master_port=$SERVER_MYPORT_2, +master_host='127.0.0.1', +master_user='root', +master_heartbeat_period=35; + +start slave; +--source include/wait_for_slave_to_start.inc + +--echo # +--echo # Check how status works for the default connection, anonymous or named +--echo # + +--echo # Slave_running and Slave_heartbeat_period should be local for a connection +--echo # + +set default_master_connection = ''; +show status like 'Slave_running'; +show status like 'Slave_heartbeat_period'; +stop slave io_thread; +--source include/wait_for_slave_io_to_stop.inc +show status like 'Slave_running'; + +set default_master_connection = 'master1'; +show status like 'Slave_running'; +show status like 'Slave_heartbeat_period'; + +--echo # +--echo # Slave_received_heartbeats should also be local +--echo # + +set default_master_connection = ''; +stop slave sql_thread; +--source include/wait_for_slave_sql_to_stop.inc +change master to master_heartbeat_period=1; +show status like 'Slave_received_heartbeats'; +start slave; +--source include/wait_for_slave_to_start.inc + +--let $status_var = Slave_received_heartbeats +--let $status_var_value = 2 +# The units are tens of seconds +--let $status_timeout = 30 +--source include/wait_for_status_var.inc +show status like 'Slave_received_heartbeats'; +stop slave; +--source include/wait_for_slave_to_stop.inc + +set default_master_connection = 'master1'; +show status like 'Slave_received_heartbeats'; + +stop slave; +--source include/wait_for_slave_to_stop.inc +change master to master_heartbeat_period=2; +start slave; +--source include/wait_for_slave_to_start.inc + +--let $status_var = Slave_received_heartbeats +--let $status_var_value = 1 +--let $status_timeout = 30 +--source include/wait_for_status_var.inc +show status like 'Slave_received_heartbeats'; + + +--echo # +--echo # Slave_open_temp_tables should be global +--echo # + +set default_master_connection = ''; +start slave; +--source include/wait_for_slave_to_start.inc + +--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) +set binlog_format = statement; +create temporary table tmp1 (i int) engine=MyISAM; +--save_master_pos + +--connection slave +--sync_with_master 0,'master1' +show status like 'Slave_open_temp_tables'; + +set default_master_connection = 'master1'; +show status like 'Slave_open_temp_tables'; + +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) +set binlog_format = statement; +create temporary table tmp1 (i int) engine=MyISAM; +--save_master_pos + +--connection slave +--sync_with_master 0,'' +show status like 'Slave_open_temp_tables'; + +set default_master_connection = ''; +show status like 'Slave_open_temp_tables'; + + +# Cleanup + +--source include/reset_master_slave.inc +--disconnect slave +--connection master1 +--source include/reset_master_slave.inc +--disconnect master1 +--connection master2 +--source include/reset_master_slave.inc +--disconnect master2 + + diff --git a/mysql-test/suite/multi_source/syntax.result b/mysql-test/suite/multi_source/syntax.result new file mode 100644 index 00000000..35f4b304 --- /dev/null +++ b/mysql-test/suite/multi_source/syntax.result @@ -0,0 +1,84 @@ +include/master-slave.inc +[connection master] +show slave status; +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups +show slave '' status; +Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups +show all slaves status; +Connection_name Slave_SQL_State Slave_IO_State Master_Host Master_User Master_Port Connect_Retry Master_Log_File Read_Master_Log_Pos Relay_Log_File Relay_Log_Pos Relay_Master_Log_File Slave_IO_Running Slave_SQL_Running Replicate_Do_DB Replicate_Ignore_DB Replicate_Do_Table Replicate_Ignore_Table Replicate_Wild_Do_Table Replicate_Wild_Ignore_Table Last_Errno Last_Error Skip_Counter Exec_Master_Log_Pos Relay_Log_Space Until_Condition Until_Log_File Until_Log_Pos Master_SSL_Allowed Master_SSL_CA_File Master_SSL_CA_Path Master_SSL_Cert Master_SSL_Cipher Master_SSL_Key Seconds_Behind_Master Master_SSL_Verify_Server_Cert Last_IO_Errno Last_IO_Error Last_SQL_Errno Last_SQL_Error Replicate_Ignore_Server_Ids Master_Server_Id Master_SSL_Crl Master_SSL_Crlpath Using_Gtid Gtid_IO_Pos Replicate_Do_Domain_Ids Replicate_Ignore_Domain_Ids Parallel_Mode SQL_Delay SQL_Remaining_Delay Slave_SQL_Running_State Slave_DDL_Groups Slave_Non_Transactional_Groups Slave_Transactional_Groups Retried_transactions Max_relay_log_size Executed_log_entries Slave_received_heartbeats Slave_heartbeat_period Gtid_Slave_Pos +# +# Check error handling +# +show slave 'qqq' status; +ERROR HY000: There is no master connection 'qqq' +show slave 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' status; +ERROR HY000: There is no master connection 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' +show slave 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' status; +ERROR HY000: Incorrect arguments to MASTER_CONNECTION_NAME +change master 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' to master_host='dummy'; +ERROR HY000: Incorrect arguments to MASTER_CONNECTION_NAME +start slave 'qqq'; +ERROR HY000: There is no master connection 'qqq' +stop slave 'qqq'; +ERROR HY000: There is no master connection 'qqq' +flush slave 'qqq'; +ERROR HY000: There is no master connection 'qqq' +reset slave 'qqq'; +ERROR HY000: There is no master connection 'qqq' +select master_pos_wait('master-bin.999999',0,2,'qqq'); +master_pos_wait('master-bin.999999',0,2,'qqq') +NULL +Warnings: +Warning 1617 There is no master connection 'qqq' +select master_pos_wait('master-bin.999999',0,2,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'); +master_pos_wait('master-bin.999999',0,2,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc') +NULL +Warnings: +Warning 1210 Incorrect arguments to MASTER_CONNECTION_NAME +connection slave; +# +# checking usage of default_master_connection; +# +select @@default_master_connection; +@@default_master_connection + +select @@global.default_master_connection; +ERROR HY000: Variable 'default_master_connection' is a SESSION variable +set @@global.default_master_connection='qqq'; +ERROR HY000: Variable 'default_master_connection' is a SESSION variable and can't be used with SET GLOBAL +set @@default_master_connection='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'; +ERROR 42000: Variable 'default_master_connection' can't be set to the value of 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' +select @@default_master_connection; +@@default_master_connection + +set @@default_master_connection='qqq'; +select @@default_master_connection; +@@default_master_connection +qqq +show variables like "default_master_connection"; +Variable_name Value +default_master_connection qqq +show slave status; +ERROR HY000: There is no master connection 'qqq' +select master_pos_wait('master-bin.999999',0,2); +master_pos_wait('master-bin.999999',0,2) +NULL +Warnings: +Warning 1617 There is no master connection 'qqq' +set @@default_master_connection=''; +select master_pos_wait('master-bin.999999',0,2); +master_pos_wait('master-bin.999999',0,2) +-1 +set @@default_master_connection=''; +# +# checking variables +# +show status like "Slave_running"; +Variable_name Value +Slave_running ON +set @@default_master_connection='qqq'; +show status like "Slave_running"; +Variable_name Value +Slave_running +set @@default_master_connection=''; +include/rpl_end.inc diff --git a/mysql-test/suite/multi_source/syntax.test b/mysql-test/suite/multi_source/syntax.test new file mode 100644 index 00000000..12539d32 --- /dev/null +++ b/mysql-test/suite/multi_source/syntax.test @@ -0,0 +1,75 @@ +# Test multi master syntax + +--source include/not_embedded.inc +--source include/master-slave.inc + +# Check syntax of multi source replication + +show slave status; +show slave '' status; +show all slaves status; + +--echo # +--echo # Check error handling +--echo # + +--error WARN_NO_MASTER_INFO +show slave 'qqq' status; +--error WARN_NO_MASTER_INFO +show slave 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' status; +--error ER_WRONG_ARGUMENTS +show slave 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' status; +--error ER_WRONG_ARGUMENTS +change master 'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc' to master_host='dummy'; + +--error WARN_NO_MASTER_INFO +start slave 'qqq'; +--error WARN_NO_MASTER_INFO +stop slave 'qqq'; +--error WARN_NO_MASTER_INFO +flush slave 'qqq'; +--error WARN_NO_MASTER_INFO +reset slave 'qqq'; + +select master_pos_wait('master-bin.999999',0,2,'qqq'); +select master_pos_wait('master-bin.999999',0,2,'aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'); + +save_master_pos; +connection slave; +sync_with_master 0,''; +sync_with_master 0 ,''; +sync_with_master 0, ''; + +--echo # +--echo # checking usage of default_master_connection; +--echo # +select @@default_master_connection; + +--error 1238 +select @@global.default_master_connection; +--error 1228 +set @@global.default_master_connection='qqq'; +--error 1231 +set @@default_master_connection='aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaabbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbcccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccccc'; +select @@default_master_connection; +set @@default_master_connection='qqq'; +select @@default_master_connection; +show variables like "default_master_connection"; + +--error WARN_NO_MASTER_INFO +show slave status; +select master_pos_wait('master-bin.999999',0,2); +set @@default_master_connection=''; +select master_pos_wait('master-bin.999999',0,2); + +set @@default_master_connection=''; + +--echo # +--echo # checking variables +--echo # +show status like "Slave_running"; +set @@default_master_connection='qqq'; +show status like "Slave_running"; +set @@default_master_connection=''; + +--source include/rpl_end.inc |