1--let $rpl_topology=1->2
2--source include/rpl_init.inc
3--source include/have_innodb.inc
4--source include/have_debug.inc
5
6
7--connection server_2
8--source include/stop_slave.inc
9CHANGE MASTER TO master_use_gtid= current_pos;
10--source include/start_slave.inc
11
12--connection server_1
13CREATE TABLE t1 (a INT);
14FLUSH LOGS;
15--save_master_pos
16
17--connection server_2
18--sync_with_master
19
20
21# Prepare a string of events and have the slave replicate all of it.
22--connection server_1
23SET gtid_domain_id=10;
24INSERT INTO t1 VALUES (1);
25INSERT INTO t1 VALUES (2);
26SET gtid_seq_no=100;
27INSERT INTO t1 VALUES (3);
28INSERT INTO t1 VALUES (4);
29INSERT INTO t1 VALUES (5);
30--save_master_pos
31
32--connection server_2
33--sync_with_master
34--source include/stop_slave.inc
35SELECT * FROM t1 ORDER BY a;
36
37# Now start the slave again, but force a reconnect. There was a bug that this
38# reconnect would cause duplicate events.
39
40--connection server_1
41# Make sure to get rid of any old binlog dump thread so it does not
42# interfere with our DBUG error injection.
43--source include/kill_binlog_dump_threads.inc
44INSERT INTO t1 VALUES (10);
45SET @old_debug= @@GLOBAL.debug_dbug;
46SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
47SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100";
48--save_master_pos
49
50--connection server_2
51--source include/start_slave.inc
52--sync_with_master
53SELECT * FROM t1 ORDER BY a;
54
55--source include/stop_slave.inc
56TRUNCATE t1;
57RESET MASTER;
58SET GLOBAL gtid_slave_pos= "";
59
60--connection server_1
61SET GLOBAL debug_dbug= @old_debug;
62TRUNCATE t1;
63RESET MASTER;
64
65# A1 B1 A2 B2 A3 B3, slave reached A1 and B3 and stopped. Slave starts,
66# reconnects at A2. There was a bug that B2 would be duplicated.
67
68SET gtid_domain_id=10;
69SET gtid_seq_no=50;
70INSERT INTO t1 VALUES (1);
71SET gtid_domain_id=11;
72INSERT INTO t1 VALUES (11);
73SET gtid_domain_id=10;
74SET gtid_seq_no=100;
75INSERT INTO t1 VALUES (2);
76SET gtid_domain_id=11;
77INSERT INTO t1 VALUES (12);
78SET gtid_domain_id=10;
79INSERT INTO t1 VALUES (3);
80SET gtid_domain_id=11;
81SET gtid_seq_no=200;
82INSERT INTO t1 VALUES (13);
83
84--connection server_2
85START SLAVE UNTIL master_gtid_pos="10-1-50,11-1-200";
86--source include/wait_for_slave_to_stop.inc
87SELECT * FROM t1 ORDER BY a;
88
89--connection server_1
90--source include/kill_binlog_dump_threads.inc
91INSERT INTO t1 VALUES (20);
92SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
93SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100";
94--save_master_pos
95
96--connection server_2
97--source include/start_slave.inc
98--sync_with_master
99SELECT * FROM t1 ORDER BY a;
100
101--source include/stop_slave.inc
102TRUNCATE t1;
103RESET MASTER;
104SET GLOBAL gtid_slave_pos= "";
105
106--connection server_1
107SET GLOBAL debug_dbug= @old_debug;
108TRUNCATE t1;
109RESET MASTER;
110
111# A1 B1 A2 B2 A3 B3. START SLAVE UNTIL A1,B3, gets reconnect at B2.
112# There was a bug that the UNTIL would be ignored, and A2 would be lost.
113
114--source include/kill_binlog_dump_threads.inc
115SET gtid_domain_id= 9;
116SET gtid_seq_no= 50;
117INSERT INTO t1 VALUES (1);
118SET gtid_domain_id= 10;
119INSERT INTO t1 VALUES (11);
120SET gtid_domain_id= 9;
121INSERT INTO t1 VALUES (2);
122SET gtid_domain_id= 10;
123SET gtid_seq_no= 100;
124INSERT INTO t1 VALUES (12);
125SET gtid_domain_id= 9;
126INSERT INTO t1 VALUES (3);
127SET gtid_domain_id= 10;
128SET gtid_seq_no= 200;
129INSERT INTO t1 VALUES (13);
130SET gtid_domain_id= 10;
131
132SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
133SET GLOBAL debug_dbug="+d,gtid_force_reconnect_at_10_1_100";
134
135--connection server_2
136START SLAVE UNTIL master_gtid_pos="9-1-50,10-1-200";
137--source include/wait_for_slave_to_stop.inc
138SELECT * FROM t1 ORDER BY a;
139
140--connection server_1
141SET GLOBAL debug_dbug= @old_debug;
142INSERT INTO t1 VALUES (20);
143--save_master_pos
144
145--connection server_2
146--source include/start_slave.inc
147--sync_with_master
148SELECT * FROM t1 ORDER BY a;
149
150
151--echo *** Test when slave IO thread needs to reconnect in the middle of an event group. ***
152--connection server_2
153--source include/stop_slave.inc
154
155TRUNCATE t1;
156RESET MASTER;
157SET GLOBAL gtid_slave_pos= "";
158
159--connection server_1
160SET GLOBAL debug_dbug= @old_debug;
161TRUNCATE t1;
162RESET MASTER;
163
164--source include/kill_binlog_dump_threads.inc
165SET GLOBAL debug_dbug="+d,dummy_disable_default_dbug_output";
166SET GLOBAL debug_dbug="+d,binlog_force_reconnect_after_22_events";
167
168# 4 events for FD, fake rotate, gtid list, binlog checkpoint.
169# 2 events for GTID, create table
170CREATE TABLE t2 (a INT PRIMARY KEY) ENGINE=InnoDB;
171# 3 events for BEGIN/query/COMMIT
172INSERT INTO t2 VALUES (1);
173# 4 events for BEGIN/query/query/COMMIT
174BEGIN;
175INSERT INTO t2 VALUES (10);
176INSERT INTO t2 VALUES (11);
177COMMIT;
178# So this event group starts after 4+2+4+3=13 events. Or 16 in row-based.
179BEGIN;
180INSERT INTO t2 VALUES (20);
181INSERT INTO t2 VALUES (21);
182INSERT INTO t2 VALUES (22);
183INSERT INTO t2 VALUES (23);
184INSERT INTO t2 VALUES (24);
185INSERT INTO t2 VALUES (25);
186INSERT INTO t2 VALUES (26);
187INSERT INTO t2 VALUES (27);
188INSERT INTO t2 VALUES (28);
189INSERT INTO t2 VALUES (29);
190COMMIT;
191--save_master_pos
192
193--connection server_2
194--source include/start_slave.inc
195--sync_with_master
196SELECT * FROM t2 ORDER BY a;
197
198--connection server_1
199SET GLOBAL debug_dbug= @old_debug;
200
201
202# Clean up.
203--connection server_1
204DROP TABLE t1, t2;
205
206--source include/rpl_end.inc
207