Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Verify the functionality of old-named semisync libraries:
4 # - old-named semisync libraries exist,
5 # - installing old-named semisync libraries generates deprecation warning
6 # - old-named semisync libraries use the old variable names,
7 # - replication works with the old-named libraries,
8 # - replication works between mixes of old and new source and replica,
9 # - it's prohibited to load both old and new source libraries or
10 # both old and new replica libraries on the same node at the same time.
11 #
12 # ==== Requirements ====
13 #
14 # R1. old source library uses old variable names and new source library
15 # uses new variable names
16 # R2. old replica library uses old variable names and new replica library
17 # uses new variable names
18 # R3. replication old source library -> old replica library shall work
19 # R4. replication old source library -> new replica library shall work
20 # R5. replication new source library -> old replica library shall work
21 # R6. old source library and new replica library installed on
22 # the same node shall work.
23 # R7. new source library and old replica library installed on
24 # the same node shall work.
25 # R8. mixing old and new source library or old and new replica library
26 # on the same node gives an error:
27 # R6.1. Error installing first old source and then new source.
28 # R6.2. Error installing first new source and then old source.
29 # R6.3. Error installing first old replica and then new replica.
30 # R6.4. Error installing first new replica and then old replica.
31 # The above errors shall be generated in the following contexts:
32 # a) when installing libraries dynamically using INSTALL PLUGIN
33 # b) when installing libraries on server start using --plugin-load
34 # c) when installing libraries on server start using --init-file
35 # R9. Installing the old libraries shall generate deprecation warnings:
36 # 9.1. when installing libraries dynamically using INSTALL PLUGIN
37 # 9.2. when installing libraries on server start using --plugin-load
38 # 9.3. when installing libraries on server start using --init-file
39
40 # Test is binlog_format-agnostic
41 --source include/have_binlog_format_row.inc
42
43 --source include/master-slave.inc
44
45 --echo ==== Setup ====
46
47 --source include/save_error_log_position.inc
48
49 CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT);
50 --source include/sync_slave_sql_with_master.inc
51 --source include/save_error_log_position.inc
52
53 --source include/stop_slave.inc
54 --source include/rpl_connection_master.inc
55 --source include/stop_dump_threads.inc
56
57 let $messages =
58 .*A message intended for a client cannot be sent there as no client-session is attached.*Got an error reading communication packets.*
59 ;
60 --source include/suppress_messages.inc
61
62 --let $messages = rpl_semi_sync.*is deprecated and will be removed in a future release.*
63 --let $suppress_mode = IGNORE_GLOBAL_SUPPRESSIONS
64 --source include/suppress_messages.inc
65
66 --let $_enabled_text = _enabled
67 --let $_status_text = _status
68 --let $_yes_tx_text = _yes_tx
69 --let $assert_escape = 1
70
71 --let $extra_debug_sql = SHOW STATUS LIKE 'rpl_semi_sync_%'
72
73 --let $proc_dir = $MYSQLTEST_VARDIR/tmp
74
75 # $install_plugins
76 # Install plugins on both servers, using names specified by parameters.
77 #
78 # Parameters:
79 # - $source_name - master or source, the term to use for the source library
80 # - $replica_name - slave or replica, the term to use for the replica library
81 # - $source_connection - the connection to use to install the source library
82 # - $replica_connection - the connection to use to install the replica library
83 --let $install_plugins = $proc_dir/install_plugins.inc
84 --write_file $install_plugins END_OF_PROCEDURE
85 --let $rpl_connection_name = $source_connection
86 --source include/rpl_connection.inc
87 if ($source_name == master) {
88 --replace_result $SEMISYNC_MASTER_PLUGIN SEMISYNC_MASTER_PLUGIN
89 eval INSTALL PLUGIN rpl_semi_sync_master SONAME '$SEMISYNC_MASTER_PLUGIN';
90 --let $error_pattern = .*rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
91 --source include/assert_error_log.inc
92 }
93 if ($source_name == source) {
94 --replace_result $SEMISYNC_SOURCE_PLUGIN SEMISYNC_SOURCE_PLUGIN
95 eval INSTALL PLUGIN rpl_semi_sync_source SONAME '$SEMISYNC_SOURCE_PLUGIN';
96 }
97 --echo # R1. source variable name matches source library name
98 eval SET @@global.rpl_semi_sync_$source_name$_enabled_text = 1;
99
100 --let $rpl_connection_name = $replica_connection
101 --source include/rpl_connection.inc
102 if ($replica_name == slave) {
103 --replace_result $SEMISYNC_SLAVE_PLUGIN SEMISYNC_SLAVE_PLUGIN
104 eval INSTALL PLUGIN rpl_semi_sync_slave SONAME '$SEMISYNC_SLAVE_PLUGIN';
105 --let $error_pattern = .*rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
106 --source include/assert_error_log.inc
107 }
108 if ($replica_name == replica) {
109 --replace_result $SEMISYNC_REPLICA_PLUGIN SEMISYNC_REPLICA_PLUGIN
110 eval INSTALL PLUGIN rpl_semi_sync_replica SONAME '$SEMISYNC_REPLICA_PLUGIN';
111 }
112 --echo # R2. replica variable name matches replica library name
113 eval SET @@global.rpl_semi_sync_$replica_name$_enabled_text = 1;
114 END_OF_PROCEDURE
115
116 # $uninstall_plugins
117 # Uninstall plugins on both servers, using names specified by parameters.
118 # Parameters:
119 # - $source_name - master or source, the term to use for the source library
120 # - $replica_name - slave or replica, the term to use for the replica library
121 # - $source_connection - the connection to use to install the source library
122 # - $replica_connection - the connection to use to install the replica library
123 --let $uninstall_plugins = $proc_dir/uninstall_plugins.inc
124 --write_file $uninstall_plugins END_OF_PROCEDURE
125 --let $rpl_connection_name = $source_connection
126 --source include/rpl_connection.inc
127 --source include/stop_dump_threads.inc
128 eval UNINSTALL PLUGIN rpl_semi_sync_$source_name;
129
130 --let $rpl_connection_name = $replica_connection
131 --source include/rpl_connection.inc
132 --source include/stop_dump_threads.inc
133 eval UNINSTALL PLUGIN rpl_semi_sync_$replica_name;
134 END_OF_PROCEDURE
135
136 # $check_replication
137 #
138 # Verifies that semisync replication works for one transaction:
139 # - The replica applies the transaction
140 # - The source receives an ack,
141 # - The plugins remain enabled.
142 #
143 # Parameters:
144 # $source_name - "master" or "source", the name to use to check that
145 # the library is loaded.
146 # $replica_name - "slave" or "replica", the name to use to check that
147 # the library is loaded.
148 # $replica_connection - The connection to the replica - usually "slave",
149 # but use "master" to reverse the direction.
150 # $source_connection - The connection to the source - usually "master",
151 # but use "slave" to reverse the direction.
152 --let $check_replication = $proc_dir/check_replication.inc
153 --write_file $check_replication END_OF_PROCEDURE
154 --let $rpl_connection_name = $replica_connection
155 --source include/rpl_connection.inc
156 --source include/start_slave.inc
157
158 --let $rpl_connection_name = $source_connection
159 --source include/rpl_connection.inc
160
161 --let $assert_cond = '[SHOW STATUS LIKE 'Rpl_semi_sync_$source_name$_yes_tx_text', Value, 1]' = '0'
162 --let $assert_text = Initially no acked transactions
163 --source include/assert.inc
164
165 INSERT INTO t1() VALUES ();
166
167 --let $assert_cond = [SHOW STATUS LIKE 'Rpl_semi_sync_$source_name$_yes_tx_text', Value, 1] = 1
168 --let $assert_text = After one transaction is committed, one transaction got acked
169 --source include/assert.inc
170
171 --let $sync_slave_connection = $replica_connection
172 --source include/sync_slave_sql_with_master.inc
173 --let $sync_slave_connection =
174
175 --let $rpl_connection_name = $source_connection
176 --source include/rpl_connection.inc
177
178 --let $assert_cond = '[SHOW STATUS LIKE 'Rpl_semi_sync_$source_name$_status_text', Value, 1]' = 'ON'
179 --let $assert_text = Semisync $source_name library should remain enabled on $source_connection
180 --source include/assert.inc
181
182 --let $rpl_connection_name = $replica_connection
183 --source include/rpl_connection.inc
184
185 --let $assert_cond = '[SHOW STATUS LIKE 'Rpl_semi_sync_$replica_name$_status_text', Value, 1]' = 'ON'
186 --let $assert_text = Semisync $replica_name library should remain enabled on $replica_connection
187 --source include/assert.inc
188
189 --source include/stop_slave.inc
190 END_OF_PROCEDURE
191
192 --echo ==== R3. Replication: old source library -> old replica library ====
193
194 --let $source_connection = master
195 --let $replica_connection = slave
196
197 --let $source_name = master
198 --let $replica_name = slave
199 --source $install_plugins
200 --source $check_replication
201 --source $uninstall_plugins
202
203 --echo ==== R4. Replication: old source library -> new replica library ====
204
205 --let $source_name = master
206 --let $replica_name = replica
207 --source $install_plugins
208 --source $check_replication
209 --source $uninstall_plugins
210
211 --echo ==== R5. Replication: new source library -> old replica library ====
212
213 --let $source_name = source
214 --let $replica_name = slave
215 --source $install_plugins
216 --source $check_replication
217 --source $uninstall_plugins
218
219 --echo ==== R6. New source and old replica on the same node works, and R7. Old source and new replica on the same node works ====
220
221 --echo # Reconfigure toplogy and install plugins.
222
223 # Use a topology like:
224 #
225 # master ------> slave
226 # 1 2
227 # replica <---- source
228 #
229 # Do not enable semisync on both connections at the same time, since
230 # semisync doesn't work with circular replication. When the replica
231 # commits a replicated transaction, it waits for an ack from the
232 # source in the reverse replication channel. But the source filters
233 # out the transaction because it was already applied, so no ack will
234 # arrive, and so semisync times out.
235
236 --let $rpl_topology = 1->2->1
237 --source include/rpl_change_topology.inc
238
239 --let $source_name = master
240 --let $replica_name = slave
241 --source $install_plugins
242
243 --let $source_connection = slave
244 --let $replica_connection = master
245 --let $source_name = source
246 --let $replica_name = replica
247 --source $install_plugins
248
249 --echo # Check that replication works in the usual direction
250
251 --connection slave
252 SET @@global.rpl_semi_sync_source_enabled = 0;
253 --connection master
254 SET @@global.rpl_semi_sync_replica_enabled = 0;
255
256 --let $source_connection = master
257 --let $replica_connection = slave
258 --let $source_name = master
259 --let $replica_name = slave
260 --source $check_replication
261
262 --echo # Check that replication works in reverse direction
263
264 --connection master
265 SET @@global.rpl_semi_sync_replica_enabled = 1;
266 SET @@global.rpl_semi_sync_master_enabled = 0;
267 --connection slave
268 SET @@global.rpl_semi_sync_source_enabled = 1;
269 SET @@global.rpl_semi_sync_slave_enabled = 0;
270
271 --let $source_connection = slave
272 --let $replica_connection = master
273 --let $source_name = source
274 --let $replica_name = replica
275 --source $check_replication
276
277 --echo # Uninstall plugins
278
279 --let $source_connection = master
280 --let $replica_connection = slave
281 --let $source_name = master
282 --let $replica_name = slave
283 --source $uninstall_plugins
284
285 --let $source_connection = slave
286 --let $replica_connection = master
287 --let $source_name = source
288 --let $replica_name = replica
289 --source $uninstall_plugins
290
291 --echo ==== R8. Error installing conflicting plugins. ====
292
293 # $check_install_plugin_conflict
294 #
295 # Installs a semisync library and then installs the other duplicate
296 # library (new vs old name). Verifies that the second INSTALL
297 # generates an error, that the first library remains installed, and
298 # that the second library remains not installed.
299 #
300 # Parameters:
301 # $plugin1 - Suffix of first plugin: "source", "master", "replica", or "slave".
302 # $plugin2 - Suffix of second plugin: "source", "master", "replica", or "slave".
303 # $library1 - Full name of first library: one of the environment variables
304 # $SEMISYNC_SOURCE_PLUGIN etc.
305 # $library2 - Full name of second library: one of the environment variables
306 # $SEMISYNC_SOURCE_PLUGIN etc.
307 --let $check_install_plugin_conflict = $proc_dir/check_install_plugin_conflict.inc
308 --write_file $check_install_plugin_conflict END_OF_PROCEDURE
309 --echo * Case a) Use INSTALL PLUGIN dynamically
310 --replace_result $library1 PLUGIN_NAME
311 eval INSTALL PLUGIN rpl_semi_sync_$plugin1 SONAME '$library1';
312 --echo # R9.1. deprecation warnings for dynamic plugin load using INSTALL PLUGIN
313 if ($plugin1 == master) {
314 --let $error_pattern = .rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
315 --source include/assert_error_log.inc
316 }
317 if ($plugin1 == slave) {
318 --let $error_pattern = .rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
319 --source include/assert_error_log.inc
320 }
321 --replace_result $library2 PLUGIN_NAME
322 --error ER_INSTALL_PLUGIN_CONFLICT_CLIENT
323 eval INSTALL PLUGIN rpl_semi_sync_$plugin2 SONAME '$library2';
324 --let $error_pattern = Plugin 'rpl_semi_sync_$plugin2' init function returned error.
325 --source include/assert_error_log.inc
326 --let $assert_text = rpl_semi_sync_$plugin1 should remain installed
327 --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE 'rpl_semi_sync_$plugin1%'] > 0
328 --source include/assert.inc
329 --let $assert_text = rpl_semi_sync_$plugin2 should not be installed
330 --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE 'rpl_semi_sync_$plugin2%'] = 0
331 --source include/assert.inc
332 eval UNINSTALL PLUGIN rpl_semi_sync_$plugin1;
333
334 --echo * Case b) Restart server with --plugin-load
335 --let $rpl_server_parameters = --plugin-load=rpl_semi_sync_$plugin1=$library1;rpl_semi_sync_$plugin2=$library2
336 --let $rpl_omit_print_server_parameters = 1
337 --let $rpl_server_number = 1
338 --source include/rpl_restart_server.inc
339 let $error_pattern =
340 Cannot install the rpl_semi_sync_$plugin1 plugin when the rpl_semi_sync_$plugin2 plugin is installed.
341 Plugin .rpl_semi_sync_$plugin1. init function returned error.
342 Cannot install the rpl_semi_sync_$plugin2 plugin when the rpl_semi_sync_$plugin1 plugin is installed.
343 Plugin .rpl_semi_sync_$plugin2. init function returned error.
344 ;
345 --source include/assert_error_log.inc
346 --let $assert_text = No semisync plugin should be installed
347 --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE 'rpl_semi_sync_%'] = 0
348 --source include/assert.inc
349
350 --echo * Case c) Restart server with --init-file
351 --delimiter ||
352 let $write_var = escape(\',
353 INSTALL PLUGIN rpl_semi_sync_$plugin1 SONAME '$library1';
354 INSTALL PLUGIN rpl_semi_sync_$plugin2 SONAME '$library2';
355 )||
356 --delimiter ;
357
358 --let $write_to_file = GENERATE
359 --source include/write_var_to_file.inc
360 --let $init_file = $write_to_file
361 --let $write_to_file =
362 --let $rpl_server_parameters = --init-file=$init_file
363 --let $rpl_omit_print_server_parameters = 1
364 --let $rpl_server_number = 1
365 --source include/rpl_restart_server.inc
366
367 --remove_file $init_file
368
369 --echo # R9.3. deprecation warnings for --init-file
370 --let $error_pattern =
371 if ($plugin1 == master) {
372 --let $error_pattern = .rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
373 }
374 if ($plugin1 == slave) {
375 --let $error_pattern = .rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
376 }
377 let $error_pattern = $error_pattern
378 Plugin 'rpl_semi_sync_$plugin2' init function returned error.
379 Cannot install the rpl_semi_sync_$plugin2 plugin when the rpl_semi_sync_$plugin1 plugin is installed.
380 ;
381 --source include/assert_error_log.inc
382
383 eval UNINSTALL PLUGIN rpl_semi_sync_$plugin1;
384
385 END_OF_PROCEDURE
386
387 --echo ==== R8.1 Error installing first old and then new source library ====
388
389 --let $plugin1 = master
390 --let $library1 = $SEMISYNC_MASTER_PLUGIN
391 --let $plugin2 = source
392 --let $library2 = $SEMISYNC_SOURCE_PLUGIN
393 --source $check_install_plugin_conflict
394
395 --echo ==== R8.2 Error installing first new and then old source library ====
396
397 --let $plugin1 = source
398 --let $library1 = $SEMISYNC_SOURCE_PLUGIN
399 --let $plugin2 = master
400 --let $library2 = $SEMISYNC_MASTER_PLUGIN
401 --source $check_install_plugin_conflict
402
403 --echo ==== R8.3. Error installing first old and then new replica library ====
404
405 --let $plugin1 = slave
406 --let $library1 = $SEMISYNC_SLAVE_PLUGIN
407 --let $plugin2 = replica
408 --let $library2 = $SEMISYNC_REPLICA_PLUGIN
409 --source $check_install_plugin_conflict
410
411 --echo ==== R8.4. Error installing first new and then old replica library ====
412
413 --let $plugin1 = replica
414 --let $library1 = $SEMISYNC_REPLICA_PLUGIN
415 --let $plugin2 = slave
416 --let $library2 = $SEMISYNC_SLAVE_PLUGIN
417 --source $check_install_plugin_conflict
418
419 --echo ==== R9.2. Deprecation warnings generated for --plugin-load ====
420
421 --let $rpl_server_parameters = --plugin-load=rpl_semi_sync_master=$SEMISYNC_MASTER_PLUGIN;rpl_semi_sync_slave=$SEMISYNC_SLAVE_PLUGIN
422 --let $rpl_omit_print_server_parameters = 1
423 --let $rpl_server_number = 1
424 --source include/rpl_restart_server.inc
425 let $error_pattern =
426 .rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
427 .rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
428 ;
429 --source include/assert_error_log.inc
430
431 --echo ==== Clean up ====
432
433 --let $rpl_server_number = 1
434 --let $rpl_server_parameters =
435 --source include/rpl_restart_server.inc
436
437 --source include/rpl_connection_slave.inc
438 --source include/start_slave.inc
439 --source include/rpl_connection_master.inc
440 # Since we configured replication 1->2->1, let replication start on
441 # source too, to make rpl_end.inc happy. It will auto-start on
442 # the previous rpl_restart_server.inc, since mysqld.1 is not configured
443 # with --skip-replica-start, so we just need to wait for it to happen.
444 --source include/wait_for_slave_to_start.inc
445 DROP TABLE t1;
446 --source include/sync_slave_sql_with_master.inc
447
448 --source include/rpl_end.inc
449
450 --remove_file $install_plugins
451 --remove_file $uninstall_plugins
452 --remove_file $check_replication
453 --remove_file $check_install_plugin_conflict