| 1 |
include/rpl_init.inc [topology=1->2] |
| 2 |
*** Test crashing master, causing slave IO thread to reconnect while SQL thread is running *** |
| 3 |
connection server_1; |
| 4 |
call mtr.add_suppression("Checking table:"); |
| 5 |
call mtr.add_suppression("client is using or hasn't closed the table properly"); |
| 6 |
call mtr.add_suppression("Table .* is marked as crashed and should be repaired"); |
| 7 |
call mtr.add_suppression("Could not read packet:.* errno: 11"); |
| 8 |
flush tables; |
| 9 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 10 |
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 11 |
INSERT INTO t1 VALUES (1, 0); |
| 12 |
connection server_2; |
| 13 |
SET sql_log_bin=0; |
| 14 |
call mtr.add_suppression('Master command COM_REGISTER_SLAVE failed: failed registering on master, reconnecting to try again'); |
| 15 |
call mtr.add_suppression('Slave I/O: .*Lost connection to server during query'); |
| 16 |
call mtr.add_suppression("Slave I/O thread couldn't register on master"); |
| 17 |
SET sql_log_bin=1; |
| 18 |
include/stop_slave.inc |
| 19 |
CHANGE MASTER TO master_host = '127.0.0.1', master_port = MASTER_PORT, |
| 20 |
MASTER_USE_GTID=SLAVE_POS; |
| 21 |
connection server_1; |
| 22 |
INSERT INTO t1 VALUES (2,1); |
| 23 |
INSERT INTO t1 VALUES (3,1); |
| 24 |
connection server_2; |
| 25 |
include/start_slave.inc |
| 26 |
connection server_1; |
| 27 |
include/save_master_gtid.inc |
| 28 |
SET SESSION debug_dbug="+d,crash_dispatch_command_before"; |
| 29 |
SELECT 1; |
| 30 |
Got one of the listed errors |
| 31 |
connection server_2; |
| 32 |
include/sync_with_master_gtid.inc |
| 33 |
connection server_1; |
| 34 |
INSERT INTO t1 VALUES (1000, 3); |
| 35 |
include/save_master_gtid.inc |
| 36 |
connection server_2; |
| 37 |
include/sync_with_master_gtid.inc |
| 38 |
connection server_1; |
| 39 |
DROP TABLE t1; |
| 40 |
*** Test crashing the master mysqld and check that binlog state is recovered. *** |
| 41 |
connection server_2; |
| 42 |
include/stop_slave.inc |
| 43 |
RESET MASTER; |
| 44 |
SET GLOBAL gtid_slave_pos=''; |
| 45 |
connection server_1; |
| 46 |
RESET MASTER; |
| 47 |
SHOW BINLOG EVENTS IN 'master-bin.000001' LIMIT 1,1; |
| 48 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 49 |
master-bin.000001 # Gtid_list # # [] |
| 50 |
CREATE TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; |
| 51 |
connection server_2; |
| 52 |
include/start_slave.inc |
| 53 |
connection server_1; |
| 54 |
SET gtid_domain_id= 1; |
| 55 |
INSERT INTO t1 VALUES (1); |
| 56 |
INSERT INTO t1 VALUES (2); |
| 57 |
FLUSH LOGS; |
| 58 |
SET gtid_domain_id= 2; |
| 59 |
INSERT INTO t1 VALUES (3); |
| 60 |
FLUSH LOGS; |
| 61 |
show binary logs; |
| 62 |
Log_name File_size |
| 63 |
master-bin.000001 # |
| 64 |
master-bin.000002 # |
| 65 |
master-bin.000003 # |
| 66 |
SHOW BINLOG EVENTS IN 'master-bin.000003' LIMIT 1,1; |
| 67 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 68 |
master-bin.000003 # Gtid_list # # # |
| 69 |
SET SESSION debug_dbug="+d,crash_dispatch_command_before"; |
| 70 |
SELECT 1; |
| 71 |
Got one of the listed errors |
| 72 |
show binary logs; |
| 73 |
Log_name File_size |
| 74 |
master-bin.000001 # |
| 75 |
master-bin.000002 # |
| 76 |
master-bin.000003 # |
| 77 |
master-bin.000004 # |
| 78 |
SHOW BINLOG EVENTS IN 'master-bin.000004' LIMIT 1,1; |
| 79 |
Log_name Pos Event_type Server_id End_log_pos Info |
| 80 |
master-bin.000004 # Gtid_list # # # |
| 81 |
connection server_2; |
| 82 |
SELECT * FROM t1 ORDER BY a; |
| 83 |
a |
| 84 |
1 |
| 85 |
2 |
| 86 |
3 |
| 87 |
*** Test crashing slave at various points and check that it recovers crash-safe. *** |
| 88 |
include/stop_slave.inc |
| 89 |
SET GLOBAL debug_dbug="+d,inject_crash_before_write_rpl_slave_state"; |
| 90 |
START SLAVE; |
| 91 |
connection server_1; |
| 92 |
INSERT INTO t1 VALUES (4); |
| 93 |
include/save_master_gtid.inc |
| 94 |
connection server_2; |
| 95 |
include/sync_with_master_gtid.inc |
| 96 |
include/stop_slave.inc |
| 97 |
START SLAVE; |
| 98 |
SET GLOBAL debug_dbug="+d,crash_commit_before"; |
| 99 |
connection server_1; |
| 100 |
INSERT INTO t1 VALUES (5); |
| 101 |
include/save_master_gtid.inc |
| 102 |
connection server_2; |
| 103 |
include/sync_with_master_gtid.inc |
| 104 |
include/stop_slave.inc |
| 105 |
START SLAVE; |
| 106 |
SET GLOBAL debug_dbug="+d,crash_commit_after"; |
| 107 |
connection server_1; |
| 108 |
INSERT INTO t1 VALUES (6); |
| 109 |
include/save_master_gtid.inc |
| 110 |
connection server_2; |
| 111 |
include/sync_with_master_gtid.inc |
| 112 |
include/stop_slave.inc |
| 113 |
SET GLOBAL debug_dbug="+d,inject_crash_before_flush_rli"; |
| 114 |
START SLAVE; |
| 115 |
connection server_1; |
| 116 |
INSERT INTO t1 VALUES (7); |
| 117 |
include/save_master_gtid.inc |
| 118 |
connection server_2; |
| 119 |
include/sync_with_master_gtid.inc |
| 120 |
include/stop_slave.inc |
| 121 |
SET GLOBAL debug_dbug="+d,inject_crash_after_flush_rli"; |
| 122 |
START SLAVE; |
| 123 |
connection server_1; |
| 124 |
INSERT INTO t1 VALUES (8); |
| 125 |
include/save_master_gtid.inc |
| 126 |
connection server_2; |
| 127 |
include/sync_with_master_gtid.inc |
| 128 |
SELECT * FROM t1 ORDER BY a; |
| 129 |
a |
| 130 |
1 |
| 131 |
2 |
| 132 |
3 |
| 133 |
4 |
| 134 |
5 |
| 135 |
6 |
| 136 |
7 |
| 137 |
8 |
| 138 |
*** MDEV-4725: Incorrect recovery when crash in the middle of writing an event group *** |
| 139 |
connection server_2; |
| 140 |
SET GLOBAL debug_dbug="+d,crash_before_writing_xid"; |
| 141 |
connection server_1; |
| 142 |
INSERT INTO t1 VALUES (9), (10); |
| 143 |
connection server_2; |
| 144 |
SHOW VARIABLES like 'gtid_strict_mode'; |
| 145 |
Variable_name Value |
| 146 |
gtid_strict_mode ON |
| 147 |
include/start_slave.inc |
| 148 |
*** MDEV-6462: Incorrect recovery on a slave reconnecting to crashed master *** |
| 149 |
connection server_1; |
| 150 |
set sql_log_bin= 0; |
| 151 |
call mtr.add_suppression("Error writing file 'master-bin'"); |
| 152 |
set sql_log_bin= 1; |
| 153 |
connection server_2; |
| 154 |
set sql_log_bin= 0; |
| 155 |
call mtr.add_suppression("The server_id of master server changed in the middle of GTID"); |
| 156 |
call mtr.add_suppression("Unexpected change of master binlog file name in the middle of GTID"); |
| 157 |
set sql_log_bin= 1; |
| 158 |
connection server_1; |
| 159 |
SET GLOBAL debug_dbug="+d,inject_error_writing_xid"; |
| 160 |
BEGIN; |
| 161 |
INSERT INTO t1 VALUES (11); |
| 162 |
COMMIT; |
| 163 |
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device") |
| 164 |
SET GLOBAL debug_dbug="+d,crash_dispatch_command_before"; |
| 165 |
COMMIT; |
| 166 |
Got one of the listed errors |
| 167 |
SELECT @@GLOBAL.server_id; |
| 168 |
@@GLOBAL.server_id |
| 169 |
3 |
| 170 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 171 |
a |
| 172 |
gtid_check |
| 173 |
Binlog pos ok |
| 174 |
# Wait 60 seconds for SQL thread to catch up with IO thread |
| 175 |
connection server_2; |
| 176 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 177 |
a |
| 178 |
gtid_check |
| 179 |
Binlog pos ok |
| 180 |
gtid_check |
| 181 |
Slave pos ok |
| 182 |
gtid_check |
| 183 |
Current pos ok |
| 184 |
# Repeat this with additional transactions on the master |
| 185 |
connection server_1; |
| 186 |
SET GLOBAL debug_dbug="+d,inject_error_writing_xid"; |
| 187 |
BEGIN; |
| 188 |
INSERT INTO t1 VALUES (12); |
| 189 |
COMMIT; |
| 190 |
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device") |
| 191 |
SET GLOBAL debug_dbug="+d,crash_dispatch_command_before"; |
| 192 |
COMMIT; |
| 193 |
Got one of the listed errors |
| 194 |
SELECT @@GLOBAL.server_id; |
| 195 |
@@GLOBAL.server_id |
| 196 |
1 |
| 197 |
INSERT INTO t1 VALUES (13); |
| 198 |
INSERT INTO t1 VALUES (14); |
| 199 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 200 |
a |
| 201 |
13 |
| 202 |
14 |
| 203 |
include/save_master_gtid.inc |
| 204 |
connection server_2; |
| 205 |
include/sync_with_master_gtid.inc |
| 206 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 207 |
a |
| 208 |
13 |
| 209 |
14 |
| 210 |
connection server_1; |
| 211 |
SET GLOBAL debug_dbug="+d,inject_error_writing_xid"; |
| 212 |
BEGIN; |
| 213 |
INSERT INTO t1 VALUES (21); |
| 214 |
COMMIT; |
| 215 |
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device") |
| 216 |
SET GLOBAL debug_dbug="+d,crash_dispatch_command_before"; |
| 217 |
COMMIT; |
| 218 |
Got one of the listed errors |
| 219 |
SELECT @@GLOBAL.server_id; |
| 220 |
@@GLOBAL.server_id |
| 221 |
1 |
| 222 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 223 |
a |
| 224 |
13 |
| 225 |
14 |
| 226 |
gtid_check |
| 227 |
Binlog pos ok |
| 228 |
gtid_check |
| 229 |
Current pos ok |
| 230 |
# Wait 60 seconds for SQL thread to catch up with IO thread |
| 231 |
connection server_2; |
| 232 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 233 |
a |
| 234 |
13 |
| 235 |
14 |
| 236 |
gtid_check |
| 237 |
Binlog pos ok |
| 238 |
gtid_check |
| 239 |
Slave pos ok |
| 240 |
gtid_check |
| 241 |
Current pos ok |
| 242 |
# Repeat this with additional transactions on the master |
| 243 |
connection server_1; |
| 244 |
SET GLOBAL debug_dbug="+d,inject_error_writing_xid"; |
| 245 |
BEGIN; |
| 246 |
INSERT INTO t1 VALUES (22); |
| 247 |
COMMIT; |
| 248 |
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device") |
| 249 |
SET GLOBAL debug_dbug="+d,crash_dispatch_command_before"; |
| 250 |
COMMIT; |
| 251 |
Got one of the listed errors |
| 252 |
INSERT INTO t1 VALUES (23); |
| 253 |
INSERT INTO t1 VALUES (24); |
| 254 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 255 |
a |
| 256 |
13 |
| 257 |
14 |
| 258 |
23 |
| 259 |
24 |
| 260 |
include/save_master_gtid.inc |
| 261 |
connection server_2; |
| 262 |
include/sync_with_master_gtid.inc |
| 263 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 264 |
a |
| 265 |
13 |
| 266 |
14 |
| 267 |
23 |
| 268 |
24 |
| 269 |
# Repeat this with slave restart |
| 270 |
connection server_1; |
| 271 |
SET GLOBAL debug_dbug="+d,inject_error_writing_xid"; |
| 272 |
BEGIN; |
| 273 |
INSERT INTO t1 VALUES (25); |
| 274 |
COMMIT; |
| 275 |
ERROR HY000: Error writing file 'master-bin' (errno: 28 "No space left on device") |
| 276 |
SET GLOBAL debug_dbug="+d,crash_dispatch_command_before"; |
| 277 |
COMMIT; |
| 278 |
Got one of the listed errors |
| 279 |
connection server_1; |
| 280 |
connection server_2; |
| 281 |
# Wait 60 seconds for IO thread to connect and SQL thread to catch up |
| 282 |
# with IO thread. |
| 283 |
include/stop_slave.inc |
| 284 |
connection server_1; |
| 285 |
gtid_check |
| 286 |
Binlog pos ok |
| 287 |
gtid_check |
| 288 |
Current pos ok |
| 289 |
INSERT INTO t1 VALUES (26); |
| 290 |
INSERT INTO t1 VALUES (27); |
| 291 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 292 |
a |
| 293 |
13 |
| 294 |
14 |
| 295 |
23 |
| 296 |
24 |
| 297 |
26 |
| 298 |
27 |
| 299 |
include/save_master_gtid.inc |
| 300 |
connection server_2; |
| 301 |
gtid_check |
| 302 |
Binlog pos ok |
| 303 |
gtid_check |
| 304 |
Slave pos ok |
| 305 |
gtid_check |
| 306 |
Current pos ok |
| 307 |
include/start_slave.inc |
| 308 |
include/sync_with_master_gtid.inc |
| 309 |
SELECT * from t1 WHERE a > 10 ORDER BY a; |
| 310 |
a |
| 311 |
13 |
| 312 |
14 |
| 313 |
23 |
| 314 |
24 |
| 315 |
26 |
| 316 |
27 |
| 317 |
*** MDEV-6391: GTID binlog state not recovered if mariadb-bin.state is removed *** |
| 318 |
connection server_2; |
| 319 |
include/stop_slave.inc |
| 320 |
connection server_1; |
| 321 |
INSERT INTO t1 VALUES (30); |
| 322 |
SET @old_server_id= @@server_id; |
| 323 |
SET @old_domain_id= @@gtid_domain_id; |
| 324 |
SET SESSION server_id= 10; |
| 325 |
INSERT INTO t1 VALUES (31); |
| 326 |
INSERT INTO t1 VALUES (32); |
| 327 |
SET SESSION gtid_domain_id= 1; |
| 328 |
SET SESSION server_id=11; |
| 329 |
INSERT INTO t1 VALUES (33); |
| 330 |
SET SESSION gtid_domain_id= 2; |
| 331 |
INSERT INTO t1 VALUES (34); |
| 332 |
SET SESSION server_id= 10; |
| 333 |
INSERT INTO t1 VALUES (35); |
| 334 |
INSERT INTO t1 VALUES (36); |
| 335 |
SET SESSION gtid_domain_id= 0; |
| 336 |
SET SESSION server_id= 12; |
| 337 |
INSERT INTO t1 VALUES (37); |
| 338 |
SET SESSION gtid_domain_id= @old_domain_id; |
| 339 |
SET SESSION server_id= @old_server_id; |
| 340 |
INSERT INTO t1 VALUES (38); |
| 341 |
INSERT INTO t1 VALUES (39); |
| 342 |
SELECT * FROM t1 WHERE a >= 30 ORDER BY a; |
| 343 |
a |
| 344 |
30 |
| 345 |
31 |
| 346 |
32 |
| 347 |
33 |
| 348 |
34 |
| 349 |
35 |
| 350 |
36 |
| 351 |
37 |
| 352 |
38 |
| 353 |
39 |
| 354 |
include/save_master_gtid.inc |
| 355 |
connection server_2; |
| 356 |
include/start_slave.inc |
| 357 |
include/sync_with_master_gtid.inc |
| 358 |
SELECT * FROM t1 WHERE a >= 30 ORDER BY a; |
| 359 |
a |
| 360 |
30 |
| 361 |
31 |
| 362 |
32 |
| 363 |
33 |
| 364 |
34 |
| 365 |
35 |
| 366 |
36 |
| 367 |
37 |
| 368 |
38 |
| 369 |
39 |
| 370 |
connection server_1; |
| 371 |
DROP TABLE t1; |
| 372 |
connection default; |
| 373 |
include/rpl_end.inc |