1--source include/have_innodb.inc 2--source include/have_debug_sync.inc 3--let $rpl_topology=1->2->3->4 4--source include/rpl_init.inc 5 6# Test parallel replication with a multi-level replication hierarchy. 7 8--connection server_1 9ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; 10CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; 11--save_master_pos 12 13--connection server_2 14--sync_with_master 15--save_master_pos 16SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; 17--source include/stop_slave.inc 18SET GLOBAL slave_parallel_threads=10; 19CHANGE MASTER TO master_use_gtid=slave_pos; 20SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; 21SET GLOBAL slave_parallel_mode='optimistic'; 22 23 24--connection server_3 25--sync_with_master 26--save_master_pos 27SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; 28--source include/stop_slave.inc 29SET GLOBAL slave_parallel_threads=10; 30CHANGE MASTER TO master_use_gtid=slave_pos; 31SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; 32SET GLOBAL slave_parallel_mode='optimistic'; 33 34 35--connection server_4 36--sync_with_master 37SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; 38--source include/stop_slave.inc 39SET GLOBAL slave_parallel_threads=10; 40CHANGE MASTER TO master_use_gtid=slave_pos; 41SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; 42SET GLOBAL slave_parallel_mode='optimistic'; 43 44 45--echo *** MDEV-6676: Test that @@skip_parallel_replication is preserved in slave binlog *** 46--connection server_1 47 48INSERT INTO t1 VALUES(1,1); 49BEGIN; 50INSERT INTO t1 VALUES(2,1); 51INSERT INTO t1 VALUES(3,1); 52COMMIT; 53# Do a lot of updates on same row in sequence. These would be likely to cause 54# conflicts and rollbacks in optimistic parallel replication, but we disable 55# that by enabling @@skip_parallel_replication. We can test that the flag is 56# preserved down the replication hierarchy by checking that no slave retries 57# are made. 58SET SESSION skip_parallel_replication=1; 59UPDATE t1 SET b=b+1 WHERE a=2; 60UPDATE t1 SET b=b+1 WHERE a=2; 61UPDATE t1 SET b=b+1 WHERE a=2; 62UPDATE t1 SET b=b+1 WHERE a=2; 63UPDATE t1 SET b=b+1 WHERE a=2; 64UPDATE t1 SET b=b+1 WHERE a=2; 65UPDATE t1 SET b=b+1 WHERE a=2; 66UPDATE t1 SET b=b+1 WHERE a=2; 67UPDATE t1 SET b=b+1 WHERE a=2; 68UPDATE t1 SET b=b+1 WHERE a=2; 69SET SESSION skip_parallel_replication=0; 70SELECT * FROM t1 ORDER BY a; 71--source include/save_master_gtid.inc 72 73--connection server_2 74--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 75--source include/start_slave.inc 76--source include/sync_with_master_gtid.inc 77SELECT * FROM t1 ORDER BY a; 78--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 79--disable_query_log 80eval SELECT IF($retry1=$retry2, "Ok, no retry", 81 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", 82 $retry1, " now ", $retry2, ")")) AS status; 83--enable_query_log 84 85--connection server_3 86--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 87--source include/start_slave.inc 88--source include/sync_with_master_gtid.inc 89SELECT * FROM t1 ORDER BY a; 90--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 91--disable_query_log 92eval SELECT IF($retry1=$retry2, "Ok, no retry", 93 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", 94 $retry1, " now ", $retry2, ")")) AS status; 95--enable_query_log 96 97--connection server_4 98--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 99--source include/start_slave.inc 100--source include/sync_with_master_gtid.inc 101SELECT * FROM t1 ORDER BY a; 102--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 103--disable_query_log 104eval SELECT IF($retry1=$retry2, "Ok, no retry", 105 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", 106 $retry1, " now ", $retry2, ")")) AS status; 107--enable_query_log 108 109 110--echo *** MDEV-6676: Test that the FL_WAITED flag in GTID is preserved in slave binlog *** 111 112--connection server_2 113--source include/stop_slave.inc 114CHANGE MASTER TO master_use_gtid=slave_pos; 115SET GLOBAL slave_parallel_mode='optimistic'; 116 117 118--connection server_3 119--source include/stop_slave.inc 120CHANGE MASTER TO master_use_gtid=slave_pos; 121SET GLOBAL slave_parallel_mode='optimistic'; 122 123 124--connection server_4 125--source include/stop_slave.inc 126CHANGE MASTER TO master_use_gtid=slave_pos; 127SET GLOBAL slave_parallel_mode='optimistic'; 128 129--connection server_1 130# Do a lot of updates on same row in sequence. Ensure that all of these but the 131# first have to do a lock wait on the master, setting FL_WAITED in the GTID 132# event. This should cause all slaves to not attempt to run those updates in 133# parallel with prior events, so that no retries are made. 134 135BEGIN; 136UPDATE t1 SET b=b+1 WHERE a=2; 137 138--connect (con_temp1,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 139SET debug_sync="thd_report_wait_for SIGNAL waiting1"; 140send UPDATE t1 SET b=b+1 WHERE a=2; 141--connection server_1 142SET debug_sync="now WAIT_FOR waiting1"; 143 144--connect (con_temp2,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 145SET debug_sync="thd_report_wait_for SIGNAL waiting2"; 146send UPDATE t1 SET b=b+1 WHERE a=2; 147--connection server_1 148SET debug_sync="now WAIT_FOR waiting2"; 149 150--connect (con_temp3,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 151SET debug_sync="thd_report_wait_for SIGNAL waiting3"; 152send UPDATE t1 SET b=b+1 WHERE a=2; 153--connection server_1 154SET debug_sync="now WAIT_FOR waiting3"; 155 156--connect (con_temp4,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 157SET debug_sync="thd_report_wait_for SIGNAL waiting4"; 158send UPDATE t1 SET b=b+1 WHERE a=2; 159--connection server_1 160SET debug_sync="now WAIT_FOR waiting4"; 161 162--connect (con_temp5,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 163SET debug_sync="thd_report_wait_for SIGNAL waiting5"; 164send UPDATE t1 SET b=b+1 WHERE a=2; 165--connection server_1 166SET debug_sync="now WAIT_FOR waiting5"; 167 168--connect (con_temp6,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 169SET debug_sync="thd_report_wait_for SIGNAL waiting6"; 170send UPDATE t1 SET b=b+1 WHERE a=2; 171--connection server_1 172SET debug_sync="now WAIT_FOR waiting6"; 173 174--connect (con_temp7,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 175SET debug_sync="thd_report_wait_for SIGNAL waiting7"; 176send UPDATE t1 SET b=b+1 WHERE a=2; 177--connection server_1 178SET debug_sync="now WAIT_FOR waiting7"; 179 180--connect (con_temp8,127.0.0.1,root,,test,$SERVER_MYPORT_1,) 181SET debug_sync="thd_report_wait_for SIGNAL waiting8"; 182send UPDATE t1 SET b=b+1 WHERE a=2; 183--connection server_1 184SET debug_sync="now WAIT_FOR waiting8"; 185 186COMMIT; 187SET debug_sync="RESET"; 188 189--connection con_temp1 190reap; 191 192COMMIT; 193--connection con_temp2 194reap; 195 196COMMIT; 197--connection con_temp3 198reap; 199 200COMMIT; 201--connection con_temp4 202reap; 203 204COMMIT; 205--connection con_temp5 206reap; 207 208COMMIT; 209--connection con_temp6 210reap; 211 212COMMIT; 213--connection con_temp7 214reap; 215 216COMMIT; 217--connection con_temp8 218reap; 219 220--connection server_1 221SELECT * FROM t1 ORDER BY a; 222--source include/save_master_gtid.inc 223 224--connection server_2 225--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 226--source include/start_slave.inc 227--source include/sync_with_master_gtid.inc 228SELECT * FROM t1 ORDER BY a; 229--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 230--disable_query_log 231eval SELECT IF($retry1=$retry2, "Ok, no retry", 232 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", 233 $retry1, " now ", $retry2, ")")) AS status; 234--enable_query_log 235 236--connection server_3 237--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 238--source include/start_slave.inc 239--source include/sync_with_master_gtid.inc 240SELECT * FROM t1 ORDER BY a; 241--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 242--disable_query_log 243eval SELECT IF($retry1=$retry2, "Ok, no retry", 244 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", 245 $retry1, " now ", $retry2, ")")) AS status; 246--enable_query_log 247 248--connection server_4 249--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 250--source include/start_slave.inc 251--source include/sync_with_master_gtid.inc 252SELECT * FROM t1 ORDER BY a; 253--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) 254--disable_query_log 255eval SELECT IF($retry1=$retry2, "Ok, no retry", 256 CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", 257 $retry1, " now ", $retry2, ")")) AS status; 258--enable_query_log 259 260 261# Clean up 262 263--connection server_2 264--source include/stop_slave.inc 265SET GLOBAL slave_parallel_mode=@old_parallel_mode; 266SET GLOBAL slave_parallel_threads=@old_parallel_threads; 267--source include/start_slave.inc 268 269--connection server_3 270--source include/stop_slave.inc 271SET GLOBAL slave_parallel_mode=@old_parallel_mode; 272SET GLOBAL slave_parallel_threads=@old_parallel_threads; 273--source include/start_slave.inc 274 275--connection server_4 276--source include/stop_slave.inc 277SET GLOBAL slave_parallel_mode=@old_parallel_mode; 278SET GLOBAL slave_parallel_threads=@old_parallel_threads; 279--source include/start_slave.inc 280 281--connection server_1 282DROP TABLE t1; 283 284--source include/rpl_end.inc 285