| 1 |
--source include/have_innodb.inc |
| 2 |
--source include/have_debug.inc |
| 3 |
--source include/have_debug_sync.inc |
| 4 |
--let $rpl_topology=1->2 |
| 5 |
--source include/rpl_init.inc |
| 6 |
|
| 7 |
call mtr.add_suppression("Deadlock found when trying to get lock; try restarting transaction"); |
| 8 |
call mtr.add_suppression("Can't find record in 't1'"); |
| 9 |
call mtr.add_suppression("Can't find record in 't2'"); |
| 10 |
--disable_query_log |
| 11 |
call mtr.add_suppression("InnoDB: Transaction was aborted due to "); |
| 12 |
--enable_query_log |
| 13 |
|
| 14 |
--connection server_1 |
| 15 |
ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB; |
| 16 |
CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 17 |
--save_master_pos |
| 18 |
|
| 19 |
--connection server_2 |
| 20 |
--sync_with_master |
| 21 |
SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads; |
| 22 |
--source include/stop_slave.inc |
| 23 |
SET GLOBAL slave_parallel_threads=10; |
| 24 |
CHANGE MASTER TO master_use_gtid=slave_pos; |
| 25 |
SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode; |
| 26 |
SET GLOBAL slave_parallel_mode='optimistic'; |
| 27 |
# Run the first part of the test with high batch size and see that |
| 28 |
# old rows remain in the table. |
| 29 |
SET @old_gtid_cleanup_batch_size= @@GLOBAL.gtid_cleanup_batch_size; |
| 30 |
SET GLOBAL gtid_cleanup_batch_size= 1000000; |
| 31 |
|
| 32 |
|
| 33 |
--connection server_1 |
| 34 |
|
| 35 |
INSERT INTO t1 VALUES(1,1); |
| 36 |
BEGIN; |
| 37 |
INSERT INTO t1 VALUES(2,1); |
| 38 |
INSERT INTO t1 VALUES(3,1); |
| 39 |
COMMIT; |
| 40 |
|
| 41 |
# Do a bunch of INSERT/DELETE on the same rows, bound to conflict. |
| 42 |
# We will get a lot of rollbacks, probably, but they should be handled without |
| 43 |
# any visible errors. |
| 44 |
|
| 45 |
DELETE FROM t1 WHERE a=2; |
| 46 |
INSERT INTO t1 VALUES (2,2); |
| 47 |
DELETE FROM t1 WHERE a=2; |
| 48 |
INSERT INTO t1 VALUES (2,3); |
| 49 |
DELETE FROM t1 WHERE a=2; |
| 50 |
INSERT INTO t1 VALUES (2,4); |
| 51 |
DELETE FROM t1 WHERE a=2; |
| 52 |
INSERT INTO t1 VALUES (2,5); |
| 53 |
|
| 54 |
DELETE FROM t1 WHERE a=3; |
| 55 |
INSERT INTO t1 VALUES(3,2); |
| 56 |
DELETE FROM t1 WHERE a=1; |
| 57 |
INSERT INTO t1 VALUES(1,2); |
| 58 |
DELETE FROM t1 WHERE a=3; |
| 59 |
INSERT INTO t1 VALUES(3,3); |
| 60 |
|
| 61 |
DELETE FROM t1 WHERE a=2; |
| 62 |
INSERT INTO t1 VALUES (2,6); |
| 63 |
--source include/save_master_gtid.inc |
| 64 |
SELECT * FROM t1 ORDER BY a; |
| 65 |
|
| 66 |
--connection server_2 |
| 67 |
--source include/start_slave.inc |
| 68 |
--source include/sync_with_master_gtid.inc |
| 69 |
SELECT * FROM t1 ORDER BY a; |
| 70 |
#SHOW STATUS LIKE 'Slave_retried_transactions'; |
| 71 |
|
| 72 |
|
| 73 |
--echo *** Test a bunch of non-transactional/DDL event groups. *** |
| 74 |
|
| 75 |
--connection server_2 |
| 76 |
--source include/stop_slave.inc |
| 77 |
|
| 78 |
--connection server_1 |
| 79 |
|
| 80 |
INSERT INTO t1 VALUES (4,4); |
| 81 |
INSERT INTO t1 VALUES (5,5); |
| 82 |
CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB; |
| 83 |
INSERT INTO t2 VALUES (1); |
| 84 |
CREATE TABLE t3 (a INT PRIMARY KEY) ENGINE=MyISAM; |
| 85 |
ALTER TABLE t2 ADD b INT; |
| 86 |
INSERT INTO t2 VALUES (2,2); |
| 87 |
ALTER TABLE t2 DROP b; |
| 88 |
INSERT INTO t2 VALUES (3); |
| 89 |
ALTER TABLE t2 ADD c INT; |
| 90 |
INSERT INTO t2 VALUES (4,5); |
| 91 |
INSERT INTO t2 VALUES (5,5); |
| 92 |
INSERT INTO t3 VALUES (1); |
| 93 |
UPDATE t2 SET c=NULL WHERE a=4; |
| 94 |
ALTER TABLE t2 ADD UNIQUE (c); |
| 95 |
INSERT INTO t2 VALUES (6,6); |
| 96 |
UPDATE t2 SET c=c+100 WHERE a=2; |
| 97 |
INSERT INTO t3(a) VALUES (2); |
| 98 |
DELETE FROM t3 WHERE a=2; |
| 99 |
INSERT INTO t3(a) VALUES (2); |
| 100 |
DELETE FROM t3 WHERE a=2; |
| 101 |
ALTER TABLE t3 CHANGE a c INT NOT NULL; |
| 102 |
INSERT INTO t3(c) VALUES (2); |
| 103 |
DELETE FROM t3 WHERE c=2; |
| 104 |
INSERT INTO t3 SELECT a+200 FROM t2; |
| 105 |
DELETE FROM t3 WHERE c >= 200; |
| 106 |
INSERT INTO t3 SELECT a+200 FROM t2; |
| 107 |
--source include/save_master_gtid.inc |
| 108 |
SELECT * FROM t1 ORDER BY a; |
| 109 |
SELECT * FROM t2 ORDER BY a; |
| 110 |
SELECT * FROM t3 ORDER BY c; |
| 111 |
|
| 112 |
--connection server_2 |
| 113 |
--source include/start_slave.inc |
| 114 |
--source include/sync_with_master_gtid.inc |
| 115 |
SELECT * FROM t1 ORDER BY a; |
| 116 |
SELECT * FROM t2 ORDER BY a; |
| 117 |
SELECT * FROM t3 ORDER BY c; |
| 118 |
# Check that we have a bunch of old rows left-over - they were not deleted |
| 119 |
# due to high @@gtid_cleanup_batch_size. Then set a low |
| 120 |
# @@gtid_cleanup_batch_size so we can test that rows start being deleted. |
| 121 |
SELECT IF(COUNT(*) >= 30, "OK", CONCAT("Error: too few old rows found: ", COUNT(*))) |
| 122 |
FROM mysql.gtid_slave_pos; |
| 123 |
SET GLOBAL gtid_cleanup_batch_size=1; |
| 124 |
|
| 125 |
|
| 126 |
--echo *** Test @@skip_parallel_replication. *** |
| 127 |
|
| 128 |
--connection server_2 |
| 129 |
--source include/stop_slave.inc |
| 130 |
--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) |
| 131 |
|
| 132 |
--connection server_1 |
| 133 |
# We do a bunch of conflicting transactions on the master with |
| 134 |
# skip_parallel_replication set to true, and check that we do not |
| 135 |
# get any retries on the slave. |
| 136 |
|
| 137 |
UPDATE t1 SET b=10 WHERE a=3; |
| 138 |
SET SESSION skip_parallel_replication=1; |
| 139 |
UPDATE t1 SET b=20 WHERE a=3; |
| 140 |
UPDATE t1 SET b=30 WHERE a=3; |
| 141 |
UPDATE t1 SET b=50 WHERE a=3; |
| 142 |
UPDATE t1 SET b=80 WHERE a=3; |
| 143 |
UPDATE t1 SET b=130 WHERE a=3; |
| 144 |
UPDATE t1 SET b=210 WHERE a=3; |
| 145 |
UPDATE t1 SET b=340 WHERE a=3; |
| 146 |
UPDATE t1 SET b=550 WHERE a=3; |
| 147 |
UPDATE t1 SET b=890 WHERE a=3; |
| 148 |
SET SESSION skip_parallel_replication=0; |
| 149 |
SELECT * FROM t1 ORDER BY a; |
| 150 |
--source include/save_master_gtid.inc |
| 151 |
|
| 152 |
--connection server_2 |
| 153 |
--source include/start_slave.inc |
| 154 |
--source include/sync_with_master_gtid.inc |
| 155 |
SELECT * FROM t1 ORDER BY a; |
| 156 |
--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) |
| 157 |
--disable_query_log |
| 158 |
eval SELECT IF($retry1=$retry2, "Ok, no retry", |
| 159 |
CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", |
| 160 |
$retry1, " now ", $retry2, ")")) AS status; |
| 161 |
--enable_query_log |
| 162 |
|
| 163 |
|
| 164 |
--echo *** Test that we do not replicate in parallel transactions that had row lock waits on the master *** |
| 165 |
|
| 166 |
--connection server_2 |
| 167 |
--source include/stop_slave.inc |
| 168 |
--let $retry1= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) |
| 169 |
|
| 170 |
--connection server_1 |
| 171 |
# Setup a bunch of transactions that all needed to wait. |
| 172 |
--connect (m1,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 173 |
--connect (m2,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 174 |
--connect (m3,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 175 |
--connect (m4,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 176 |
--connect (m5,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 177 |
--connect (m6,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 178 |
--connect (m7,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 179 |
--connect (m8,127.0.0.1,root,,test,$SERVER_MYPORT_1,) |
| 180 |
|
| 181 |
--connection default |
| 182 |
BEGIN; UPDATE t1 SET b=b+1 WHERE a=3; |
| 183 |
|
| 184 |
--connection m1 |
| 185 |
SET debug_sync='thd_report_wait_for SIGNAL waiting1'; |
| 186 |
send UPDATE t1 SET b=1001 WHERE a=3; |
| 187 |
--connection default |
| 188 |
SET debug_sync='now WAIT_FOR waiting1'; |
| 189 |
|
| 190 |
--connection m2 |
| 191 |
BEGIN; |
| 192 |
UPDATE t1 SET b=1002 WHERE a=5; |
| 193 |
SET debug_sync='thd_report_wait_for SIGNAL waiting2'; |
| 194 |
send UPDATE t1 SET b=102 WHERE a=3; |
| 195 |
--connection default |
| 196 |
SET debug_sync='now WAIT_FOR waiting2'; |
| 197 |
|
| 198 |
UPDATE t1 SET b=1000 WHERE a=1; |
| 199 |
--connection m3 |
| 200 |
SET debug_sync='thd_report_wait_for SIGNAL waiting3'; |
| 201 |
send UPDATE t1 SET b=1003 WHERE a=5; |
| 202 |
--connection default |
| 203 |
SET debug_sync='now WAIT_FOR waiting3'; |
| 204 |
|
| 205 |
--connection m4 |
| 206 |
SET debug_sync='thd_report_wait_for SIGNAL waiting4'; |
| 207 |
send UPDATE t1 SET b=1004 WHERE a=3; |
| 208 |
--connection default |
| 209 |
SET debug_sync='now WAIT_FOR waiting4'; |
| 210 |
|
| 211 |
--connection m5 |
| 212 |
SET debug_sync='thd_report_wait_for SIGNAL waiting5'; |
| 213 |
send UPDATE t1 SET b=1005 WHERE a=5; |
| 214 |
--connection default |
| 215 |
SET debug_sync='now WAIT_FOR waiting5'; |
| 216 |
|
| 217 |
--connection m6 |
| 218 |
SET debug_sync='thd_report_wait_for SIGNAL waiting6'; |
| 219 |
send UPDATE t1 SET b=1006 WHERE a=1; |
| 220 |
--connection default |
| 221 |
SET debug_sync='now WAIT_FOR waiting6'; |
| 222 |
|
| 223 |
--connection m7 |
| 224 |
SET debug_sync='thd_report_wait_for SIGNAL waiting7'; |
| 225 |
send UPDATE t1 SET b=1007 WHERE a=5; |
| 226 |
--connection default |
| 227 |
SET debug_sync='now WAIT_FOR waiting7'; |
| 228 |
|
| 229 |
--connection m8 |
| 230 |
SET debug_sync='thd_report_wait_for SIGNAL waiting8'; |
| 231 |
send UPDATE t1 SET b=1008 WHERE a=3; |
| 232 |
--connection default |
| 233 |
SET debug_sync='now WAIT_FOR waiting8'; |
| 234 |
|
| 235 |
--connection default |
| 236 |
COMMIT; |
| 237 |
--connection m1 |
| 238 |
REAP; |
| 239 |
--connection m2 |
| 240 |
REAP; |
| 241 |
COMMIT; |
| 242 |
--connection m3 |
| 243 |
REAP; |
| 244 |
--connection m4 |
| 245 |
REAP; |
| 246 |
--connection m5 |
| 247 |
REAP; |
| 248 |
--connection m6 |
| 249 |
REAP; |
| 250 |
--connection m7 |
| 251 |
REAP; |
| 252 |
--connection m8 |
| 253 |
REAP; |
| 254 |
--connection default |
| 255 |
SET debug_sync='RESET'; |
| 256 |
SELECT * FROM t1 ORDER BY a; |
| 257 |
--source include/save_master_gtid.inc |
| 258 |
|
| 259 |
--connection server_2 |
| 260 |
--source include/start_slave.inc |
| 261 |
--source include/sync_with_master_gtid.inc |
| 262 |
SELECT * FROM t1 ORDER BY a; |
| 263 |
--let $retry2= query_get_value(SHOW STATUS LIKE 'Slave_retried_transactions', Value, 1) |
| 264 |
--disable_query_log |
| 265 |
eval SELECT IF($retry1=$retry2, "Ok, no retry", |
| 266 |
CONCAT("ERROR: ", $retry2-$retry1, " retries during replication (was ", |
| 267 |
$retry1, " now ", $retry2, ")")) AS status; |
| 268 |
--enable_query_log |
| 269 |
|
| 270 |
|
| 271 |
--echo *** Test that we replicate correctly when using READ COMMITTED and binlog_format=MIXED on the slave *** |
| 272 |
|
| 273 |
--connection server_2 |
| 274 |
--source include/stop_slave.inc |
| 275 |
SET @old_format= @@GLOBAL.binlog_format; |
| 276 |
# Use MIXED format; we cannot binlog ROW events on slave in STATEMENT format. |
| 277 |
SET GLOBAL binlog_format= MIXED; |
| 278 |
SET @old_isolation= @@GLOBAL.transaction_isolation; |
| 279 |
SET GLOBAL TRANSACTION ISOLATION LEVEL READ COMMITTED; |
| 280 |
# Reset the worker threads to make the new settings take effect. |
| 281 |
SET GLOBAL slave_parallel_threads=0; |
| 282 |
SET GLOBAL slave_parallel_threads=10; |
| 283 |
|
| 284 |
--connection server_1 |
| 285 |
DROP TABLE t1, t2; |
| 286 |
CREATE TABLE t1 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 287 |
CREATE TABLE t2 (a int PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 288 |
INSERT INTO t1 VALUES (1,0), (2,0), (3,0); |
| 289 |
INSERT INTO t2 VALUES (1,0), (2,0); |
| 290 |
INSERT INTO t1 SELECT 4, COUNT(*) FROM t2; |
| 291 |
INSERT INTO t2 SELECT 4, COUNT(*) FROM t1; |
| 292 |
|
| 293 |
INSERT INTO t1 SELECT 5, COUNT(*) FROM t2; |
| 294 |
INSERT INTO t2 SELECT 5, COUNT(*) FROM t1; |
| 295 |
|
| 296 |
INSERT INTO t2 SELECT 6, COUNT(*) FROM t1; |
| 297 |
INSERT INTO t1 SELECT 6, COUNT(*) FROM t2; |
| 298 |
|
| 299 |
INSERT INTO t1 SELECT 7, COUNT(*) FROM t2; |
| 300 |
INSERT INTO t2 SELECT 7, COUNT(*) FROM t1; |
| 301 |
|
| 302 |
INSERT INTO t2 SELECT 8, COUNT(*) FROM t1; |
| 303 |
INSERT INTO t1 SELECT 8, COUNT(*) FROM t2; |
| 304 |
|
| 305 |
INSERT INTO t2 SELECT 9, COUNT(*) FROM t1; |
| 306 |
INSERT INTO t1 SELECT 9, COUNT(*) FROM t2; |
| 307 |
|
| 308 |
INSERT INTO t1 SELECT 10, COUNT(*) FROM t2; |
| 309 |
INSERT INTO t2 SELECT 10, COUNT(*) FROM t1; |
| 310 |
|
| 311 |
SELECT * FROM t1 ORDER BY a; |
| 312 |
SELECT * FROM t2 ORDER BY a; |
| 313 |
--source include/save_master_gtid.inc |
| 314 |
|
| 315 |
--connection server_2 |
| 316 |
--source include/start_slave.inc |
| 317 |
--source include/sync_with_master_gtid.inc |
| 318 |
SELECT * FROM t1 ORDER BY a; |
| 319 |
SELECT * FROM t2 ORDER BY a; |
| 320 |
|
| 321 |
--source include/stop_slave.inc |
| 322 |
SET GLOBAL binlog_format= @old_format; |
| 323 |
SET GLOBAL transaction_isolation= @old_isolation; |
| 324 |
--source include/start_slave.inc |
| 325 |
|
| 326 |
|
| 327 |
--echo *** MDEV-7888: ANALYZE TABLE does wakeup_subsequent_commits(), causing wrong binlog order and parallel replication hang *** |
| 328 |
|
| 329 |
--connection server_1 |
| 330 |
DROP TABLE t1, t2, t3; |
| 331 |
CREATE TABLE t1 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 332 |
CREATE TABLE t2 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB; |
| 333 |
CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=MyISAM; |
| 334 |
INSERT INTO t2 VALUES (1,1), (2,1), (3,1), (4,1), (5,1); |
| 335 |
--source include/save_master_gtid.inc |
| 336 |
|
| 337 |
--connection server_2 |
| 338 |
--source include/sync_with_master_gtid.inc |
| 339 |
--source include/stop_slave.inc |
| 340 |
SET @old_debug= @@GLOBAL.debug_dbug; |
| 341 |
SET GLOBAL debug_dbug= '+d,inject_analyze_table_sleep'; |
| 342 |
|
| 343 |
--connection server_1 |
| 344 |
# The bug was that ANALYZE TABLE would call |
| 345 |
# wakeup_subsequent_commits() too early, allowing the following |
| 346 |
# transaction in the same group to run ahead and binlog and free the |
| 347 |
# GCO. Then we get wrong binlog order and later access freed GCO, |
| 348 |
# which causes lost wakeup of following GCO and thus replication hang. |
| 349 |
# We injected a small sleep in ANALYZE to make the race easier to hit (this |
| 350 |
# can only cause false negatives in versions with the bug, not false positives, |
| 351 |
# so sleep is ok here. And it's in general not possible to trigger reliably |
| 352 |
# the race with debug_sync, since the bugfix makes the race impossible). |
| 353 |
|
| 354 |
ALTER TABLE t2 COMMENT "123abc"; |
| 355 |
ANALYZE TABLE t2; |
| 356 |
INSERT INTO t1 VALUES (1,2); |
| 357 |
INSERT INTO t1 VALUES (2,2); |
| 358 |
INSERT INTO t1 VALUES (3,2); |
| 359 |
INSERT INTO t1 VALUES (4,2); |
| 360 |
INSERT INTO t3 VALUES (1,3); |
| 361 |
ALTER TABLE t2 COMMENT "hello, world"; |
| 362 |
BEGIN; |
| 363 |
INSERT INTO t1 VALUES (5,4); |
| 364 |
INSERT INTO t1 VALUES (6,4); |
| 365 |
INSERT INTO t1 VALUES (7,4); |
| 366 |
INSERT INTO t1 VALUES (8,4); |
| 367 |
INSERT INTO t1 VALUES (9,4); |
| 368 |
INSERT INTO t1 VALUES (10,4); |
| 369 |
INSERT INTO t1 VALUES (11,4); |
| 370 |
INSERT INTO t1 VALUES (12,4); |
| 371 |
INSERT INTO t1 VALUES (13,4); |
| 372 |
INSERT INTO t1 VALUES (14,4); |
| 373 |
INSERT INTO t1 VALUES (15,4); |
| 374 |
INSERT INTO t1 VALUES (16,4); |
| 375 |
INSERT INTO t1 VALUES (17,4); |
| 376 |
INSERT INTO t1 VALUES (18,4); |
| 377 |
INSERT INTO t1 VALUES (19,4); |
| 378 |
INSERT INTO t1 VALUES (20,4); |
| 379 |
COMMIT; |
| 380 |
INSERT INTO t1 VALUES (21,5); |
| 381 |
INSERT INTO t1 VALUES (22,5); |
| 382 |
|
| 383 |
SELECT * FROM t1 ORDER BY a; |
| 384 |
SELECT * FROM t2 ORDER BY a; |
| 385 |
SELECT * FROM t3 ORDER BY a; |
| 386 |
--source include/save_master_gtid.inc |
| 387 |
|
| 388 |
--connection server_2 |
| 389 |
--source include/start_slave.inc |
| 390 |
--source include/sync_with_master_gtid.inc |
| 391 |
|
| 392 |
SELECT * FROM t1 ORDER BY a; |
| 393 |
SELECT * FROM t2 ORDER BY a; |
| 394 |
SELECT * FROM t3 ORDER BY a; |
| 395 |
|
| 396 |
--source include/stop_slave.inc |
| 397 |
SET GLOBAL debug_dbug= @old_debug; |
| 398 |
--source include/start_slave.inc |
| 399 |
|
| 400 |
--echo *** MDEV-7929: record_gtid() for non-transactional event group calls wakeup_subsequent_commits() too early, causing slave hang. *** |
| 401 |
|
| 402 |
--connection server_2 |
| 403 |
--source include/stop_slave.inc |
| 404 |
SET @old_dbug= @@GLOBAL.debug_dbug; |
| 405 |
# The bug was that record_gtid(), when there is no existing transaction from |
| 406 |
# a DML event being replicated, would commit its own transaction. This wrongly |
| 407 |
# caused wakeup_subsequent_commits(), with similar consequences as MDEV-7888 |
| 408 |
# above. We simulate this condition with a small sleep in record_gtid() for |
| 409 |
# a specific ANALYZE that we binlog with server id 100. |
| 410 |
SET GLOBAL debug_dbug= '+d,inject_record_gtid_serverid_100_sleep'; |
| 411 |
|
| 412 |
--connection server_1 |
| 413 |
|
| 414 |
ALTER TABLE t3 COMMENT "DDL statement 1"; |
| 415 |
INSERT INTO t1 VALUES (30,0); |
| 416 |
INSERT INTO t1 VALUES (31,0); |
| 417 |
INSERT INTO t1 VALUES (32,0); |
| 418 |
INSERT INTO t1 VALUES (33,0); |
| 419 |
INSERT INTO t1 VALUES (34,0); |
| 420 |
INSERT INTO t1 VALUES (35,0); |
| 421 |
INSERT INTO t1 VALUES (36,0); |
| 422 |
SET @old_server_id= @@SESSION.server_id; |
| 423 |
SET SESSION server_id= 100; |
| 424 |
ANALYZE TABLE t2; |
| 425 |
SET SESSION server_id= @old_server_id; |
| 426 |
INSERT INTO t1 VALUES (37,0); |
| 427 |
ALTER TABLE t3 COMMENT "DDL statement 2"; |
| 428 |
INSERT INTO t1 VALUES (38,0); |
| 429 |
INSERT INTO t1 VALUES (39,0); |
| 430 |
ALTER TABLE t3 COMMENT "DDL statement 3"; |
| 431 |
|
| 432 |
SELECT * FROM t1 WHERE a >= 30 ORDER BY a; |
| 433 |
|
| 434 |
--source include/save_master_gtid.inc |
| 435 |
|
| 436 |
|
| 437 |
--connection server_2 |
| 438 |
--source include/start_slave.inc |
| 439 |
--source include/sync_with_master_gtid.inc |
| 440 |
SELECT * FROM t1 WHERE a >= 30 ORDER BY a; |
| 441 |
|
| 442 |
|
| 443 |
--source include/stop_slave.inc |
| 444 |
SET GLOBAL debug_dbug= @old_debug; |
| 445 |
--source include/start_slave.inc |
| 446 |
|
| 447 |
|
| 448 |
--echo *** MDEV-8113: ALTER TABLE causes slave hang in optimistic parallel replication *** |
| 449 |
|
| 450 |
--connection server_2 |
| 451 |
--source include/stop_slave.inc |
| 452 |
|
| 453 |
--connection server_1 |
| 454 |
ALTER TABLE t2 ADD c INT; |
| 455 |
INSERT INTO t2 (a,b) VALUES (50, 0); |
| 456 |
INSERT INTO t2 (a,b) VALUES (51, 1); |
| 457 |
INSERT INTO t2 (a,b) VALUES (52, 2); |
| 458 |
INSERT INTO t2 (a,b) VALUES (53, 3); |
| 459 |
INSERT INTO t2 (a,b) VALUES (54, 4); |
| 460 |
INSERT INTO t2 (a,b) VALUES (55, 5); |
| 461 |
INSERT INTO t2 (a,b) VALUES (56, 6); |
| 462 |
INSERT INTO t2 (a,b) VALUES (57, 7); |
| 463 |
INSERT INTO t2 (a,b) VALUES (58, 8); |
| 464 |
INSERT INTO t2 (a,b) VALUES (59, 9); |
| 465 |
ALTER TABLE t2 DROP COLUMN c; |
| 466 |
SELECT * FROM t2 WHERE a >= 50 ORDER BY a; |
| 467 |
--source include/save_master_gtid.inc |
| 468 |
|
| 469 |
--connection server_2 |
| 470 |
--source include/start_slave.inc |
| 471 |
--source include/sync_with_master_gtid.inc |
| 472 |
SELECT * FROM t2 WHERE a >= 50 ORDER BY a; |
| 473 |
|
| 474 |
|
| 475 |
--echo *** MDEV-8075: DROP TEMPORARY TABLE not marked as ddl, causing optimistic parallel replication to fail *** |
| 476 |
|
| 477 |
--connection server_2 |
| 478 |
--source include/stop_slave.inc |
| 479 |
|
| 480 |
--connection server_1 |
| 481 |
INSERT INTO t1 VALUES (40, 10); |
| 482 |
CREATE TEMPORARY TABLE t1 (a INT PRIMARY KEY) ENGINE=InnoDB; |
| 483 |
INSERT INTO t1 VALUES (41); |
| 484 |
BEGIN; |
| 485 |
INSERT INTO t2 SELECT a, 20 FROM t1; |
| 486 |
DROP TEMPORARY TABLE t1; |
| 487 |
COMMIT; |
| 488 |
INSERT INTO t1 VALUES (42, 10); |
| 489 |
--source include/save_master_gtid.inc |
| 490 |
SELECT * FROM t1 WHERE a >= 40 ORDER BY a; |
| 491 |
SELECT * FROM t2 WHERE a >= 40 ORDER BY a; |
| 492 |
|
| 493 |
--connection server_2 |
| 494 |
--source include/start_slave.inc |
| 495 |
--source include/sync_with_master_gtid.inc |
| 496 |
SELECT * FROM t1 WHERE a >= 40 ORDER BY a; |
| 497 |
SELECT * FROM t2 WHERE a >= 40 ORDER BY a; |
| 498 |
|
| 499 |
# partial cleanup to reuse the tables by following tests |
| 500 |
--connection server_1 |
| 501 |
DELETE FROM t1; |
| 502 |
DELETE FROM t2; |
| 503 |
--source include/save_master_gtid.inc |
| 504 |
|
| 505 |
--connection server_2 |
| 506 |
--source include/sync_with_master_gtid.inc |
| 507 |
|
| 508 |
# |
| 509 |
# MDEV-13577 optimistic parallel slave errors out to error log unnecessary |
| 510 |
# |
| 511 |
|
| 512 |
# The 1st of the following two trx:s a blocker on slave |
| 513 |
--connection server_2 |
| 514 |
SET @org_log_warnings=@@GLOBAL.LOG_WARNINGS; |
| 515 |
set global log_warnings=2; |
| 516 |
BEGIN; |
| 517 |
INSERT INTO t1 SET a=1; |
| 518 |
|
| 519 |
--connection server_1 |
| 520 |
SET @save.binlog_format=@@session.binlog_format; |
| 521 |
SET @@SESSION.binlog_format=row; |
| 522 |
|
| 523 |
BEGIN; |
| 524 |
INSERT INTO t1 SET a=1; |
| 525 |
INSERT INTO t2 SET a=1; |
| 526 |
COMMIT; |
| 527 |
|
| 528 |
# This transaction is going to win optimistical race with above INSERT |
| 529 |
# on slave while being depend on it. That means it will face a kind of temporary error |
| 530 |
# and then will retry to succeed. |
| 531 |
BEGIN; |
| 532 |
DELETE FROM t2; |
| 533 |
COMMIT; |
| 534 |
|
| 535 |
# First make sure DELETE raced indeed to get stuck at retrying stage |
| 536 |
# where it runs "realistically" now. There is nomore optimistic error |
| 537 |
# in the errorlog, which is downgraded to the warning level (when |
| 538 |
# --log-warnings > 1), see above suppression. |
| 539 |
--connection server_2 |
| 540 |
--let $wait_condition= SELECT COUNT(*) = 1 FROM information_schema.processlist WHERE state = "Waiting for prior transaction to commit" |
| 541 |
--source include/wait_condition.inc |
| 542 |
|
| 543 |
# Next release the 1st trx to commit. |
| 544 |
--connection server_2 |
| 545 |
ROLLBACK; |
| 546 |
|
| 547 |
# MDEV-13577 local cleanup: |
| 548 |
--connection server_1 |
| 549 |
SET @@SESSION.binlog_format= @save.binlog_format; |
| 550 |
DELETE FROM t1; |
| 551 |
DELETE FROM t2; |
| 552 |
--source include/save_master_gtid.inc |
| 553 |
|
| 554 |
--connection server_2 |
| 555 |
--source include/sync_with_master_gtid.inc |
| 556 |
|
| 557 |
# |
| 558 |
# Clean up. |
| 559 |
# |
| 560 |
--connection server_2 |
| 561 |
--source include/stop_slave.inc |
| 562 |
set global log_warnings=@org_log_warnings; |
| 563 |
SET GLOBAL slave_parallel_mode=@old_parallel_mode; |
| 564 |
SET GLOBAL slave_parallel_threads=@old_parallel_threads; |
| 565 |
--source include/start_slave.inc |
| 566 |
|
| 567 |
--connection server_1 |
| 568 |
DROP TABLE t1, t2, t3; |
| 569 |
--source include/save_master_gtid.inc |
| 570 |
|
| 571 |
--connection server_2 |
| 572 |
--source include/sync_with_master_gtid.inc |
| 573 |
# Check that old rows are deleted from mysql.gtid_slave_pos. |
| 574 |
# Deletion is asynchronous, so use wait_condition.inc. |
| 575 |
# Also, there is a small amount of non-determinism in the deletion of old |
| 576 |
# rows, so it is not guaranteed that there can never be more than |
| 577 |
# @@gtid_cleanup_batch_size rows in the table; so allow a bit of slack |
| 578 |
# here. |
| 579 |
let $wait_condition= |
| 580 |
SELECT COUNT(*) <= 5*@@GLOBAL.gtid_cleanup_batch_size |
| 581 |
FROM mysql.gtid_slave_pos; |
| 582 |
--source include/wait_condition.inc |
| 583 |
eval $wait_condition; |
| 584 |
SET GLOBAL gtid_cleanup_batch_size= @old_gtid_cleanup_batch_size; |
| 585 |
|
| 586 |
--connection server_1 |
| 587 |
--source include/rpl_end.inc |