| 1 |
--source include/not_embedded.inc |
| 2 |
--source include/have_innodb.inc |
| 3 |
|
| 4 |
# |
| 5 |
# Test multiple mysql.gtid_slave_posXXX tables with multiple master connections |
| 6 |
# |
| 7 |
|
| 8 |
--connect (slave1,127.0.0.1,root,,,$SERVER_MYPORT_3) |
| 9 |
--connect (master1,127.0.0.1,root,,,$SERVER_MYPORT_1) |
| 10 |
--connect (master2,127.0.0.1,root,,,$SERVER_MYPORT_2) |
| 11 |
|
| 12 |
--connection slave1 |
| 13 |
--replace_result $SERVER_MYPORT_1 MYPORT_1 |
| 14 |
eval CHANGE MASTER 'slave1' TO master_port=$SERVER_MYPORT_1, master_host='127.0.0.1', master_user='root', master_ssl_verify_server_cert=0, master_use_gtid=slave_pos; |
| 15 |
--replace_result $SERVER_MYPORT_2 MYPORT_2 |
| 16 |
eval CHANGE MASTER 'slave2' TO master_port=$SERVER_MYPORT_2, master_host='127.0.0.1', master_user='root', master_ssl_verify_server_cert=0, master_use_gtid=slave_pos; |
| 17 |
set default_master_connection = 'slave1'; |
| 18 |
START SLAVE; |
| 19 |
--source include/wait_for_slave_to_start.inc |
| 20 |
set default_master_connection = 'slave2'; |
| 21 |
START SLAVE; |
| 22 |
--source include/wait_for_slave_to_start.inc |
| 23 |
set default_master_connection = ''; |
| 24 |
|
| 25 |
|
| 26 |
--connection master1 |
| 27 |
SET GLOBAL gtid_domain_id= 1; |
| 28 |
SET SESSION gtid_domain_id= 1; |
| 29 |
CREATE TABLE t3 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; |
| 30 |
CREATE TABLE t1 (a INT PRIMARY KEY, b VARCHAR(10)); |
| 31 |
INSERT INTO t1 VALUES (1, "initial"); |
| 32 |
INSERT INTO t3 VALUES (101, "initial 1"); |
| 33 |
--source include/save_master_gtid.inc |
| 34 |
|
| 35 |
--connection master2 |
| 36 |
SET GLOBAL gtid_domain_id= 2; |
| 37 |
SET SESSION gtid_domain_id= 2; |
| 38 |
CREATE TABLE t2 (a INT PRIMARY KEY, b VARCHAR(10)) ENGINE=InnoDB; |
| 39 |
INSERT INTO t2 VALUES (1, "initial"); |
| 40 |
|
| 41 |
|
| 42 |
--connection slave1 |
| 43 |
--source include/sync_with_master_gtid.inc |
| 44 |
|
| 45 |
--connection master2 |
| 46 |
--source include/save_master_gtid.inc |
| 47 |
|
| 48 |
--connection slave1 |
| 49 |
--source include/sync_with_master_gtid.inc |
| 50 |
|
| 51 |
|
| 52 |
--echo *** Add an innodb gtid_slave_pos table. It is not used yet as slaves are already running *** |
| 53 |
|
| 54 |
SET sql_log_bin=0; |
| 55 |
CREATE TABLE mysql.gtid_slave_pos_innodb LIKE mysql.gtid_slave_pos; |
| 56 |
ALTER TABLE mysql.gtid_slave_pos_innodb ENGINE=InnoDB; |
| 57 |
SET sql_log_bin=0; |
| 58 |
|
| 59 |
--connection master1 |
| 60 |
INSERT INTO t3 VALUES (102, "secondary"); |
| 61 |
--source include/save_master_gtid.inc |
| 62 |
|
| 63 |
--connection slave1 |
| 64 |
--source include/sync_with_master_gtid.inc |
| 65 |
SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; |
| 66 |
SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos_innodb GROUP BY domain_id; |
| 67 |
|
| 68 |
--echo *** Restart one slave thread, the other keeps running. Now the new table is used *** |
| 69 |
--connection slave1 |
| 70 |
set default_master_connection = 'slave1'; |
| 71 |
STOP SLAVE; |
| 72 |
--source include/wait_for_slave_to_stop.inc |
| 73 |
START SLAVE; |
| 74 |
--source include/wait_for_slave_to_start.inc |
| 75 |
|
| 76 |
# Send through a transaction on the slave1 connection, to be sure that it has |
| 77 |
# had time to update the state with the new table. |
| 78 |
--connection master1 |
| 79 |
INSERT INTO t1 VALUES (2, "followup"); |
| 80 |
--source include/save_master_gtid.inc |
| 81 |
--connection slave1 |
| 82 |
--source include/sync_with_master_gtid.inc |
| 83 |
|
| 84 |
--connection master2 |
| 85 |
INSERT INTO t2 VALUES (2, "secondary2"); |
| 86 |
--source include/save_master_gtid.inc |
| 87 |
|
| 88 |
--connection slave1 |
| 89 |
--source include/sync_with_master_gtid.inc |
| 90 |
SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; |
| 91 |
SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos_innodb GROUP BY domain_id; |
| 92 |
|
| 93 |
--echo *** Remove a gtid_slave_posXXX table, restart one slave *** |
| 94 |
--echo *** Get a warning that the change is not yet picked up *** |
| 95 |
--echo *** See that updates fail due to trying to use the missing table *** |
| 96 |
--connection slave1 |
| 97 |
SET sql_log_bin=0; |
| 98 |
DROP TABLE mysql.gtid_slave_pos_innodb; |
| 99 |
SET sql_log_bin=1; |
| 100 |
set default_master_connection = 'slave2'; |
| 101 |
STOP SLAVE; |
| 102 |
--source include/wait_for_slave_to_stop.inc |
| 103 |
START SLAVE; |
| 104 |
--source include/wait_for_slave_to_start.inc |
| 105 |
CALL mtr.add_suppression("The table mysql.gtid_slave_pos_innodb was removed."); |
| 106 |
|
| 107 |
--connection master2 |
| 108 |
INSERT INTO t2 VALUES (3, "tertiary 2"); |
| 109 |
|
| 110 |
--connection slave1 |
| 111 |
--let $slave_sql_errno= 1942 |
| 112 |
--source include/wait_for_slave_sql_error.inc |
| 113 |
SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; |
| 114 |
|
| 115 |
--echo *** Stop both slaves, see that the drop of mysql.gtid_slave_pos_innodb is now picked up *** |
| 116 |
--connection slave1 |
| 117 |
set default_master_connection = 'slave1'; |
| 118 |
STOP SLAVE; |
| 119 |
--source include/wait_for_slave_to_stop.inc |
| 120 |
set default_master_connection = 'slave2'; |
| 121 |
--let $slave_sql_errno= 1942 |
| 122 |
--source include/wait_for_slave_sql_error.inc |
| 123 |
STOP SLAVE; |
| 124 |
--source include/wait_for_slave_io_to_stop.inc |
| 125 |
set default_master_connection = 'slave1'; |
| 126 |
START SLAVE; |
| 127 |
--source include/wait_for_slave_to_start.inc |
| 128 |
# Send through a transaction on the slave1 connection, to be sure that it has |
| 129 |
# had time to update the state with the new table. |
| 130 |
--connection master1 |
| 131 |
INSERT INTO t1 VALUES (3, "more stuff"); |
| 132 |
--source include/save_master_gtid.inc |
| 133 |
--connection slave1 |
| 134 |
--source include/sync_with_master_gtid.inc |
| 135 |
set default_master_connection = 'slave2'; |
| 136 |
START SLAVE; |
| 137 |
--source include/wait_for_slave_to_start.inc |
| 138 |
|
| 139 |
--connection master2 |
| 140 |
--source include/save_master_gtid.inc |
| 141 |
--connection slave1 |
| 142 |
--source include/sync_with_master_gtid.inc |
| 143 |
SELECT * FROM t1 ORDER BY a; |
| 144 |
SELECT * FROM t2 ORDER BY a; |
| 145 |
SELECT * FROM t3 ORDER BY a; |
| 146 |
SELECT domain_id, max(seq_no) FROM mysql.gtid_slave_pos GROUP BY domain_id; |
| 147 |
|
| 148 |
|
| 149 |
# Cleanup. |
| 150 |
--connection master1 |
| 151 |
DROP TABLE t1; |
| 152 |
DROP TABLE t3; |
| 153 |
|
| 154 |
--connection master2 |
| 155 |
DROP TABLE t2; |
| 156 |
|
| 157 |
--connection slave1 |
| 158 |
SET GLOBAL gtid_domain_id=0; |
| 159 |
--let $wait_condition= SELECT COUNT(*)=0 FROM information_schema.tables WHERE table_name IN ("t1", "t2", "t3") AND table_schema = "test" |
| 160 |
--source include/wait_condition.inc |
| 161 |
--sorted_result |
| 162 |
STOP ALL SLAVES; |
| 163 |
--source include/reset_master_slave.inc |
| 164 |
--disconnect slave1 |
| 165 |
|
| 166 |
|
| 167 |
--connection master1 |
| 168 |
SET GLOBAL gtid_domain_id=0; |
| 169 |
--source include/reset_master_slave.inc |
| 170 |
--disconnect master1 |
| 171 |
|
| 172 |
--connection master2 |
| 173 |
SET GLOBAL gtid_domain_id=0; |
| 174 |
--source include/reset_master_slave.inc |
| 175 |
--disconnect master2 |