File: rpl_semi_sync_alias.test

package info (click to toggle)
mysql-8.0 8.0.43-3
  • links: PTS, VCS
  • area: main
  • in suites: sid
  • size: 1,273,924 kB
  • sloc: cpp: 4,684,605; ansic: 412,450; pascal: 108,398; java: 83,641; perl: 30,221; cs: 27,067; sql: 26,594; sh: 24,181; python: 21,816; yacc: 17,169; php: 11,522; xml: 7,388; javascript: 7,076; makefile: 2,194; lex: 1,075; awk: 670; asm: 520; objc: 183; ruby: 97; lisp: 86
file content (453 lines) | stat: -rw-r--r-- 18,194 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
# ==== Purpose ====
#
# Verify the functionality of old-named semisync libraries:
# - old-named semisync libraries exist,
# - installing old-named semisync libraries generates deprecation warning
# - old-named semisync libraries use the old variable names,
# - replication works with the old-named libraries,
# - replication works between mixes of old and new source and replica,
# - it's prohibited to load both old and new source libraries or
#   both old and new replica libraries on the same node at the same time.
#
# ==== Requirements ====
#
# R1. old source library uses old variable names and new source library
#     uses new variable names
# R2. old replica library uses old variable names and new replica library
#     uses new variable names
# R3. replication old source library -> old replica library shall work
# R4. replication old source library -> new replica library shall work
# R5. replication new source library -> old replica library shall work
# R6. old source library and new replica library installed on
#     the same node shall work.
# R7. new source library and old replica library installed on
#     the same node shall work.
# R8. mixing old and new source library or old and new replica library
#     on the same node gives an error:
#     R6.1. Error installing first old source and then new source.
#     R6.2. Error installing first new source and then old source.
#     R6.3. Error installing first old replica and then new replica.
#     R6.4. Error installing first new replica and then old replica.
#     The above errors shall be generated in the following contexts:
#     a) when installing libraries dynamically using INSTALL PLUGIN
#     b) when installing libraries on server start using --plugin-load
#     c) when installing libraries on server start using --init-file
# R9. Installing the old libraries shall generate deprecation warnings:
#     9.1. when installing libraries dynamically using INSTALL PLUGIN
#     9.2. when installing libraries on server start using --plugin-load
#     9.3. when installing libraries on server start using --init-file

# Test is binlog_format-agnostic
--source include/have_binlog_format_row.inc

--source include/master-slave.inc

--echo ==== Setup ====

--source include/save_error_log_position.inc

CREATE TABLE t1 (a INT PRIMARY KEY AUTO_INCREMENT);
--source include/sync_slave_sql_with_master.inc
--source include/save_error_log_position.inc

--source include/stop_slave.inc
--source include/rpl_connection_master.inc
--source include/stop_dump_threads.inc

let $messages =
.*A message intended for a client cannot be sent there as no client-session is attached.*Got an error reading communication packets.*
;
--source include/suppress_messages.inc

--let $messages = rpl_semi_sync.*is deprecated and will be removed in a future release.*
--let $suppress_mode = IGNORE_GLOBAL_SUPPRESSIONS
--source include/suppress_messages.inc

--let $_enabled_text = _enabled
--let $_status_text = _status
--let $_yes_tx_text = _yes_tx
--let $assert_escape = 1

--let $extra_debug_sql = SHOW STATUS LIKE 'rpl_semi_sync_%'

--let $proc_dir = $MYSQLTEST_VARDIR/tmp

# $install_plugins
# Install plugins on both servers, using names specified by parameters.
#
# Parameters:
# - $source_name - master or source, the term to use for the source library
# - $replica_name - slave or replica, the term to use for the replica library
# - $source_connection - the connection to use to install the source library
# - $replica_connection - the connection to use to install the replica library
--let $install_plugins = $proc_dir/install_plugins.inc
--write_file $install_plugins END_OF_PROCEDURE
  --let $rpl_connection_name = $source_connection
  --source include/rpl_connection.inc
  if ($source_name == master) {
    --replace_result $SEMISYNC_MASTER_PLUGIN SEMISYNC_MASTER_PLUGIN
    eval INSTALL PLUGIN rpl_semi_sync_master SONAME '$SEMISYNC_MASTER_PLUGIN';
    --let $error_pattern = .*rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
    --source include/assert_error_log.inc
  }
  if ($source_name == source) {
    --replace_result $SEMISYNC_SOURCE_PLUGIN SEMISYNC_SOURCE_PLUGIN
    eval INSTALL PLUGIN rpl_semi_sync_source SONAME '$SEMISYNC_SOURCE_PLUGIN';
  }
  --echo # R1. source variable name matches source library name
  eval SET @@global.rpl_semi_sync_$source_name$_enabled_text = 1;

  --let $rpl_connection_name = $replica_connection
  --source include/rpl_connection.inc
  if ($replica_name == slave) {
    --replace_result $SEMISYNC_SLAVE_PLUGIN SEMISYNC_SLAVE_PLUGIN
    eval INSTALL PLUGIN rpl_semi_sync_slave SONAME '$SEMISYNC_SLAVE_PLUGIN';
    --let $error_pattern = .*rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
    --source include/assert_error_log.inc
  }
  if ($replica_name == replica) {
    --replace_result $SEMISYNC_REPLICA_PLUGIN SEMISYNC_REPLICA_PLUGIN
    eval INSTALL PLUGIN rpl_semi_sync_replica SONAME '$SEMISYNC_REPLICA_PLUGIN';
  }
  --echo # R2. replica variable name matches replica library name
  eval SET @@global.rpl_semi_sync_$replica_name$_enabled_text = 1;
