Debian Codegraph @

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

raw
1 # ==== References ====
2 #
3 # MDEV-21117 recovery for --rpl-semi-sync-slave-enabled server
4 # MDEV-27760 event may non stop replicate in circular semisync setup
5 #
6
7 --source include/have_innodb.inc
8 --source include/have_debug.inc
9 --source include/have_debug_sync.inc
10 --source include/have_binlog_format_row.inc
11 --source include/master-slave.inc
12
13 --disable_query_log
14 call mtr.add_suppression("Could not read packet:.* errno: 11");
15 flush tables;
16 --enable_query_log
17
18 # Initial slave
19 --connection server_2
20 --source include/stop_slave.inc
21
22 # Initial master
23 --connection server_1
24 RESET MASTER;
25 SET @@global.max_binlog_size= 4096;
26 set @@global.rpl_semi_sync_master_enabled = 1;
27
28 --connection server_2
29 RESET MASTER;
30 SET @@global.max_binlog_size= 4096;
31 set @@global.rpl_semi_sync_slave_enabled = 1;
32 set @@global.gtid_slave_pos = "";
33 CHANGE MASTER TO master_use_gtid= slave_pos;
34 --source include/start_slave.inc
35
36 --connection server_1
37 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
38 set @@global.rpl_semi_sync_master_wait_point=AFTER_SYNC;
39
40 CREATE TABLE t1 (a INT PRIMARY KEY, b MEDIUMTEXT) ENGINE=Innodb;
41 INSERT INTO t1 VALUES (1, 'dummy1');
42 --save_master_pos
43
44 --connection server_2
45 --sync_with_master
46
47 --connection server_1
48 --let $case = 1
49 --echo #
50 --echo # Case:$case
51 --echo #
52 --echo # CRASH the original master, and FAILOVER to the new
53 # value 1 for server id 1 -> 2 failover
54 --let $failover_to_slave=1
55 --let $query_to_crash= INSERT INTO t1 VALUES (2, REPEAT("x", 4100))
56 --echo # $query_to_crash
57 --echo # Row - 2 will be in master's binlog but not committed, gets replicated
58 --echo # to slave and applied. On crash master should have 1 row and slave
59 --echo # should have 2 rows.
60 --echo #
61 --echo # Expected State post crash:
62 --echo #=================================================================
63 --echo # Master | Slave |
64 --echo # 0-1-4 (Not committed) | 0-1-4 (Received through semi-sync |
65 --echo # | replication and applied) |
66 --echo #=================================================================
67 --let $log_search_pattern=truncated binlog file:.*master.*000001
68 --let $expected_rows_on_master= 1
69 --let $expected_rows_on_slave= 2
70 --source rpl_semi_sync_crash.inc
71
72 --echo #
73 --echo # Server_2 promoted as master will send 0-1-4 to new slave Server_1
74 --echo #
75 --connection server_2
76 --let $rows_so_far=3
77 --eval INSERT INTO t1 VALUES ($rows_so_far, 'dummy3')
78 --save_master_pos
79 --echo # The gtid state on current master must be equal to ...
80 SHOW VARIABLES LIKE 'gtid_binlog_pos';
81 SHOW VARIABLES LIKE 'gtid_binlog_state';
82 SHOW VARIABLES LIKE 'gtid_slave_pos';
83
84 --connection server_1
85 --sync_with_master
86 --eval SELECT COUNT(*) 'must be $rows_so_far' FROM t1
87 --echo # ... the gtid states on the slave:
88 SHOW VARIABLES LIKE 'gtid_slave_pos';
89 SHOW VARIABLES LIKE 'gtid_binlog_pos';
90 SHOW VARIABLES LIKE 'gtid_binlog_state';
91
92 --connection server_2
93 --let $case = 2
94 --echo #
95 --echo # Case:$case
96 --echo #
97 --echo # CRASH the new master, and FAILOVER back to the original
98 # value 0 for the reverse server id 2 -> 1 failover
99 --let $failover_to_slave=0
100 # Additionally through "foreign" server_id verify MDEV-27760's acceptance
101 # policy on the recient (to be promoted into master) server.
102 --let $query_to_crash = SET STATEMENT server_id=1 FOR INSERT INTO t1 VALUES (4, REPEAT("x", 4100))
103 --let $query2_to_crash= INSERT INTO t1 VALUES (5, REPEAT("x", 4100))
104 --echo # $query_to_crash
105 --echo # $query2_to_crash
106 --echo # Rows 4 and 5 will be in master's binlog but not committed, they get
107 --echo # replicated to slave and applied. On crash master should have 3 rows
108 --echo # and slave should have 5 rows.
109 --echo #
110 --echo # Expected State post crash:
111 --echo #=================================================================
112 --echo # Master | Slave |
113 --echo # 0-1-6 (Not commited) | 0-1-6 (Received through semi-sync |
114 --echo # | replication and applied) |
115 --echo # 0-2-7 (Not commited) | 0-2-7 (Received through semi-sync |
116 --echo # | replication and applied) |
117 --echo #=================================================================
118 --let $log_search_pattern=truncated binlog file:.*slave.*000002.* to remove transactions starting from GTID 0-1-6
119 --let $expected_rows_on_master= 3
120 --let $expected_rows_on_slave= 5
121 --source rpl_semi_sync_crash.inc
122
123 --echo #
124 --echo # Server_1 promoted as master will send 0-1-6 and 0-2-7 to slave Server_2
125 --echo #
126 --connection server_1
127 --let $rows_so_far=6
128 --eval INSERT INTO t1 VALUES ($rows_so_far, 'dummy6')
129 --save_master_pos
130 --echo # The gtid state on current master must be equal to ...
131 SHOW VARIABLES LIKE 'gtid_binlog_pos';
132 SHOW VARIABLES LIKE 'gtid_binlog_state';
133 SHOW VARIABLES LIKE 'gtid_slave_pos';
134
135 --connection server_2
136 --sync_with_master
137 --eval SELECT COUNT(*) 'must be $rows_so_far as' FROM t1
138 --echo # ... the gtid states on the slave:
139 SHOW VARIABLES LIKE 'gtid_slave_pos';
140 SHOW VARIABLES LIKE 'gtid_binlog_pos';
141 SHOW VARIABLES LIKE 'gtid_binlog_state';
142
143 --let $diff_tables=server_1:t1, server_2:t1
144 --source include/diff_tables.inc
145
146 --connection server_1
147 --let $case = 3
148 --echo #
149 --echo # Case:$case
150 --echo #
151 --echo # CRASH the master and FAILOVER to slave
152 --let $failover_to_slave=1
153 --let $query_to_crash = INSERT INTO t1 VALUES (7, REPEAT("x", 4100))
154 --let $query2_to_crash= INSERT INTO t1 VALUES (8, REPEAT("x", 4100))
155 --echo # $query_to_crash
156 --echo # $query2_to_crash
157 --echo # Rows 7 and 8 will be in master's binlog but not committed, only 7
158 --echo # gets replicated to slave and applied. On crash master should have 6
159 --echo # rows and slave should have 7 rows.
160 --echo #
161 --echo # Expected State post crash:
162 --echo #=================================================================
163 --echo # Master | Slave |
164 --echo # 0-1-9 (Not commited) | 0-1-9 (Received through semi-sync |
165 --echo # | replication and applied) |
166 --echo # 0-1-10 (Not commited - | |
167 --echo # never sent to slave) | |
168 --echo #=================================================================
169 --let $log_search_pattern=truncated binlog file:.*master.*000002.* to remove transactions starting from GTID 0-1-9
170 --let $expected_rows_on_master= 6
171 --let $expected_rows_on_slave= 7
172 --source rpl_semi_sync_crash.inc
173
174 --echo #
175 --echo # Server_2 promoted as master will send 0-1-9 to slave Server_1
176 --echo #
177 --connection server_2
178 --let $rows_so_far=8
179 --eval INSERT INTO t1 VALUES ($rows_so_far, 'Done')
180 --source include/save_master_gtid.inc
181 --echo # The gtid state on current master must be equal to ...
182 SHOW VARIABLES LIKE 'gtid_binlog_pos';
183 SHOW VARIABLES LIKE 'gtid_binlog_state';
184 SHOW VARIABLES LIKE 'gtid_slave_pos';
185
186 --connection server_1
187 --source include/sync_with_master_gtid.inc
188 --eval SELECT COUNT(*) 'must be $rows_so_far' FROM t1
189 --echo # ... the gtid states on the slave:
190 SHOW VARIABLES LIKE 'gtid_slave_pos';
191 SHOW VARIABLES LIKE 'gtid_binlog_pos';
192 SHOW VARIABLES LIKE 'gtid_binlog_state';
193
194 --echo #
195 --echo # Cleanup
196 --echo #
197
198 --source include/stop_slave.inc
199 set global rpl_semi_sync_slave_enabled = 0;
200 set global rpl_semi_sync_master_enabled = 0;
201 set global rpl_semi_sync_master_wait_point=default;
202 RESET MASTER;
203 RESET SLAVE;
204
205 --connection server_2
206 RESET MASTER;
207 RESET SLAVE;
208 set @@global.rpl_semi_sync_master_enabled = 0;
209 set @@global.rpl_semi_sync_slave_enabled = 0;
210 set @@global.rpl_semi_sync_master_wait_point=default;
211 evalp CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_1, master_user='root', master_use_gtid=SLAVE_POS;
212 set @@global.gtid_slave_pos=@@global.gtid_binlog_pos;
213 --source include/start_slave.inc
214
215 --connection server_1
216 DROP TABLE t1;
217 --save_master_pos
218
219 --connection server_2
220 --sync_with_master
221
222 connection default;
223 --enable_reconnect
224 --source include/wait_until_connected_again.inc
225
226 --source include/rpl_end.inc