diff options
Diffstat (limited to 'mysql-test/suite/multi_source')
48 files changed, 5902 insertions, 0 deletions
diff --git a/mysql-test/suite/multi_source/change_master.result b/mysql-test/suite/multi_source/change_master.result new file mode 100644 index 00000000..9fd84e51 --- /dev/null +++ b/mysql-test/suite/multi_source/change_master.result @@ -0,0 +1,8 @@ +RESET MASTER; +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +change master 'abc1' to relay_log_file=''; +ERROR HY000: Failed initializing relay log position: Could not find target log during relay log initialization +change master 'abc1' to relay_log_file=''; +ERROR HY000: Failed initializing relay log position: Could not find target log during relay log initialization +disconnect slave; +connection default; diff --git a/mysql-test/suite/multi_source/change_master.test b/mysql-test/suite/multi_source/change_master.test new file mode 100644 index 00000000..08e69096 --- /dev/null +++ b/mysql-test/suite/multi_source/change_master.test @@ -0,0 +1,13 @@ +--source include/not_embedded.inc + +RESET MASTER; + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +--error ER_RELAY_LOG_INIT +change master 'abc1' to relay_log_file=''; +--error ER_RELAY_LOG_INIT +change master 'abc1' to relay_log_file=''; +--disconnect slave +--connection default + 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..6530bb74 --- /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'; +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 = ''; +*** 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'; +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..9fc7a668 --- /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'; +--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 = ''; +--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'; +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..a35a20bd --- /dev/null +++ b/mysql-test/suite/multi_source/info_logs.result @@ -0,0 +1,130 @@ +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', +master_use_gtid=no; +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', +master_use_gtid=no; +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; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos' +# +# 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', +master_use_gtid=no; +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_Rewrite_DB 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_Rewrite_DB 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..f8352978 --- /dev/null +++ b/mysql-test/suite/multi_source/info_logs.test @@ -0,0 +1,203 @@ +# +# 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', +master_use_gtid=no; + +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', +master_use_gtid=no; + +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', +master_use_gtid=no; + +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..12bc251f --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-8874.result @@ -0,0 +1,135 @@ +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', master_use_gtid=no; +change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no; +change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no; +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 ; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos' +RESET SLAVE 'm2' ALL ; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos' +RESET SLAVE ALL ; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos' +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', master_use_gtid=no; +change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no; +change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no; +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 +RESET SLAVE ALL; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos' 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..1a99ae73 --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-8874.test @@ -0,0 +1,142 @@ +--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', master_use_gtid=no; +--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', master_use_gtid=no; +--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', master_use_gtid=no; +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', master_use_gtid=no; +--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', master_use_gtid=no; +--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', master_use_gtid=no; +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 +RESET SLAVE ALL; 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..452964fd --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-9544.result @@ -0,0 +1,93 @@ +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', master_use_gtid=no; +change master 'm2' to master_port=MYPORT_2 , master_host='127.0.0.1', master_user='root', master_use_gtid=no; +change master to master_port=MYPORT_3 , master_host='127.0.0.1', master_user='root', master_use_gtid=no; +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 +change master to master_use_gtid=slave_pos; +change master 'm1' to master_use_gtid=slave_pos; +change master 'm2' to master_use_gtid=slave_pos; 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..fd89bdfa --- /dev/null +++ b/mysql-test/suite/multi_source/mdev-9544.test @@ -0,0 +1,120 @@ +--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', master_use_gtid=no; +--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', master_use_gtid=no; +--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', master_use_gtid=no; +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 + +# Reset for check-testcase +change master to master_use_gtid=slave_pos; +change master 'm1' to master_use_gtid=slave_pos; +change master 'm2' to master_use_gtid=slave_pos; 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..2bbb3443 --- /dev/null +++ b/mysql-test/suite/multi_source/multi_parallel.test @@ -0,0 +1,126 @@ +# 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 +--source include/no_valgrind_without_big.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..355919de --- /dev/null +++ b/mysql-test/suite/multi_source/multi_source_slave_alias_replica.result @@ -0,0 +1,159 @@ +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_Rewrite_DB +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 Slave_Pos +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_Rewrite_DB +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 Slave_Pos +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..4b53b465 --- /dev/null +++ b/mysql-test/suite/multi_source/multisource.result @@ -0,0 +1,251 @@ +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', +master_use_gtid=no; +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' +# +# +# MDEV:16437: merge 5.7 P_S replication instrumentation and tables +# +SELECT * FROM performance_schema.replication_applier_status_by_coordinator; +CHANNEL_NAME master1 +THREAD_ID # +SERVICE_STATE ON +LAST_ERROR_NUMBER 0 +LAST_ERROR_MESSAGE +LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00 +LAST_SEEN_TRANSACTION 0-1-7 +LAST_TRANS_RETRY_COUNT 0 +CHANNEL_NAME +THREAD_ID # +SERVICE_STATE ON +LAST_ERROR_NUMBER 0 +LAST_ERROR_MESSAGE +LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00 +LAST_SEEN_TRANSACTION 0-2-4 +LAST_TRANS_RETRY_COUNT 0 +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/multisource_for_channel.result b/mysql-test/suite/multi_source/multisource_for_channel.result new file mode 100644 index 00000000..9b4efae0 --- /dev/null +++ b/mysql-test/suite/multi_source/multisource_for_channel.result @@ -0,0 +1,374 @@ +RESET MASTER; +connect slave,127.0.0.1,root,,,$SERVER_MYPORT_3; +change master to relay_log_file='' for channel 'abc1'; +ERROR HY000: Failed initializing relay log position: Could not find target log during relay log initialization +change master to master_host='' for channel 'abc2'; +ERROR HY000: Incorrect arguments to MASTER_HOST +change master to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root', +master_use_gtid=no +for channel 'master1'; +start slave for channel '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 to +master_port=MYPORT_2, +master_host='127.0.0.1', +master_user='root' +for channel 'master1'; +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 to +master_port=MYPORT_1, +master_host='127.0.0.1', +master_user='root' for channel 'master2'; +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', +master_use_gtid=no; +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' +# +# +# MDEV:16437: merge 5.7 P_S replication instrumentation and tables +# +SELECT * FROM performance_schema.replication_applier_status_by_coordinator; +CHANNEL_NAME master1 +THREAD_ID # +SERVICE_STATE ON +LAST_ERROR_NUMBER 0 +LAST_ERROR_MESSAGE +LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00 +LAST_SEEN_TRANSACTION 0-1-7 +LAST_TRANS_RETRY_COUNT 0 +CHANNEL_NAME +THREAD_ID # +SERVICE_STATE ON +LAST_ERROR_NUMBER 0 +LAST_ERROR_MESSAGE +LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00 +LAST_SEEN_TRANSACTION 0-2-4 +LAST_TRANS_RETRY_COUNT 0 +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 + +# +# syntax compatible test +# + +# +# show relaylog events +# +SHOW RELAYLOG EVENTS for channel 'master1'; +Log_name Pos Event_type Server_id End_log_pos Info +mysqld-relay-bin-master1.000003 4 Format_desc 3 256 Server ver: Version +mysqld-relay-bin-master1.000003 256 Rotate 1 1358 master-bin.000002;pos=4 +mysqld-relay-bin-master1.000003 304 Rotate 3 366 mysqld-relay-bin-master1.000004;pos=4 + +show slave status for channel 'master1' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000004' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_SQL_Errno = '0' + +# +# stop slave +# +STOP SLAVE for channel 'master1'; + +show slave status for channel 'master1' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000004' +Slave_IO_Running = 'No' +Slave_SQL_Running = 'No' +Last_Errno = '0' +Last_SQL_Errno = '0' + +# +# start slave +# +START SLAVE for channel 'master1'; +include/wait_for_slave_to_start.inc +connection master1; +create table foo (a int); +drop table foo; +connection slave; + +show slave status for channel 'master1' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000005' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_SQL_Errno = '0' + +# +# flush relay logs +# +FLUSH RELAY LOGS for channel 'master1'; + +show slave status for channel 'master1' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000006' +Slave_IO_Running = 'Yes' +Slave_SQL_Running = 'Yes' +Last_Errno = '0' +Last_SQL_Errno = '0' + +# +# stop slave +# +STOP SLAVE for channel 'master1'; + +show slave status for channel 'master1' +Master_Port = 'MYPORT_1' +Relay_Log_File = 'mysqld-relay-bin-master1.000006' +Slave_IO_Running = 'No' +Slave_SQL_Running = 'No' +Last_Errno = '0' +Last_SQL_Errno = '0' + +# +# reset slave +# +RESET SLAVE for channel 'master1'; +Warnings: +Note 4190 RESET SLAVE is implicitly changing the value of 'Using_Gtid' from 'No' to 'Slave_Pos' + +show slave status for channel 'master1' +Master_Port = 'MYPORT_1' +Relay_Log_File = '' +Slave_IO_Running = 'No' +Slave_SQL_Running = 'No' +Last_Errno = '0' +Last_SQL_Errno = '0' + +# +# show relaylog events after reset slave +# +SHOW RELAYLOG EVENTS for channel 'master1'; +Log_name Pos Event_type Server_id End_log_pos Info + +# +# check error syntax +# +RESET SLAVE 'master1' for channel 'mmaster2'; +ERROR HY000: Incorrect arguments to CONNECTION_NAME AND FOR CHANNEL CAN NOT BE SPECIFIED AT THE SAME TIME) +STOP SLAVE 'master1' for channel 'master2'; +ERROR HY000: Incorrect arguments to CONNECTION_NAME AND FOR CHANNEL CAN NOT BE SPECIFIED AT THE SAME TIME) +FLUSH RELAY LOGS 'master1' for channel 'master2'; +ERROR HY000: Incorrect arguments to CONNECTION_NAME AND FOR CHANNEL CAN NOT BE SPECIFIED AT THE SAME TIME) +START SLAVE 'master1' for channel 'master2'; +ERROR HY000: Incorrect arguments to CONNECTION_NAME AND FOR CHANNEL CAN NOT BE SPECIFIED AT THE SAME TIME) +SHOW RELAYLOG 'master1' EVENTS for channel 'master2'; +ERROR HY000: Incorrect arguments to CONNECTION_NAME AND FOR CHANNEL CAN NOT BE SPECIFIED AT THE SAME TIME) +SHOW SLAVE 'master1' STATUS for channel 'master2'; +ERROR HY000: Incorrect arguments to CONNECTION_NAME AND FOR CHANNEL CAN NOT BE SPECIFIED AT THE SAME TIME) + +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; +connection default; +CREATE TABLE channel (channel int); +DROP TABLE channel; diff --git a/mysql-test/suite/multi_source/multisource_for_channel.test b/mysql-test/suite/multi_source/multisource_for_channel.test new file mode 100644 index 00000000..b3feb4b9 --- /dev/null +++ b/mysql-test/suite/multi_source/multisource_for_channel.test @@ -0,0 +1,440 @@ +# +# This is the basic test of support mysql syntax "for channel" used for +# multi-source replication +# +# Test basic replication functionality in multi-source setup +# + +--source include/not_embedded.inc +--source include/have_innodb.inc +--source include/have_perfschema.inc +--source include/binlog_start_pos.inc +--let $rpl_server_count= 0 + +RESET MASTER; + +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +# MDEV-3984: crash/read of freed memory when changing master with named connection +# This fails after adding the new master 'abc1', check we do not free twice. +--error ER_RELAY_LOG_INIT +change master to relay_log_file='' for channel 'abc1'; +# This fails before adding the new master, check that we do free it. +--error ER_WRONG_ARGUMENTS +change master to master_host='' for channel 'abc2'; + +# Start replication from the first master + +--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', +master_use_gtid=no +for channel 'master1'; + +start slave for channel 'master1'; +set default_master_connection = 'master1'; +--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 0,'master1' + +# Here and further: add an extra check on SQL thread status +# as the normal sync is not always enough +--source include/wait_for_sql_thread_read_all.inc + +# each of the 3 commands should produce +# 'master1' status + +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 + +--echo # +--echo # Checking SHOW SLAVE 'master1' STATUS +--echo # +--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ +--let $slave_name= 'master1' +--let for_channel= 1 +--source include/show_slave_status.inc +--let $slave_name= +--let for_channel= + +--echo # +--echo # Checking SHOW SLAVE STATUS +--echo # +--source include/show_slave_status.inc + +--echo # +--echo # Checking SHOW ALL SLAVES STATUS +--echo # +--let $all_slaves_status= 1 +--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period +--source include/show_slave_status.inc +--let $all_slaves_status= +--echo # + + +# Check that replication actually works + +--connection master1 + +--disable_warnings +drop database if exists db1; +--enable_warnings +create database db1; +use db1; +create table t1 (i int auto_increment, f1 varchar(16), primary key pk (i,f1)) engine=MyISAM; +insert into t1 (f1) values ('one'),('two'); +--save_master_pos + +--connection slave +--sync_with_master 0,'master1' + +--sorted_result +select * from db1.t1; + +--let $datadir = `SELECT @@datadir` + +--echo # List of relay log files in the datadir +--list_files $datadir mysqld-relay-bin-master1.* + +# Check that relay logs are recognizable + +let binlog_start=4; +let binlog_file=; +source include/show_relaylog_events.inc; +let binlog_file= mysqld-relay-bin-master1.000002; +source include/show_relaylog_events.inc; + +# Try to configure connection with the same name again, +# should get an error because the slave is running + +--replace_result $SERVER_MYPORT_2 MYPORT_2 +--error ER_SLAVE_MUST_STOP +eval change master to +master_port=$SERVER_MYPORT_2, +master_host='127.0.0.1', +master_user='root' +for channel 'master1'; + +# Try to configure using the default connection name +# (which is 'master1' at the moment), +# again, should get an error + +--replace_result $SERVER_MYPORT_2 MYPORT_2 +--error ER_SLAVE_MUST_STOP +eval change master to +master_port=$SERVER_MYPORT_2, +master_host='127.0.0.1', +master_user='root'; + +# Try to configure a connection with the same master +# using a different name, should get a conflict + +--replace_result $SERVER_MYPORT_1 MYPORT_1 +--error ER_CONNECTION_ALREADY_EXISTS +eval change master to +master_port=$SERVER_MYPORT_1, +master_host='127.0.0.1', +master_user='root' for channel 'master2'; + + +# 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_use_gtid=no; + +start slave; +--source include/wait_for_slave_to_start.inc + +--source include/wait_for_sql_thread_read_all.inc + +# See both connections in the same status output + +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 + +--echo # +--echo # Checking SHOW ALL SLAVES STATUS +--echo # +--let $all_slaves_status= 1 +--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/ +--source include/show_slave_status.inc +--let $all_slaves_status= +--echo # + +# Check that replication from two servers actually works + +--connection master1 + +insert into t1 (f1) values ('three'); +--save_master_pos + +--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) + +--disable_warnings +drop database if exists db2; +--enable_warnings +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 +--sync_with_master 0,'master1' + +--connection master2 +--save_master_pos + +--connection slave +--sync_with_master 0 +--sorted_result +select * from db1.t1; +select * from db2.t1; + +--connection master2 +commit; +--save_master_pos + +--connection slave +--sync_with_master 0 +--sorted_result +select * from db2.t1; + +# Flush and purge logs on one master, +# make sure slaves don't get confused + +--connection master1 +flush logs; +--source include/wait_for_binlog_checkpoint.inc +--save_master_pos +--connection slave +--sync_with_master 0, 'master1' + +--connection master1 +purge binary logs to 'master-bin.000002'; +# Additional events: 43 (Gtid_list) + 2 x 44 (Binlog_checkpoint) = 131 +let filesize=`select $binlog_start_pos+131`; +--replace_result $filesize filesize +show binary logs; +insert into t1 (f1) values ('four'); +create table db1.t3 (f1 int) engine=InnoDB; +--save_master_pos + +--connection slave +--sync_with_master 0,'master1' + +--source include/wait_for_sql_thread_read_all.inc + +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 + +--echo # +--echo # Checking SHOW ALL SLAVES STATUS +--echo # +--let $all_slaves_status= 1 +--let $status_items= Connection_name, Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno, Slave_heartbeat_period +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /$SERVER_MYPORT_2/MYPORT_2/ +--source include/show_slave_status.inc +--let $all_slaves_status= +--echo # + +--echo # +--echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables +--echo # +--replace_column 2 # +query_vertical SELECT * FROM performance_schema.replication_applier_status_by_coordinator; + +--sorted_result +select * from db1.t1; + +# This should show relay log events for the default master +# (the one with the empty name) +let binlog_file=; +source include/show_relaylog_events.inc; +let binlog_file= mysqld-relay-bin.000002; +source include/show_relaylog_events.inc; + +# Make sure we don't lose control over replication connections +# after reconnecting to the slave + +--disconnect slave +--connect (slave,127.0.0.1,root,,,$SERVER_MYPORT_3) + +stop slave io_thread; +show status like 'Slave_running'; +set default_master_connection = 'master1'; +show status like 'Slave_running'; + +--echo +--echo # +--echo # syntax compatible test +--echo # +--echo +--echo # +--echo # show relaylog events +--echo # +--replace_regex /Server ver:.*/Server ver: Version/ +SHOW RELAYLOG EVENTS for channel 'master1'; + +--echo +--echo show slave status for channel 'master1' +--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ +--let $slave_name= 'master1' +--let $for_channel= 1 +--source include/show_slave_status.inc + +--echo +--echo # +--echo # stop slave +--echo # +STOP SLAVE for channel 'master1'; + +--echo +--echo show slave status for channel 'master1' +--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ +--let $slave_name= 'master1' +--let $for_channel= 1 +--source include/show_slave_status.inc + +--echo +--echo # +--echo # start slave +--echo # +START SLAVE for channel 'master1'; +--source include/wait_for_slave_to_start.inc + +# Force some data into the relay log to ensure that we get a new relay log +--connection master1 +create table foo (a int); +drop table foo; +--save_master_pos +--connection slave +--sync_with_master 0,'master1' +--source include/wait_for_sql_thread_read_all.inc + +--echo +--echo show slave status for channel 'master1' +--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ /Preparing/Yes/ +--let $slave_name= 'master1' +--let $for_channel= 1 +--source include/show_slave_status.inc + +--echo +--echo # +--echo # flush relay logs +--echo # +FLUSH RELAY LOGS for channel 'master1'; +--source include/wait_for_sql_thread_read_all.inc + +--echo +--echo show slave status for channel 'master1' +--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ +--let $slave_name= 'master1' +--let $for_channel= 1 +--source include/show_slave_status.inc + +--echo +--echo # +--echo # stop slave +--echo # +STOP SLAVE for channel 'master1'; + +--echo +--echo show slave status for channel 'master1' +--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ +--let $slave_name= 'master1' +--let $for_channel= 1 +--source include/show_slave_status.inc + +--echo +--echo # +--echo # reset slave +--echo # +RESET SLAVE for channel 'master1'; + +--echo +--echo show slave status for channel 'master1' +--let $status_items= Master_Port, Relay_Log_File, Slave_IO_Running, Slave_SQL_Running, Last_Errno, Last_SQL_Errno +--let $slave_field_result_replace= /$SERVER_MYPORT_1/MYPORT_1/ +--let $slave_name= 'master1' +--let $for_channel= 1 +--source include/show_slave_status.inc + +--echo +--echo # +--echo # show relaylog events after reset slave +--echo # +SHOW RELAYLOG EVENTS for channel 'master1'; + +--let $slave_name= +--let for_channel= + +--echo +--echo # +--echo # check error syntax +--echo # +--error ER_WRONG_ARGUMENTS +RESET SLAVE 'master1' for channel 'mmaster2'; +--error ER_WRONG_ARGUMENTS +STOP SLAVE 'master1' for channel 'master2'; +--error ER_WRONG_ARGUMENTS +FLUSH RELAY LOGS 'master1' for channel 'master2'; +--error ER_WRONG_ARGUMENTS +START SLAVE 'master1' for channel 'master2'; +--error ER_WRONG_ARGUMENTS +SHOW RELAYLOG 'master1' EVENTS for channel 'master2'; +--error ER_WRONG_ARGUMENTS +SHOW SLAVE 'master1' STATUS for channel 'master2'; + +--echo +# Cleanup +drop database db1; +drop database db2; + +--source include/reset_master_slave.inc +--disconnect slave + +--connection master1 +drop database db1; +--source include/reset_master_slave.inc +--disconnect master1 + +--connection master2 +drop database db2; +--source include/reset_master_slave.inc +--disconnect master2 + +# +# Check channel as a keyword +# +--connection default +CREATE TABLE channel (channel int); +DROP TABLE channel; 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/replicate_rewrite_db_dynamic.cnf b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.cnf new file mode 100644 index 00000000..a22ddacd --- /dev/null +++ b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.cnf @@ -0,0 +1,19 @@ +!include my.cnf + +[mysqld.1] +gtid-domain-id=1 +server-id=1 +log-bin +log-slave-updates + +[mysqld.2] +gtid-domain-id=2 +server-id=2 +log-bin +log-slave-updates + +[mysqld.3] +gtid-domain-id=3 +server-id=3 +log-bin +log-slave-updates diff --git a/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.result b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.result new file mode 100644 index 00000000..3be8b364 --- /dev/null +++ b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.result @@ -0,0 +1,67 @@ +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 the slave (server_3) to two masters (server_1 and server_2) +connection server_3; +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'; +# Apply events from server_1 (m1) into m1_test +create database m1_test; +SET @@global.'m1'.replicate_rewrite_db='test->m1_test'; +# Apply events from server_2 (m2) into m2_test +create database m2_test; +SET @@global.'m2'.replicate_rewrite_db='test->m2_test'; +start all slaves; +Warnings: +Note 1937 SLAVE 'm2' 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 +# Create test data for servers 1 and 2 with different data +connection server_1; +create table t (a int); +insert into t values (1); +insert into t values (2); +insert into t values (3); +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +connection server_2; +create table t (a int); +insert into t values (4); +insert into t values (5); +insert into t values (6); +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +# Ensure the slave correctly replicates data from each master into its +# respective database +include/diff_tables.inc [server_1:test.t,server_3:m1_test.t] +include/diff_tables.inc [server_2:test.t,server_3:m2_test.t] +# +# Cleanup +connection server_1; +DROP TABLE t; +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +connection server_2; +DROP TABLE t; +include/save_master_gtid.inc +connection server_3; +include/sync_with_master_gtid.inc +connection server_3; +stop all slaves; +Warnings: +Note 1938 SLAVE 'm2' 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 +RESET SLAVE ALL; +DROP DATABASE m1_test; +DROP DATABASE m2_test; +# End of replicate_rewrite_db_dynamic.test diff --git a/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.test b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.test new file mode 100644 index 00000000..e1bbfabe --- /dev/null +++ b/mysql-test/suite/multi_source/replicate_rewrite_db_dynamic.test @@ -0,0 +1,96 @@ +# +# Test multi-source dynamically setting of replication filter +# "replicate_rewrite_db" +# +# This test ensures that setting a replica's replicate_rewrite_db works on a +# per-master basis. To ensure this, this test connects a replica to two +# different primary server instances. Each primary uses the same database +# name and table name. To ensure the data operations don't interfere with one +# another on the replica, it sets replicate_rewrite_db individually per +# connection to apply the events from each primary into a database specific to +# that connection. +# + +--source include/not_embedded.inc +--source include/have_innodb.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) + + +--echo # Connect the slave (server_3) to two masters (server_1 and server_2) +--connection server_3 +--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'; + +--echo # Apply events from server_1 (m1) into m1_test +create database m1_test; +SET @@global.'m1'.replicate_rewrite_db='test->m1_test'; + +--echo # Apply events from server_2 (m2) into m2_test +create database m2_test; +SET @@global.'m2'.replicate_rewrite_db='test->m2_test'; + +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 + +--echo # Create test data for servers 1 and 2 with different data +--connection server_1 +create table t (a int); +insert into t values (1); +insert into t values (2); +insert into t values (3); +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--connection server_2 +create table t (a int); +insert into t values (4); +insert into t values (5); +insert into t values (6); +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--echo # Ensure the slave correctly replicates data from each master into its +--echo # respective database +--let $diff_tables=server_1:test.t,server_3:m1_test.t +--source include/diff_tables.inc + +--let $diff_tables=server_2:test.t,server_3:m2_test.t +--source include/diff_tables.inc + + +--echo # +--echo # Cleanup + +--connection server_1 +DROP TABLE t; +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--connection server_2 +DROP TABLE t; +--source include/save_master_gtid.inc +--connection server_3 +--source include/sync_with_master_gtid.inc + +--connection server_3 +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 +RESET SLAVE ALL; +DROP DATABASE m1_test; +DROP DATABASE m2_test; + +--echo # End of replicate_rewrite_db_dynamic.test 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..2e9ce5e8 --- /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_Rewrite_DB 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 Slave_Pos 0-1-3 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_Rewrite_DB 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 Slave_Pos 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..34b42ae6 --- /dev/null +++ b/mysql-test/suite/multi_source/reset_slave.test @@ -0,0 +1,74 @@ +# +# 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 + 608`; +let relay_log_pos=`select 2*$binlog_start_pos + 652`; +let relay_log_space=`select 3*$binlog_start_pos + 714`; + +--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..65c25b88 --- /dev/null +++ b/mysql-test/suite/multi_source/simple.result @@ -0,0 +1,530 @@ +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 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_Rewrite_DB +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 Slave_Pos +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_Rewrite_DB +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 Slave_Pos +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 +# +# MDEV:16437: merge 5.7 P_S replication instrumentation and tables +# +select * from performance_schema.replication_connection_configuration; +CHANNEL_NAME slave2 +HOST 127.0.0.1 +PORT # +USER root +USING_GTID SLAVE_POS +SSL_ALLOWED NO +SSL_CA_FILE +SSL_CA_PATH +SSL_CERTIFICATE +SSL_CIPHER +SSL_KEY +SSL_VERIFY_SERVER_CERTIFICATE NO +SSL_CRL_FILE +SSL_CRL_PATH +CONNECTION_RETRY_INTERVAL 60 +CONNECTION_RETRY_COUNT 100000 +HEARTBEAT_INTERVAL 60.000 +IGNORE_SERVER_IDS +REPL_DO_DOMAIN_IDS +REPL_IGNORE_DOMAIN_IDS +CHANNEL_NAME slave1 +HOST 127.0.0.1 +PORT # +USER root +USING_GTID SLAVE_POS +SSL_ALLOWED NO +SSL_CA_FILE +SSL_CA_PATH +SSL_CERTIFICATE +SSL_CIPHER +SSL_KEY +SSL_VERIFY_SERVER_CERTIFICATE NO +SSL_CRL_FILE +SSL_CRL_PATH +CONNECTION_RETRY_INTERVAL 60 +CONNECTION_RETRY_COUNT 100000 +HEARTBEAT_INTERVAL 60.000 +IGNORE_SERVER_IDS +REPL_DO_DOMAIN_IDS +REPL_IGNORE_DOMAIN_IDS +start all slaves; +# +# MDEV:16437: merge 5.7 P_S replication instrumentation and tables +# +select * from performance_schema.replication_applier_status_by_coordinator; +CHANNEL_NAME slave2 +THREAD_ID # +SERVICE_STATE ON +LAST_ERROR_NUMBER 0 +LAST_ERROR_MESSAGE +LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00 +LAST_SEEN_TRANSACTION +LAST_TRANS_RETRY_COUNT 0 +CHANNEL_NAME slave1 +THREAD_ID # +SERVICE_STATE ON +LAST_ERROR_NUMBER 0 +LAST_ERROR_MESSAGE +LAST_ERROR_TIMESTAMP 0000-00-00 00:00:00 +LAST_SEEN_TRANSACTION +LAST_TRANS_RETRY_COUNT 0 +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_Rewrite_DB +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 Slave_Pos +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 slave1 +Slave_SQL_State +Slave_IO_State +Master_Host 127.0.0.1 +Master_User root +Master_Port MYPORT_1 +Connect_Retry 60 +Master_Log_File +Read_Master_Log_Pos 4 +Relay_Log_File +Relay_Log_Pos <relay_log_pos> +Relay_Master_Log_File +Slave_IO_Running No +Slave_SQL_Running No +Replicate_Rewrite_DB +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 0 +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 Slave_Pos +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 +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_Rewrite_DB +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 Slave_Pos +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 +reset slave 'slave1' all; +show all slaves status; +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_Rewrite_DB +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 Slave_Pos +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 +stop all slaves; +Warnings: +Note 1938 SLAVE 'slave2' stopped +show all slaves status; +Connection_name slave2 +Slave_SQL_State +Slave_IO_State +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 No +Slave_SQL_Running No +Replicate_Rewrite_DB +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 2 +Master_SSL_Crl +Master_SSL_Crlpath +Using_Gtid Slave_Pos +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 +Retried_transactions 0 +Max_relay_log_size 1073741824 +Executed_log_entries 7 +Slave_received_heartbeats 0 +Slave_heartbeat_period 60.000 +Gtid_Slave_Pos +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..070d4745 --- /dev/null +++ b/mysql-test/suite/multi_source/simple.test @@ -0,0 +1,99 @@ +# +# Simple multi-master test +# + +--source include/not_embedded.inc +--source include/binlog_start_pos.inc +--source include/have_perfschema.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> +query_vertical show all slaves status; + +--echo # +--echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables +--echo # +--replace_column 3 # +query_vertical select * from performance_schema.replication_connection_configuration; + +# Ensure that start all slaves doesn't do anything as all slaves are started +start all slaves; + +--echo # +--echo # MDEV:16437: merge 5.7 P_S replication instrumentation and tables +--echo # +--replace_column 2 # +query_vertical select * from performance_schema.replication_applier_status_by_coordinator; + +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> +query_vertical 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> +query_vertical 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> +query_vertical 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..4573d54c --- /dev/null +++ b/mysql-test/suite/multi_source/skip_counter.result @@ -0,0 +1,129 @@ +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', +master_use_gtid=no; +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', +master_use_gtid=no; +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..e89480f5 --- /dev/null +++ b/mysql-test/suite/multi_source/skip_counter.test @@ -0,0 +1,151 @@ +# +# 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', +master_use_gtid=no; + +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', +master_use_gtid=no; + +# 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..3c7c91c3 --- /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_Rewrite_DB 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_Rewrite_DB 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_Rewrite_DB 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 |