END_OF_PROCEDURE

# $uninstall_plugins
# Uninstall plugins on both servers, using names specified by parameters.
# Parameters:
# - $source_name - master or source, the term to use for the source library
# - $replica_name - slave or replica, the term to use for the replica library
# - $source_connection - the connection to use to install the source library
# - $replica_connection - the connection to use to install the replica library
--let $uninstall_plugins = $proc_dir/uninstall_plugins.inc
--write_file $uninstall_plugins END_OF_PROCEDURE
  --let $rpl_connection_name = $source_connection
  --source include/rpl_connection.inc
  --source include/stop_dump_threads.inc
  eval UNINSTALL PLUGIN rpl_semi_sync_$source_name;

  --let $rpl_connection_name = $replica_connection
  --source include/rpl_connection.inc
  --source include/stop_dump_threads.inc
  eval UNINSTALL PLUGIN rpl_semi_sync_$replica_name;
END_OF_PROCEDURE

# $check_replication
#
# Verifies that semisync replication works for one transaction:
# - The replica applies the transaction
# - The source receives an ack,
# - The plugins remain enabled.
#
# Parameters:
# $source_name - "master" or "source", the name to use to check that
#   the library is loaded.
# $replica_name - "slave" or "replica", the name to use to check that
#   the library is loaded.
# $replica_connection - The connection to the replica - usually "slave",
#   but use "master" to reverse the direction.
# $source_connection - The connection to the source - usually "master",
#   but use "slave" to reverse the direction.
--let $check_replication = $proc_dir/check_replication.inc
--write_file $check_replication END_OF_PROCEDURE
  --let $rpl_connection_name = $replica_connection
  --source include/rpl_connection.inc
  --source include/start_slave.inc

  --let $rpl_connection_name = $source_connection
  --source include/rpl_connection.inc

  --let $assert_cond = '[SHOW STATUS LIKE 'Rpl_semi_sync_$source_name$_yes_tx_text', Value, 1]' = '0'
  --let $assert_text = Initially no acked transactions
  --source include/assert.inc

  INSERT INTO t1() VALUES ();

  --let $assert_cond = [SHOW STATUS LIKE 'Rpl_semi_sync_$source_name$_yes_tx_text', Value, 1] = 1
  --let $assert_text = After one transaction is committed, one transaction got acked
  --source include/assert.inc

  --let $sync_slave_connection = $replica_connection
  --source include/sync_slave_sql_with_master.inc
  --let $sync_slave_connection =

  --let $rpl_connection_name = $source_connection
  --source include/rpl_connection.inc

  --let $assert_cond = '[SHOW STATUS LIKE 'Rpl_semi_sync_$source_name$_status_text', Value, 1]' = 'ON'
  --let $assert_text = Semisync $source_name library should remain enabled on $source_connection
  --source include/assert.inc

  --let $rpl_connection_name = $replica_connection
  --source include/rpl_connection.inc

  --let $assert_cond = '[SHOW STATUS LIKE 'Rpl_semi_sync_$replica_name$_status_text', Value, 1]' = 'ON'
  --let $assert_text = Semisync $replica_name library should remain enabled on $replica_connection
  --source include/assert.inc

  --source include/stop_slave.inc
END_OF_PROCEDURE

--echo ==== R3. Replication: old source library -> old replica library ====

--let $source_connection = master
--let $replica_connection = slave

--let $source_name = master
--let $replica_name = slave
--source $install_plugins
--source $check_replication
--source $uninstall_plugins

--echo ==== R4. Replication: old source library -> new replica library ====

--let $source_name = master
--let $replica_name = replica
--source $install_plugins
--source $check_replication
--source $uninstall_plugins

--echo ==== R5. Replication: new source library -> old replica library ====

