Debian Codegraph @

mysql-test/suite/rpl_gtid/t/rpl_gtids_table_disable_binlog_on_slave.test

raw
1 #
2 # ==== Purpose ====
3 #
4 # WL#6559 Optimize GTIDs for passive slave - store GTIDs in table
5 #
6 # Verify that we can store gtids into gtid_executed table for XA transactions
7 # on binlog rotation when binlog is enabled, store gtid into gtid_executed
8 # table within each transaction and report GLOBAL.GTID_EXECUTED and
9 # GLOBAL.GTID_PURGED correctly when binlog is disabled.
10 #
11
12 --source include/have_myisam.inc
13 --source include/not_group_replication_plugin.inc
14
15 # required by extra/rpl_tests/rpl_xa_gtid_next.inc
16
17 --source include/have_debug.inc
18 --source include/have_debug_sync.inc
19 --source include/set_privilege_checks_user_as_system_user.inc
20 --source include/master-slave.inc
21
22 --let $master_uuid= `SELECT @@GLOBAL.SERVER_UUID`
23
24 CREATE TABLE IF NOT EXISTS t1 (a INT) ENGINE=InnoDB;
25 CREATE TABLE t2 (a INT) ENGINE=MyISAM;
26
27 --echo #
28 --echo # Verify that XA transactions' gtids can be reported
29 --echo # from global.gtid_executed correctly.
30 --echo #
31 INSERT INTO t2 VALUES(1);
32 XA START '1';
33 --disable_warnings
34 INSERT INTO t2 VALUES(2);
35 INSERT INTO t1 VALUES(1);
36 INSERT INTO t1 VALUES(2);
37 --enable_warnings
38 XA END '1';
39 XA PREPARE '1';
40 XA COMMIT '1';
41 --let $gno_0 = 6
42 --let $gno_root = 1-$gno_0
43 --let $expected_gtid_root = $master_uuid:$gno_root
44 --let $expected_gtid = $expected_gtid_root
45 --let $assert_text= committed gtids SOURCE_UUID:$gno_root
46 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$expected_gtid"
47 --source include/assert.inc
48
49 --echo #
50 --echo # Verify that specified gtid for XA transaction can be reported
51 --echo # from global.gtid_executed correctly.
52 --echo #
53 --let $gno_1 = 17
54 --replace_result $master_uuid SOURCE_UUID
55 --eval SET @@SESSION.GTID_NEXT= '$master_uuid:$gno_1'
56 XA START '1';
57 --disable_warnings
58 INSERT INTO t1 VALUES(3);
59 --enable_warnings
60 XA END '1';
61 XA PREPARE '1';
62 --let $gno_2 = $gno_1
63 --inc $gno_2
64 --replace_result $master_uuid SOURCE_UUID
65 --eval SET @@SESSION.GTID_NEXT= '$master_uuid:$gno_2'
66 XA COMMIT '1';
67 --let $expected_gtid=$expected_gtid_root:$gno_1-$gno_2
68 --let $assert_text= committed gtids SOURCE_UUID:$gno_root:$gno_1-$gno_2
69 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$expected_gtid"
70 --source include/assert.inc
71
72 --echo #
73 --echo # Verify that we can store gtids SOURCE_UUID:$gno_root:16 in gtid_executed
74 --echo # table for XA transactions on binlog rotation.
75 --echo #
76 --eval SET GTID_NEXT='AUTOMATIC'
77 FLUSH LOGS;
78 --replace_result $master_uuid SOURCE_UUID
79 SELECT * FROM mysql.gtid_executed;
80
81
82 --source include/sync_slave_sql_with_master.inc
83 --echo #
84 --echo # connection slave
85 --echo #
86 call mtr.add_suppression("You need to use --log-bin to make --binlog-format work");
87 call mtr.add_suppression("Replica SQL for channel '': Error in Xid_log_event: Commit could not "
88 "be completed, 'Got error -1 - 'Unknown error.*' from storage engine', "
89 "Error_code: MY-001030");
90 call mtr.add_suppression("Replica.*Got error -1 .* from storage engine.*Error_code: MY-001030");
91 call mtr.add_suppression("Replica: An error occurred at storing the GTID value");
92 call mtr.add_suppression("The replica coordinator and worker threads are stopped");
93
94 --let $assert_text= committed gtids SOURCE_UUID:$gno_root:$gno_1-$gno_2
95 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$expected_gtid"
96 --source include/assert.inc
97 --echo #
98 --echo # Verify that the transaction is skiped if its specified gtid
99 --echo # is already in global.gtid_executed.
100 --echo #
101 --replace_result $master_uuid SOURCE_UUID
102 --eval SET @@SESSION.GTID_NEXT= '$master_uuid:4'
103 INSERT INTO t1 VALUES(11);
104 --let $assert_text= Table t1 must not contain 11
105 --let $assert_cond= "[SELECT a FROM t1 WHERE a=11]" = ""
106 --source include/assert.inc
107
108 --echo #
109 --echo # Verify that the specified gtid to GTID_NEXT is stored into
110 --echo # global.gtid_executed and gtid_executed table.
111 --echo #
112 --inc $gno_2
113 --replace_result $master_uuid SOURCE_UUID
114 --eval SET @@SESSION.GTID_NEXT= '$master_uuid:$gno_2'
115 COMMIT;
116 --let $expected_gtid=$expected_gtid_root:$gno_1-$gno_2
117 --let $assert_text= committed gtids SOURCE_UUID:$gno_root:$gno_1-$gno_2
118 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$expected_gtid"
119 --source include/assert.inc
120
121 # GTID is persisted now in batches by Innodb background thread. Number of
122 # rows in gtid_executed could vary and should check only after compressing.
123 #--echo #
124 #--echo # Verify that we store gtid into gtid_executed table within
125 #--echo # each transaction when binlog is disabled.
126 #--echo #
127 #--replace_result $master_uuid SOURCE_UUID
128 #SELECT * FROM mysql.gtid_executed;
129
130 --echo #
131 --echo # Verify that the gtid_executed table is compressed.
132 --echo #
133 SET @debug_save= @@GLOBAL.DEBUG;
134 SET @@GLOBAL.DEBUG= '+d,compress_gtid_table';
135 --inc $gno_2
136 --replace_result $master_uuid SOURCE_UUID
137 --eval SET @@SESSION.GTID_NEXT= '$master_uuid:$gno_2'
138 COMMIT;
139 --eval SET GTID_NEXT='AUTOMATIC'
140
141 --echo # Trigger compression explicitly
142 FLUSH LOGS;
143 SET DEBUG_SYNC='now WAIT_FOR complete_compression';
144 SET GLOBAL DEBUG= @debug_save;
145 --replace_result $master_uuid SOURCE_UUID
146 SELECT * FROM mysql.gtid_executed;
147
148 --echo #
149 --echo # Verify that gtid_executed and gtid_purged are always same
150 --echo # when binlog is disabled.
151 --echo #
152 --let $assert_text= gtid_executed and gtid_purged are always same when binlog is disabled
153 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "[SELECT @@GLOBAL.GTID_PURGED]"
154 --source include/assert.inc
155
156 --echo #
157 --echo # Verify that no gtid is generated for transaction
158 --echo # when binlog is disabled
159 --echo #
160 CREATE TABLE t3 (a INT);
161 INSERT INTO t1 VALUES(12);
162 DROP TABLE t3;
163
164 --echo #
165 --echo # Stored gtids SOURCE_UUID:$gno_root:$gno_1-$gno_2 in gtid_executed table
166 --echo # on slave.
167 --replace_result $master_uuid SOURCE_UUID
168 --eval SELECT * FROM mysql.gtid_executed
169
170 #
171 # Check out XA COMMIT,ROLLBACK with Gtid_next having either automatic
172 # and manual value.
173 #
174 --let $gno_0 = `SELECT $gno_0 + 2`
175 --let $conclude_as = COMMIT
176 --let $gtid_phase1 =
177 --let $gtid_phase2 =
178 --source extra/rpl_tests/rpl_xa_gtid_next.inc
179
180 --let $gno_0 = `SELECT $gno_0 + 2`
181 --let $conclude_as = ROLLBACK
182 --let $gtid_phase1 =
183 --let $gtid_phase2 =
184 --source extra/rpl_tests/rpl_xa_gtid_next.inc
185
186 --let $gno_0 = `SELECT $gno_0 + 1`
187 --inc $gno_2
188 --let $conclude_as = ROLLBACK
189 --let $gtid_phase1 =
190 --let $gtid_phase2 = $master_uuid:$gno_2
191 --source extra/rpl_tests/rpl_xa_gtid_next.inc
192
193 --let $gno_0 = `SELECT $gno_0 + 1`
194 --inc $gno_2
195 --let $conclude_as = ROLLBACK
196 --let $gtid_phase1 = $master_uuid:$gno_2
197 --let $gtid_phase2 =
198 # Error to run set @@gtid_next prior to XA $conclude_as is simulated
199 --let $xa_error_simul = 1
200 --source extra/rpl_tests/rpl_xa_gtid_next.inc
201
202 # Three more GTIDs are generated in what follows, two of them from DROP
203 # TABLE.
204 --let $gno_0 = `SELECT $gno_0 + 3`
205 DROP TABLE t1, t2;
206 --source include/sync_slave_sql_with_master.inc
207
208 --connection master
209 CREATE TABLE t3 (a INT);
210 --source include/sync_slave_sql_with_master.inc
211 # simulate_err_on_write_gtid_into_table would disable gtid background.
212 FLUSH LOGS;
213 --echo #
214 --echo # Verify that transaction's gtid is not stored into gtid_executed table
215 --echo # and the transaction is rolled back if we encounter an error
216 --echo # when writing gtid into table when binlog is disabled and
217 --echo # gtid_mode is enabled.
218 --echo #
219 SET @@GLOBAL.DEBUG= '+d,simulate_err_on_write_gtid_into_table';
220 --connection master
221 INSERT INTO t3 VALUES(1);
222 --connection slave
223 --let $slave_sql_errno= convert_error(ER_GET_ERRNO)
224 --source include/wait_for_slave_sql_error.inc
225 SET GLOBAL DEBUG= @debug_save;
226 --source include/stop_slave_io.inc
227 # two queries contributed to the rhs
228 --let $gno_root = 1-$gno_0
229 --let $expected_gtid_root= $master_uuid:$gno_root
230 --let $expected_gtid = $expected_gtid_root:$gno_1-$gno_2
231 --echo #
232 --echo # Stored gtids SOURCE_UUID:$gno_root:$gno_1-$gno_2 in gtid_executed table on slave.
233 --echo #
234 # GTID is persisted now in batches by Innodb background thread. Number of
235 # rows in gtid_executed could vary and should check only after compressing.
236 #--replace_result $master_uuid SOURCE_UUID
237 #--eval SELECT * FROM mysql.gtid_executed
238 --let $assert_text= committed gtids SOURCE_UUID:$gno_root:$gno_1-$gno_2
239 --let $assert_cond= "[SELECT @@GLOBAL.GTID_EXECUTED]" = "$expected_gtid"
240 --source include/assert.inc
241 --let $assert_text= Table t3 must not contain 1
242 --let $assert_cond= "[SELECT a FROM t3 WHERE a=1]" = ""
243 --source include/assert.inc
244
245 --echo #
246 --echo # Verify that the gtid_executed table is compressed.
247 --echo #
248 SET @debug_save= @@GLOBAL.DEBUG;
249 SET @@GLOBAL.DEBUG= '+d,compress_gtid_table';
250 --inc $gno_2
251 --replace_result $master_uuid SOURCE_UUID
252 --eval SET @@SESSION.GTID_NEXT= '$master_uuid:$gno_2'
253 COMMIT;
254 --eval SET GTID_NEXT='AUTOMATIC'
255
256 --echo # Trigger compression explicitly
257 FLUSH LOGS;
258 SET DEBUG_SYNC='now WAIT_FOR complete_compression';
259 SET GLOBAL DEBUG= @debug_save;
260 --replace_result $master_uuid SOURCE_UUID
261 SELECT * FROM mysql.gtid_executed;
262
263 --connection master
264 DROP TABLE t3;
265 CALL mtr.add_suppression("Statement is unsafe because it is being used inside a XA transaction");
266 --connection slave
267 DROP TABLE t3;
268 CALL mtr.add_suppression("Statement is unsafe because it is being used inside a XA transaction");
269 # We are intentionally making Slave ahead of Master
270 # which is not allowed after fix for bug#18789758.
271 # Since we are at cleanup stage only, we can
272 # ignore the error here in this test script.
273 RESET SLAVE;
274 --let $rpl_only_running_threads= 1
275
276 --source include/rpl_end.inc