Debian Codegraph @

mysql-test/suite/rpl/t/rpl_parallel_analyze_table_hang.test

raw
1 --echo *** MDEV-7888: ANALYZE TABLE does wakeup_subsequent_commits(), causing wrong binlog order and parallel replication hang ***
2 --source include/have_innodb.inc
3 --source include/have_debug.inc
4 --source include/have_debug_sync.inc
5 --source include/master-slave.inc
6
7 --connection server_2
8 SET @old_parallel_threads=@@GLOBAL.slave_parallel_threads;
9 SET @old_parallel_mode=@@GLOBAL.slave_parallel_mode;
10 --source include/stop_slave.inc
11 SET GLOBAL slave_parallel_mode='conservative';
12 SET GLOBAL slave_parallel_threads=10;
13 CHANGE MASTER TO master_use_gtid=slave_pos;
14 --source include/start_slave.inc
15
16 --connection server_1
17 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
18 CREATE TABLE t2 (a int PRIMARY KEY) ENGINE=InnoDB;
19 CREATE TABLE t3 (a INT PRIMARY KEY, b INT) ENGINE=InnoDB;
20 --save_master_pos
21
22 --connection server_2
23 --sync_with_master
24 --source include/stop_slave.inc
25 SET @old_dbug= @@GLOBAL.debug_dbug;
26 SET GLOBAL debug_dbug= '+d,inject_analyze_table_sleep';
27
28 --connection server_1
29 # Inject two group commits. The bug was that ANALYZE TABLE would call
30 # wakeup_subsequent_commits() too early, allowing the following transaction
31 # in the same group to run ahead and binlog and free the GCO. Then we get
32 # wrong binlog order and later access freed GCO, which causes lost wakeup
33 # of following GCO and thus replication hang.
34 # We injected a small sleep in ANALYZE to make the race easier to hit (this
35 # can only cause false negatives in versions with the bug, not false positives,
36 # so sleep is ok here. And it's in general not possible to trigger reliably
37 # the race with debug_sync, since the bugfix makes the race impossible).
38
39 SET @old_dbug= @@SESSION.debug_dbug;
40 SET SESSION debug_dbug="+d,binlog_force_commit_id";
41
42 # Group commit with cid=10000, two event groups.
43 SET @commit_id= 10000;
44 ANALYZE TABLE t2;
45 INSERT INTO t3 VALUES (120, 0);
46
47 # Group commit with cid=10001, one event group.
48 SET @commit_id= 10001;
49 INSERT INTO t3 VALUES (121, 0);
50
51 SET SESSION debug_dbug=@old_dbug;
52
53 SELECT * FROM t3 WHERE a >= 120 ORDER BY a;
54 --source include/save_master_gtid.inc
55
56 --connection server_2
57 --source include/start_slave.inc
58 --source include/sync_with_master_gtid.inc
59
60 SELECT * FROM t3 WHERE a >= 120 ORDER BY a;
61
62 # Clean up.
63 --source include/stop_slave.inc
64 SET GLOBAL debug_dbug= @old_dbug;
65 SET GLOBAL slave_parallel_threads=@old_parallel_threads;
66 SET GLOBAL slave_parallel_mode=@old_parallel_mode;
67 --source include/start_slave.inc
68
69 --connection server_1
70 DROP TABLE t2,t3;
71
72 --source include/rpl_end.inc
73