--let $source_name = source
--let $replica_name = slave
--source $install_plugins
--source $check_replication
--source $uninstall_plugins

--echo ==== R6. New source and old replica on the same node works, and R7. Old source and new replica on the same node works ====

--echo # Reconfigure toplogy and install plugins.

# Use a topology like:
#
# master ------> slave
# 1                  2
# replica <---- source
#
# Do not enable semisync on both connections at the same time, since
# semisync doesn't work with circular replication. When the replica
# commits a replicated transaction, it waits for an ack from the
# source in the reverse replication channel. But the source filters
# out the transaction because it was already applied, so no ack will
# arrive, and so semisync times out.

--let $rpl_topology = 1->2->1
--source include/rpl_change_topology.inc

--let $source_name = master
--let $replica_name = slave
--source $install_plugins

--let $source_connection = slave
--let $replica_connection = master
--let $source_name = source
--let $replica_name = replica
--source $install_plugins

--echo # Check that replication works in the usual direction

--connection slave
SET @@global.rpl_semi_sync_source_enabled = 0;
--connection master
SET @@global.rpl_semi_sync_replica_enabled = 0;

--let $source_connection = master
--let $replica_connection = slave
--let $source_name = master
--let $replica_name = slave
--source $check_replication

--echo # Check that replication works in reverse direction

--connection master
SET @@global.rpl_semi_sync_replica_enabled = 1;
SET @@global.rpl_semi_sync_master_enabled = 0;
--connection slave
SET @@global.rpl_semi_sync_source_enabled = 1;
SET @@global.rpl_semi_sync_slave_enabled = 0;

--let $source_connection = slave
--let $replica_connection = master
--let $source_name = source
--let $replica_name = replica
--source $check_replication

--echo # Uninstall plugins

--let $source_connection = master
--let $replica_connection = slave
--let $source_name = master
--let $replica_name = slave
--source $uninstall_plugins

--let $source_connection = slave
--let $replica_connection = master
--let $source_name = source
--let $replica_name = replica
--source $uninstall_plugins

--echo ==== R8. Error installing conflicting plugins. ====

# $check_install_plugin_conflict
#
# Installs a semisync library and then installs the other duplicate
# library (new vs old name).  Verifies that the second INSTALL
# generates an error, that the first library remains installed, and
# that the second library remains not installed.
#
# Parameters:
# $plugin1 - Suffix of first plugin: "source", "master", "replica", or "slave".
# $plugin2 - Suffix of second plugin: "source", "master", "replica", or "slave".
# $library1 - Full name of first library: one of the environment variables
#   $SEMISYNC_SOURCE_PLUGIN etc.
# $library2 - Full name of second library: one of the environment variables
#   $SEMISYNC_SOURCE_PLUGIN etc.
--let $check_install_plugin_conflict = $proc_dir/check_install_plugin_conflict.inc
--write_file $check_install_plugin_conflict END_OF_PROCEDURE
  --echo * Case a) Use INSTALL PLUGIN dynamically
  --replace_result $library1 PLUGIN_NAME
  eval INSTALL PLUGIN rpl_semi_sync_$plugin1 SONAME '$library1';
  --echo # R9.1. deprecation warnings for dynamic plugin load using INSTALL PLUGIN
  if ($plugin1 == master) {
    --let $error_pattern = .rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
    --source include/assert_error_log.inc
  }
  if ($plugin1 == slave) {
    --let $error_pattern = .rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
    --source include/assert_error_log.inc
  }
  --replace_result $library2 PLUGIN_NAME
  --error ER_INSTALL_PLUGIN_CONFLICT_CLIENT
  eval INSTALL PLUGIN rpl_semi_sync_$plugin2 SONAME '$library2';
  --let $error_pattern = Plugin 'rpl_semi_sync_$plugin2' init function returned error.
  --source include/assert_error_log.inc
  --let $assert_text = rpl_semi_sync_$plugin1 should remain installed
  --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE 'rpl_semi_sync_$plugin1%'] > 0
  --source include/assert.inc
  --let $assert_text = rpl_semi_sync_$plugin2 should not be installed
  --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE 'rpl_semi_sync_$plugin2%'] = 0
  --source include/assert.inc
  eval UNINSTALL PLUGIN rpl_semi_sync_$plugin1;

  --echo * Case b) Restart server with --plugin-load
  --let $rpl_server_parameters = --plugin-load=rpl_semi_sync_$plugin1=$library1;rpl_semi_sync_$plugin2=$library2
  --let $rpl_omit_print_server_parameters = 1
  --let $rpl_server_number = 1
  --source include/rpl_restart_server.inc
  let $error_pattern =
