Debian Codegraph @

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

raw
1 # ==== References ====
2 #
3 # MDEV-27760 event may non stop replicate in circular semisync setup
4 # MDEV-28609 refine gtid-strict-mode to ignore same server-id gtid from the past
5 # on semisync slave
6 --source include/have_innodb.inc
7 --source include/have_binlog_format_mixed.inc
8 --source include/master-slave.inc
9
10 connection server_2;
11 call mtr.add_suppression("Timeout waiting for reply of binlog");
12
13 # The following tests prove
14 # A.
15 # no out-of-order gtid error is done to the stict gtid mode semisync
16 # slave receives the same server-id gtid event from the past (of its gtid
17 # state). Such transaction is silently ignored similarly to
18 # replicate_same_sever_id; and
19 # B.
20 # In contrast to A. the out-of-order gtid error is thrown when a "foreign"
21 # server-id transaction makes its round-trip to the originator server.
22
23 --echo # Master server_1 and Slave server_2 initialization ...
24 --connection server_2
25 --source include/stop_slave.inc
26
27 # Initial master
28 --connection server_1
29 RESET MASTER;
30 set @@session.gtid_domain_id=10;
31 set @@global.rpl_semi_sync_master_enabled = 1;
32 set @@global.rpl_semi_sync_master_wait_point=AFTER_SYNC;
33
34 --connection server_2
35 RESET MASTER;
36 ALTER TABLE mysql.gtid_slave_pos ENGINE=InnoDB;
37 set @@session.gtid_domain_id=20;
38 set @@global.rpl_semi_sync_slave_enabled = 1;
39 --echo # a 1948 warning is expected
40 set @@global.gtid_slave_pos = "";
41 CHANGE MASTER TO master_use_gtid= slave_pos;
42 --source include/start_slave.inc
43 --echo # server_1 -> server_2 semisync link is set up.
44
45 --connection server_1
46 CREATE TABLE t1 (a INT PRIMARY KEY, b INT default 0) ENGINE=Innodb;
47 INSERT INTO t1(a) VALUES (1);
48 --source include/save_master_gtid.inc
49
50 --connection server_2
51 --source include/sync_with_master_gtid.inc
52
53 --echo # Circular configuration server_1 -> server_2 -> server_1 ...
54 --connection server_1
55 set @@global.gtid_strict_mode = true;
56 set @@global.rpl_semi_sync_slave_enabled = 1;
57
58 evalp CHANGE MASTER TO master_host='127.0.0.1', master_port=$SERVER_MYPORT_2, master_user='root', master_ssl_verify_server_cert=0, master_use_gtid=SLAVE_POS;
59 --source include/start_slave.inc
60 --echo ... is done.
61
62 --echo ## A. no out-of-order gtid error for own transaction made round trip
63
64 # A0. server_1 has already originated the transaction
65 --let $wait_condition=select @@gtid_slave_pos=@@gtid_binlog_pos
66 --source include/wait_condition.inc
67
68 # A1. server_2 originates
69 --connection server_2
70 set @@global.gtid_strict_mode = true;
71 set @@global.rpl_semi_sync_master_enabled = 1;
72
73 # The following command is likely to cause the slave master is not yet setup
74 # for semi-sync
75
76 INSERT INTO t1(a) VALUES (2);
77 --source include/save_master_gtid.inc
78
79 --connection server_1
80 # Update slave to notice that server_2 now has rpl_semi_sync_master_enabled
81 --source include/stop_slave.inc
82 --source include/start_slave.inc
83
84 --echo #
85 --echo # the successful sync is a required proof
86 --echo #
87 --source include/sync_with_master_gtid.inc
88 # A2. server_1 is originating now
89 update t1 set b=b+1 where a=2;
90 --source include/save_master_gtid.inc
91
92 --connection server_2
93 --source include/sync_with_master_gtid.inc
94
95 --echo # Post-execution state check on both servers synchronized with each other
96 --connection server_1
97 --echo # ... the gtid states on server_1
98 --let $wait_condition=select @@gtid_slave_pos=@@gtid_binlog_pos
99 --source include/wait_condition.inc
100 SHOW VARIABLES LIKE 'gtid_slave_pos';
101 SHOW VARIABLES LIKE 'gtid_binlog_pos';
102 SELECT * from t1;
103
104 --connection server_2
105 --echo # The gtid states on server_2 must be equal to ...
106 --let $wait_condition=select @@gtid_slave_pos=@@gtid_binlog_pos
107 --source include/wait_condition.inc
108 SHOW VARIABLES LIKE 'gtid_binlog_pos';
109 SHOW VARIABLES LIKE 'gtid_slave_pos';
110 SELECT * from t1;
111
112 --echo ## B. out-of-order gtid error for a "foreign" server-id transaction
113 # B1. circulation starts from server_1
114
115 --connection server_1
116 set statement sql_log_bin=0 for call mtr.add_suppression("Slave: An attempt was made to binlog GTID 10-2-4");
117 set @@session.server_id=2;
118 INSERT INTO t1(a) VALUES (3);
119 set @@session.server_id=default;
120 --source include/save_master_gtid.inc
121
122 --connection server_2
123 --source include/sync_with_master_gtid.inc
124 INSERT INTO t1(a) VALUES (4);
125 --source include/save_master_gtid.inc
126
127 --connection server_1
128 --let $slave_sql_errno = 1950
129 --source include/wait_for_slave_sql_error.inc
130 set sql_slave_skip_counter=1;
131 --source include/start_slave.inc
132 --source include/sync_with_master_gtid.inc
133
134 # B2. circulation starts from server_2
135 --connection server_2
136 set statement sql_log_bin=0 for call mtr.add_suppression("Slave: An attempt was made to binlog GTID 20-1-3");
137 set @@session.server_id=1;
138 INSERT INTO t1(a) VALUES (5);
139 set @@session.server_id=default;
140 --source include/save_master_gtid.inc
141
142 --connection server_1
143 --source include/sync_with_master_gtid.inc
144 INSERT INTO t1(a) VALUES (6);
145 --source include/save_master_gtid.inc
146
147
148 --connection server_2
149 --let $slave_sql_errno = 1950
150 --source include/wait_for_slave_sql_error.inc
151 set sql_slave_skip_counter=1;
152 --source include/start_slave.inc
153 --source include/sync_with_master_gtid.inc
154
155 --echo # Post-execution state check on both servers synchronized with each other
156 --connection server_1
157 --echo # ... the gtid states on server_1
158 --let $wait_condition=select @@gtid_slave_pos=@@gtid_binlog_pos
159 --source include/wait_condition.inc
160 SHOW VARIABLES LIKE 'gtid_slave_pos';
161 SHOW VARIABLES LIKE 'gtid_binlog_pos';
162 SELECT * from t1;
163
164 --connection server_2
165 --source include/sync_with_master_gtid.inc
166 --echo # The gtid states on server_2 must be equal to ...
167 --let $wait_condition=select @@gtid_slave_pos=@@gtid_binlog_pos
168 --source include/wait_condition.inc
169 SHOW VARIABLES LIKE 'gtid_binlog_pos';
170 SHOW VARIABLES LIKE 'gtid_slave_pos';
171 SELECT * from t1;
172
173 --echo #
174 --echo # Cleanup
175 --echo #
176 --connection server_1
177 DROP TABLE t1;
178 --source include/save_master_gtid.inc
179
180 --connection server_2
181 --source include/sync_with_master_gtid.inc
182
183 --connection server_1
184 --source include/stop_slave.inc
185 set @@global.rpl_semi_sync_master_enabled = default;
186 set @@global.rpl_semi_sync_slave_enabled = default;
187 set @@global.rpl_semi_sync_master_wait_point=default;
188 set @@global.gtid_ignore_duplicates = default;
189 set @@global.gtid_strict_mode = default;
190
191 --connection server_2
192 --source include/stop_slave.inc
193 set @@global.gtid_ignore_duplicates = default;
194 set @@global.rpl_semi_sync_master_enabled = default;
195 set @@global.rpl_semi_sync_slave_enabled = default;
196 set @@global.gtid_strict_mode = default;
197 --source include/start_slave.inc
198
199 --source include/rpl_end.inc