| 1 |
*** Test killing slave threads at various wait points *** |
| 2 |
include/master-slave.inc |
| 3 |
[connection master] |
| 4 |
connection server_2; |
| 5 |
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; |
| 6 |
SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; |
| 7 |
include/stop_slave.inc |
| 8 |
SET GLOBAL slave_parallel_threads=10; |
| 9 |
SET GLOBAL slave_parallel_mode='conservative'; |
| 10 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 11 |
include/start_slave.inc |
| 12 |
connection server_1; |
| 13 |
connect con_temp3,127.0.0.1,root,,test,$SERVER_MYPORT_1,; |
| 14 |
connect con_temp4,127.0.0.1,root,,test,$SERVER_MYPORT_1,; |
| 15 |
connect con_temp5,127.0.0.1,root,,test,$SERVER_MYPORT_1,; |
| 16 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 17 |
CREATE TABLE t1 (a int PRIMARY KEY) ENGINE=MyISAM; |
| 18 |
CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB; |
| 19 |
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 20 |
INSERT INTO t2 VALUES(100); |
| 21 |
INSERT INTO t3 VALUES(100, 100); |
| 22 |
connection server_2; |
| 23 |
connection server_1; |
| 24 |
SET sql_log_bin=0; |
| 25 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 26 |
RETURNS INT DETERMINISTIC |
| 27 |
BEGIN |
| 28 |
RETURN x; |
| 29 |
END |
| 30 |
|| |
| 31 |
SET sql_log_bin=1; |
| 32 |
connection server_2; |
| 33 |
SET sql_log_bin=0; |
| 34 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 35 |
RETURNS INT DETERMINISTIC |
| 36 |
BEGIN |
| 37 |
IF d1 != '' THEN |
| 38 |
SET debug_sync = d1; |
| 39 |
END IF; |
| 40 |
IF d2 != '' THEN |
| 41 |
SET debug_sync = d2; |
| 42 |
END IF; |
| 43 |
RETURN x; |
| 44 |
END |
| 45 |
|| |
| 46 |
SET sql_log_bin=1; |
| 47 |
*** 1. Test killing transaction waiting in commit for previous transaction to commit *** |
| 48 |
connection con_temp3; |
| 49 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; |
| 50 |
INSERT INTO t3 VALUES (31, foo(31, |
| 51 |
'commit_before_prepare_ordered WAIT_FOR t2_waiting', |
| 52 |
'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont')); |
| 53 |
connection server_1; |
| 54 |
SET debug_sync='now WAIT_FOR master_queued1'; |
| 55 |
connection con_temp4; |
| 56 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2'; |
| 57 |
BEGIN; |
| 58 |
INSERT INTO t3 VALUES (32, foo(32, |
| 59 |
'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont', |
| 60 |
'')); |
| 61 |
INSERT INTO t3 VALUES (33, foo(33, |
| 62 |
'group_commit_waiting_for_prior SIGNAL t2_waiting', |
| 63 |
'group_commit_waiting_for_prior_killed SIGNAL t2_killed')); |
| 64 |
COMMIT; |
| 65 |
connection server_1; |
| 66 |
SET debug_sync='now WAIT_FOR master_queued2'; |
| 67 |
connection con_temp5; |
| 68 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3'; |
| 69 |
INSERT INTO t3 VALUES (34, foo(34, |
| 70 |
'', |
| 71 |
'')); |
| 72 |
connection server_1; |
| 73 |
SET debug_sync='now WAIT_FOR master_queued3'; |
| 74 |
SET debug_sync='now SIGNAL master_cont1'; |
| 75 |
connection con_temp3; |
| 76 |
connection con_temp4; |
| 77 |
connection con_temp5; |
| 78 |
connection server_1; |
| 79 |
SELECT * FROM t3 WHERE a >= 30 ORDER BY a; |
| 80 |
a b |
| 81 |
31 31 |
| 82 |
32 32 |
| 83 |
33 33 |
| 84 |
34 34 |
| 85 |
100 100 |
| 86 |
SET debug_sync='RESET'; |
| 87 |
connection server_2; |
| 88 |
SET sql_log_bin=0; |
| 89 |
CALL mtr.add_suppression("Query execution was interrupted"); |
| 90 |
CALL mtr.add_suppression("Commit failed due to failure of an earlier commit on which this one depends"); |
| 91 |
CALL mtr.add_suppression("Slave: Connection was killed"); |
| 92 |
SET sql_log_bin=1; |
| 93 |
SET debug_sync='now WAIT_FOR t2_query'; |
| 94 |
SET debug_sync='now SIGNAL t2_cont'; |
| 95 |
SET debug_sync='now WAIT_FOR t1_ready'; |
| 96 |
KILL THD_ID; |
| 97 |
SET debug_sync='now WAIT_FOR t2_killed'; |
| 98 |
SET debug_sync='now SIGNAL t1_cont'; |
| 99 |
include/wait_for_slave_sql_error.inc [errno=1317,1927,1964] |
| 100 |
STOP SLAVE IO_THREAD; |
| 101 |
SELECT * FROM t3 WHERE a >= 30 ORDER BY a; |
| 102 |
a b |
| 103 |
31 31 |
| 104 |
100 100 |
| 105 |
SET debug_sync='RESET'; |
| 106 |
SET GLOBAL slave_parallel_threads=0; |
| 107 |
SET GLOBAL slave_parallel_threads=10; |
| 108 |
SET sql_log_bin=0; |
| 109 |
DROP FUNCTION foo; |
| 110 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 111 |
RETURNS INT DETERMINISTIC |
| 112 |
BEGIN |
| 113 |
RETURN x; |
| 114 |
END |
| 115 |
|| |
| 116 |
SET sql_log_bin=1; |
| 117 |
connection server_1; |
| 118 |
INSERT INTO t3 VALUES (39,0); |
| 119 |
connection server_2; |
| 120 |
include/start_slave.inc |
| 121 |
SELECT * FROM t3 WHERE a >= 30 ORDER BY a; |
| 122 |
a b |
| 123 |
31 31 |
| 124 |
32 32 |
| 125 |
33 33 |
| 126 |
34 34 |
| 127 |
39 0 |
| 128 |
100 100 |
| 129 |
SET sql_log_bin=0; |
| 130 |
DROP FUNCTION foo; |
| 131 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 132 |
RETURNS INT DETERMINISTIC |
| 133 |
BEGIN |
| 134 |
IF d1 != '' THEN |
| 135 |
SET debug_sync = d1; |
| 136 |
END IF; |
| 137 |
IF d2 != '' THEN |
| 138 |
SET debug_sync = d2; |
| 139 |
END IF; |
| 140 |
RETURN x; |
| 141 |
END |
| 142 |
|| |
| 143 |
SET sql_log_bin=1; |
| 144 |
connection server_2; |
| 145 |
include/stop_slave.inc |
| 146 |
SET GLOBAL slave_parallel_threads=0; |
| 147 |
SET GLOBAL slave_parallel_threads=10; |
| 148 |
include/start_slave.inc |
| 149 |
*** 2. Same as (1), but without restarting IO thread after kill of SQL threads *** |
| 150 |
connection con_temp3; |
| 151 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; |
| 152 |
INSERT INTO t3 VALUES (41, foo(41, |
| 153 |
'commit_before_prepare_ordered WAIT_FOR t2_waiting', |
| 154 |
'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont')); |
| 155 |
connection server_1; |
| 156 |
SET debug_sync='now WAIT_FOR master_queued1'; |
| 157 |
connection con_temp4; |
| 158 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2'; |
| 159 |
BEGIN; |
| 160 |
INSERT INTO t3 VALUES (42, foo(42, |
| 161 |
'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont', |
| 162 |
'')); |
| 163 |
INSERT INTO t3 VALUES (43, foo(43, |
| 164 |
'group_commit_waiting_for_prior SIGNAL t2_waiting', |
| 165 |
'group_commit_waiting_for_prior_killed SIGNAL t2_killed')); |
| 166 |
COMMIT; |
| 167 |
connection server_1; |
| 168 |
SET debug_sync='now WAIT_FOR master_queued2'; |
| 169 |
connection con_temp5; |
| 170 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3'; |
| 171 |
INSERT INTO t3 VALUES (44, foo(44, |
| 172 |
'', |
| 173 |
'')); |
| 174 |
connection server_1; |
| 175 |
SET debug_sync='now WAIT_FOR master_queued3'; |
| 176 |
SET debug_sync='now SIGNAL master_cont1'; |
| 177 |
connection con_temp3; |
| 178 |
connection con_temp4; |
| 179 |
connection con_temp5; |
| 180 |
connection server_1; |
| 181 |
SELECT * FROM t3 WHERE a >= 40 ORDER BY a; |
| 182 |
a b |
| 183 |
41 41 |
| 184 |
42 42 |
| 185 |
43 43 |
| 186 |
44 44 |
| 187 |
100 100 |
| 188 |
SET debug_sync='RESET'; |
| 189 |
connection server_2; |
| 190 |
SET debug_sync='now WAIT_FOR t2_query'; |
| 191 |
SET debug_sync='now SIGNAL t2_cont'; |
| 192 |
SET debug_sync='now WAIT_FOR t1_ready'; |
| 193 |
KILL THD_ID; |
| 194 |
SET debug_sync='now WAIT_FOR t2_killed'; |
| 195 |
SET debug_sync='now SIGNAL t1_cont'; |
| 196 |
include/wait_for_slave_sql_error.inc [errno=1317,1927,1964] |
| 197 |
SET debug_sync='RESET'; |
| 198 |
SET GLOBAL slave_parallel_threads=0; |
| 199 |
SET GLOBAL slave_parallel_threads=10; |
| 200 |
SET sql_log_bin=0; |
| 201 |
DROP FUNCTION foo; |
| 202 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 203 |
RETURNS INT DETERMINISTIC |
| 204 |
BEGIN |
| 205 |
RETURN x; |
| 206 |
END |
| 207 |
|| |
| 208 |
SET sql_log_bin=1; |
| 209 |
include/stop_slave_io.inc |
| 210 |
connection server_1; |
| 211 |
INSERT INTO t3 VALUES (49,0); |
| 212 |
connection server_2; |
| 213 |
CHANGE MASTER TO master_use_gtid=no; |
| 214 |
include/start_slave.inc |
| 215 |
SELECT * FROM t3 WHERE a >= 40 ORDER BY a; |
| 216 |
a b |
| 217 |
41 41 |
| 218 |
42 42 |
| 219 |
43 43 |
| 220 |
44 44 |
| 221 |
49 0 |
| 222 |
100 100 |
| 223 |
SET sql_log_bin=0; |
| 224 |
DROP FUNCTION foo; |
| 225 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 226 |
RETURNS INT DETERMINISTIC |
| 227 |
BEGIN |
| 228 |
IF d1 != '' THEN |
| 229 |
SET debug_sync = d1; |
| 230 |
END IF; |
| 231 |
IF d2 != '' THEN |
| 232 |
SET debug_sync = d2; |
| 233 |
END IF; |
| 234 |
RETURN x; |
| 235 |
END |
| 236 |
|| |
| 237 |
SET sql_log_bin=1; |
| 238 |
connection server_2; |
| 239 |
include/stop_slave.inc |
| 240 |
SET GLOBAL slave_parallel_threads=0; |
| 241 |
SET GLOBAL slave_parallel_threads=10; |
| 242 |
include/start_slave.inc |
| 243 |
*** 3. Same as (2), but not using gtid mode *** |
| 244 |
connection server_1; |
| 245 |
connection con_temp3; |
| 246 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued1 WAIT_FOR master_cont1'; |
| 247 |
INSERT INTO t3 VALUES (51, foo(51, |
| 248 |
'commit_before_prepare_ordered WAIT_FOR t2_waiting', |
| 249 |
'commit_after_prepare_ordered SIGNAL t1_ready WAIT_FOR t1_cont')); |
| 250 |
connection server_1; |
| 251 |
SET debug_sync='now WAIT_FOR master_queued1'; |
| 252 |
connection con_temp4; |
| 253 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued2'; |
| 254 |
BEGIN; |
| 255 |
INSERT INTO t3 VALUES (52, foo(52, |
| 256 |
'ha_write_row_end SIGNAL t2_query WAIT_FOR t2_cont', |
| 257 |
'')); |
| 258 |
INSERT INTO t3 VALUES (53, foo(53, |
| 259 |
'group_commit_waiting_for_prior SIGNAL t2_waiting', |
| 260 |
'group_commit_waiting_for_prior_killed SIGNAL t2_killed')); |
| 261 |
COMMIT; |
| 262 |
connection server_1; |
| 263 |
SET debug_sync='now WAIT_FOR master_queued2'; |
| 264 |
connection con_temp5; |
| 265 |
SET debug_sync='commit_after_release_LOCK_prepare_ordered SIGNAL master_queued3'; |
| 266 |
INSERT INTO t3 VALUES (54, foo(54, |
| 267 |
'', |
| 268 |
'')); |
| 269 |
connection server_1; |
| 270 |
SET debug_sync='now WAIT_FOR master_queued3'; |
| 271 |
SET debug_sync='now SIGNAL master_cont1'; |
| 272 |
connection con_temp3; |
| 273 |
connection con_temp4; |
| 274 |
connection con_temp5; |
| 275 |
connection server_1; |
| 276 |
SELECT * FROM t3 WHERE a >= 50 ORDER BY a; |
| 277 |
a b |
| 278 |
51 51 |
| 279 |
52 52 |
| 280 |
53 53 |
| 281 |
54 54 |
| 282 |
100 100 |
| 283 |
SET debug_sync='RESET'; |
| 284 |
connection server_2; |
| 285 |
SET debug_sync='now WAIT_FOR t2_query'; |
| 286 |
SET debug_sync='now SIGNAL t2_cont'; |
| 287 |
SET debug_sync='now WAIT_FOR t1_ready'; |
| 288 |
KILL THD_ID; |
| 289 |
SET debug_sync='now WAIT_FOR t2_killed'; |
| 290 |
SET debug_sync='now SIGNAL t1_cont'; |
| 291 |
include/wait_for_slave_sql_error.inc [errno=1317,1927,1964] |
| 292 |
SELECT * FROM t3 WHERE a >= 50 ORDER BY a; |
| 293 |
a b |
| 294 |
51 51 |
| 295 |
100 100 |
| 296 |
SET debug_sync='RESET'; |
| 297 |
SET GLOBAL slave_parallel_threads=0; |
| 298 |
SET GLOBAL slave_parallel_threads=10; |
| 299 |
SET sql_log_bin=0; |
| 300 |
DROP FUNCTION foo; |
| 301 |
CREATE FUNCTION foo(x INT, d1 VARCHAR(500), d2 VARCHAR(500)) |
| 302 |
RETURNS INT DETERMINISTIC |
| 303 |
BEGIN |
| 304 |
RETURN x; |
| 305 |
END |
| 306 |
|| |
| 307 |
SET sql_log_bin=1; |
| 308 |
connection server_1; |
| 309 |
INSERT INTO t3 VALUES (59,0); |
| 310 |
connection server_2; |
| 311 |
START SLAVE SQL_THREAD; |
| 312 |
SELECT * FROM t3 WHERE a >= 50 ORDER BY a; |
| 313 |
a b |
| 314 |
51 51 |
| 315 |
52 52 |
| 316 |
53 53 |
| 317 |
54 54 |
| 318 |
59 0 |
| 319 |
100 100 |
| 320 |
connection server_2; |
| 321 |
include/stop_slave.inc |
| 322 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 323 |
SET GLOBAL slave_parallel_threads=@old_parallel_threads; |
| 324 |
SET GLOBAL slave_parallel_mode=@old_parallel_mode; |
| 325 |
include/start_slave.inc |
| 326 |
SET DEBUG_SYNC= 'RESET'; |
| 327 |
connection server_1; |
| 328 |
DROP function foo; |
| 329 |
DROP TABLE t1,t2,t3; |
| 330 |
SET DEBUG_SYNC= 'RESET'; |
| 331 |
include/rpl_end.inc |