Cannot install the rpl_semi_sync_$plugin1 plugin when the rpl_semi_sync_$plugin2 plugin is installed.
Plugin .rpl_semi_sync_$plugin1. init function returned error.
Cannot install the rpl_semi_sync_$plugin2 plugin when the rpl_semi_sync_$plugin1 plugin is installed.
Plugin .rpl_semi_sync_$plugin2. init function returned error.
;
  --source include/assert_error_log.inc
  --let $assert_text = No semisync plugin should be installed
  --let $assert_cond = [SELECT COUNT(*) FROM performance_schema.global_variables WHERE VARIABLE_NAME LIKE 'rpl_semi_sync_%'] = 0
  --source include/assert.inc

  --echo * Case c) Restart server with --init-file
  --delimiter ||
  let $write_var = escape(\',
    INSTALL PLUGIN rpl_semi_sync_$plugin1 SONAME '$library1';
    INSTALL PLUGIN rpl_semi_sync_$plugin2 SONAME '$library2';
  )||
  --delimiter ;

  --let $write_to_file = GENERATE
  --source include/write_var_to_file.inc
  --let $init_file = $write_to_file
  --let $write_to_file =
  --let $rpl_server_parameters = --init-file=$init_file
  --let $rpl_omit_print_server_parameters = 1
  --let $rpl_server_number = 1
  --source include/rpl_restart_server.inc

  --remove_file $init_file

  --echo # R9.3. deprecation warnings for --init-file
  --let $error_pattern =
  if ($plugin1 == master) {
    --let $error_pattern = .rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
  }
  if ($plugin1 == slave) {
    --let $error_pattern = .rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
  }
  let $error_pattern = $error_pattern
Plugin 'rpl_semi_sync_$plugin2' init function returned error.
Cannot install the rpl_semi_sync_$plugin2 plugin when the rpl_semi_sync_$plugin1 plugin is installed.
  ;
  --source include/assert_error_log.inc

  eval UNINSTALL PLUGIN rpl_semi_sync_$plugin1;

END_OF_PROCEDURE

--echo ==== R8.1 Error installing first old and then new source library ====

--let $plugin1 = master
--let $library1 = $SEMISYNC_MASTER_PLUGIN
--let $plugin2 = source
--let $library2 = $SEMISYNC_SOURCE_PLUGIN
--source $check_install_plugin_conflict

--echo ==== R8.2 Error installing first new and then old source library ====

--let $plugin1 = source
--let $library1 = $SEMISYNC_SOURCE_PLUGIN
--let $plugin2 = master
--let $library2 = $SEMISYNC_MASTER_PLUGIN
--source $check_install_plugin_conflict

--echo ==== R8.3. Error installing first old and then new replica library ====

--let $plugin1 = slave
--let $library1 = $SEMISYNC_SLAVE_PLUGIN
--let $plugin2 = replica
--let $library2 = $SEMISYNC_REPLICA_PLUGIN
--source $check_install_plugin_conflict

--echo ==== R8.4. Error installing first new and then old replica library ====

--let $plugin1 = replica
--let $library1 = $SEMISYNC_REPLICA_PLUGIN
--let $plugin2 = slave
--let $library2 = $SEMISYNC_SLAVE_PLUGIN
--source $check_install_plugin_conflict

--echo ==== R9.2. Deprecation warnings generated for --plugin-load ====

--let $rpl_server_parameters = --plugin-load=rpl_semi_sync_master=$SEMISYNC_MASTER_PLUGIN;rpl_semi_sync_slave=$SEMISYNC_SLAVE_PLUGIN
--let $rpl_omit_print_server_parameters = 1
--let $rpl_server_number = 1
--source include/rpl_restart_server.inc
let $error_pattern =
.rpl_semi_sync_master. is deprecated and will be removed in a future release. Please use rpl_semi_sync_source instead.
.rpl_semi_sync_slave. is deprecated and will be removed in a future release. Please use rpl_semi_sync_replica instead.
;
--source include/assert_error_log.inc

--echo ==== Clean up ====

--let $rpl_server_number = 1
--let $rpl_server_parameters =
--source include/rpl_restart_server.inc

--source include/rpl_connection_slave.inc
--source include/start_slave.inc
--source include/rpl_connection_master.inc
# Since we configured replication 1->2->1, let replication start on
# source too, to make rpl_end.inc happy.  It will auto-start on
# the previous rpl_restart_server.inc, since mysqld.1 is not configured
# with --skip-replica-start, so we just need to wait for it to happen.
--source include/wait_for_slave_to_start.inc
DROP TABLE t1;
--source include/sync_slave_sql_with_master.inc

--source include/rpl_end.inc

--remove_file $install_plugins
--remove_file $uninstall_plugins
--remove_file $check_replication
--remove_file $check_install_plugin_conflict