Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Verify that @@session.terminology_use_previous works as
4 # expected, for all tables and SQL statements that it affects.
5 #
6 # This option affects a number of instrumentation names for mutexes,
7 # read/write locks, condition variables, memory allocations, threads,
8 # thread stages, and thread commands.
9 #
10 # These instrumentation names occur in a number of performance_schema
11 # tables, INFORMATION_SCHEMA tables, SHOW statements, and in a log
12 # file. The log file is affected only the global value of the option
13 # and the logic to test it is different, so it is tested in
14 # rpl_terminology_use_previous_logs. This test checks the
15 # tables and statements, not the log file.
16 #
17 # ==== Requirements ====
18 #
19 # R1. When @@session.terminology_use_previous = NONE:
20 # R1.1. The new names should be used for all affected identifiers
21 # R1.2. The old names should not be used for any identifiers
22 #
23 # R2. When @@session.terminology_use_previous != NONE:
24 # R2.1. The old names should be used for all affected identifiers
25 # R2.2. The new names should not be used for any identifiers
26 #
27 # R3. The default for terminology_use_previous should be NONE.
28 #
29 # ==== Implementation ====
30 #
31 # Since a large number of identifiers are affected by the option, and
32 # they appear in a variety of monitoring tables and commands, we check
33 # all identifiers in all monitoring tables and commands in a
34 # programmatic fashion.
35 #
36 # * Declarative approach
37 #
38 # We declare the names as data, and we declare the monitoring tables
39 # and commands as data, in both cases using a JSON representation. We
40 # use three mtr variables for this:
41 #
42 # $classes: a JSON array containing the 7 instrumentation classes
43 # where renamed identifiers occur.
44 #
45 # $occurrences: a JSON object, where the keys are instrumentation
46 # classes and the values describe the monitoring tables and
47 # commands where identifiers in the class can be found.
48 #
49 # $names: a JSON array, where each element is a JSON document that
50 # contains the old and new name for a renamed identifier.
51 #
52 # * Execution flow
53 #
54 # To execute test scenarios, an outer loop iterates over the two
55 # possible values for @@terminology_use_previous. Inside
56 # that, we have a loop that iterates over all the instrumentation
57 # classes. Inside that, we have two loops: first one over all the
58 # monitoring tables for that class, and then one over all the
59 # monitoring commands for that class. In each of those inner loops,
60 # we assert that all the renamed identifiers appear with the old/new
61 # name according to terminology_use_previous, and that the
62 # other name does not appear.
63 #
64 # We use the JSON test framework, include/create_json_*, to iterate
65 # over JSON arrays and unpack JSON objects into mtr variables.
66 #
67 # * Assertions for tables
68 #
69 # The tables we check, in most cases, contains one row per identifier.
70 # We create three SELECT queries:
71 #
72 # 1. A SELECT whose result is the set of identifiers found in the
73 # table
74 #
75 # 2. A SELECT whose result set is the set of expected identifiers.
76 #
77 # 3. A SELECT whose result set is the set of identifiers we do *not*
78 # expect - i.e., the old names if
79 # terminology_use_previous is NONE, and the new names
80 # otherwise.
81 #
82 # We join #1 and #2 and assert that the result set is equal to the
83 # full list
84 #
85 # We join #1 and #3 and assert that the result set is empty.
86 #
87 # * Assertions for statements
88 #
89 # The statements we check - actually only SHOW PROCESSLIST - cannot be
90 # used in a join operation. Therefore we first copy the output of
91 # SHOW PROCESSLIST into a temporary table, and then assert that the
92 # contents of the table is as expected, using the logic for tables
93 # described above. To copy the result into a temporary table, we
94 # first write the result to a file and then load the file using LOAD
95 # DATA INFILE.
96 #
97 # * Scenario setup
98 #
99 # In most tables, and for most instrumentation classes, there is
100 # always a row per instrumentation name. However, for SHOW
101 # PROCESSLIST and the related tables, the Thread Command is only
102 # visible if some thread is in the relevant state. So in order to
103 # test Thread Command, we take the server to a state where a thread
104 # uses the renamed Thread Command. The relevant Thread Command is
105 # "Register Replica", which is used briefly by the source server while
106 # a replica is connecting, and we use a debug sync point to force the
107 # source to pause it is in this state.
108 #
109 # ==== Limitations ====
110 #
111 # We do not test the *history tables* in performance_schema. The
112 # reason is that history tables contain the last N events that
113 # occurred during the code execution, for instance, the last N mutex
114 # acquisitions among all threads. That is highly nondeterministic,
115 # and highly unstable over the server evolution, so not easy to test
116 # in a robust way.
117 #
118 # We do not test *all* thread stages in SHOW PROCESSLIST,
119 # performance_schema.threads, performance_schema.processlist, or
120 # INFORMATION_SCHEMA.PROCESSLIST. Since each of these contains a
121 # snapshot of the current server state, testing a stage would require
122 # executing the necessary steps to reach each of those stages; i.e., a
123 # new test scenario for each stage. So we only test two of the stages
124 # in these cases.
125 #
126 # ==== References ====
127 #
128 # WL#14628: Compatibility option to enable old replication terminology
129 # in P_S instrumentation
130
131 # Test is binlog_format-agnostic.
132 --source include/have_binlog_format_row.inc
133
134 # Test uses SET debug and SET debug_sync to ensure source is in the
135 # middle of the execution of a Thread Command
136 --source include/have_debug_sync.inc
137 --source include/have_debug.inc
138
139 # Start replica threads later.
140 --let $rpl_skip_start_slave = 1
141 --source include/master-slave.inc
142
143 --echo #### Specify scenarios ####
144
145 # List the performance_schema instrumentation "classes" that we test.
146 let $classes =
147 [
148 "mutex",
149 "rwlock",
150 "cond",
151 "memory",
152 "thread",
153 "stage",
154 "command"
155 ];
156 --let $json_label = class
157 --source include/create_json_iterator.inc
158
159 # For each class, list the places we should look for the names in the
160 # class.
161 #
162 # $occurrences is a JSON object, where the keys are names of classes, and
163 # the values are in turn JSON objects that describe where names in that
164 # class occurs. The latter has the following members:
165 #
166 # prefix: Any prefix that the server prepends to the names in the class.
167 #
168 # tables: List of JSON objects, each one describing one table where
169 # the names may occur. The objects have the following fields:
170 #
171 # schema: The table schema. If not given, uses "performance_schema".
172 #
173 # table: The table name.
174 #
175 # column: The column where the identifier occurs. If not given,
176 # uses "EVENT_NAME".
177 #
178 # use_prefix: If 1, this table prepends the class prefix to the names.
179 # If 0, it does not. If not given, uses 1.
180 #
181 # row_count: If set, expect that only this number of identifiers
182 # occurs in the result set. Otherwise, expects that each
183 # identifier occurs at least once.
184 #
185 # statements: List of JSON objects, each one describing one SQL
186 # statement whose output may contain the name. The objects have
187 # the following fields:
188 #
189 # sql: The statement.
190 #
191 # column_index: The ordinal position of column of the result set in
192 # which the name occurs.
193 #
194 # row_count: If set, expect only this number of identifiers
195 # occurs in the result set. Otherwise, expects that each
196 # identifier occurs at least once.
197
198 let $events_waits_tables =
199 { "table": "events_waits_summary_by_account_by_event_name" },
200 { "table": "events_waits_summary_by_host_by_event_name" },
201 { "table": "events_waits_summary_by_instance" },
202 { "table": "events_waits_summary_by_thread_by_event_name" },
203 { "table": "events_waits_summary_by_user_by_event_name" },
204 { "table": "events_waits_summary_global_by_event_name" };
205 # Don't test history tables, because the existence of instrument names
206 # there depends on previous execution history.
207 # { "table": "events_waits_current" },
208 # { "table": "events_waits_history" },
209 # { "table": "events_waits_history_long" },
210
211 let $memory_tables =
212 { "table": "memory_summary_by_account_by_event_name" },
213 { "table": "memory_summary_by_host_by_event_name" },
214 { "table": "memory_summary_by_thread_by_event_name" },
215 { "table": "memory_summary_by_user_by_event_name" },
216 { "table": "memory_summary_global_by_event_name" };
217
218 let $events_stages_tables =
219 { "table": "events_stages_summary_by_account_by_event_name" },
220 { "table": "events_stages_summary_by_host_by_event_name" },
221 { "table": "events_stages_summary_by_thread_by_event_name" },
222 { "table": "events_stages_summary_by_user_by_event_name" },
223 { "table": "events_stages_summary_global_by_event_name" };
224 # Don't test history tables, because the existence of instrument names
225 # there depends on previous execution history.
226 # { "table": "events_stages_current" },
227 # { "table": "events_stages_history" },
228 # { "table": "events_stages_history_long" },
229
230 let $statement_tables =
231 { "table": "events_statements_summary_by_account_by_event_name" },
232 { "table": "events_statements_summary_by_host_by_event_name" },
233 { "table": "events_statements_summary_by_thread_by_event_name" },
234 { "table": "events_statements_summary_by_user_by_event_name" },
235 { "table": "events_statements_summary_global_by_event_name" };
236 # Don't test history tables, because the existence of instrument names
237 # there depends on previous execution history.
238 # { "table": "events_statements_history" },
239 # { "table": "events_statements_history_long" },
240
241 let $occurrences =
242 {
243 "mutex" : {
244 "prefix": "wait/synch/mutex/sql/",
245 "tables": [
246 $events_waits_tables,
247 { "table": "mutex_instances", "column": "NAME" }
248 ]
249 },
250 "rwlock": {
251 "prefix": "wait/synch/rwlock/sql/",
252 "tables": [
253 $events_waits_tables,
254 { "table": "rwlock_instances", "column": "NAME" }
255 ]
256 },
257 "cond": {
258 "prefix": "wait/synch/cond/sql/",
259 "tables": [
260 $events_waits_tables,
261 { "table": "cond_instances", "column": "NAME" }
262 ]
263 },
264 "memory": {
265 "prefix": "memory/sql/",
266 "tables": [
267 $memory_tables
268 ]
269 },
270 "thread": {
271 "prefix": "thread/sql/",
272 "tables": [
273 { "table": "threads", "column": "NAME" }
274 ]
275 },
276 "stage": {
277 "prefix": "stage/sql/",
278 "tables": [
279 $events_stages_tables,
280 { "table": "threads", "column": "PROCESSLIST_STATE", "use_prefix": 0,
281 "row_count": 2 },
282 { "table": "processlist", "column": "STATE", "use_prefix": 0,
283 "row_count": 2 },
284 { "schema": "INFORMATION_SCHEMA", "table": "PROCESSLIST",
285 "column": "STATE", "use_prefix": 0, "row_count": 2 }
286 ],
287 "statements": [
288 { "sql": "SET @@global.performance_schema_show_processlist = 1; SHOW PROCESSLIST",
289 "column_index": 7, "row_count": 2 },
290 { "sql": "SET @@global.performance_schema_show_processlist = 0; SHOW PROCESSLIST",
291 "column_index": 7, "row_count": 2 }
292 ]
293 },
294 "command": {
295 "prefix": "statement/com/",
296 "tables": [
297 $statement_tables,
298 { "table": "threads", "column": "PROCESSLIST_COMMAND", "use_prefix": 0 },
299 { "table": "processlist", "column": "COMMAND", "use_prefix": 0 },
300 { "schema": "INFORMATION_SCHEMA", "table": "PROCESSLIST",
301 "column": "COMMAND", "use_prefix": 0 }
302 ],
303 "statements": [
304 { "sql": "SET @@global.performance_schema_show_processlist = 1; SHOW PROCESSLIST",
305 "column_index": 5 },
306 { "sql": "SET @@global.performance_schema_show_processlist = 0; SHOW PROCESSLIST",
307 "column_index": 5 },
308 { "sql": "SHOW REPLICA STATUS", "column_index": 1, "row_count": 1 },
309 { "sql": "SHOW REPLICA STATUS", "column_index": 45, "row_count": 1 },
310 { "sql": "SHOW SLAVE STATUS", "column_index": 1, "row_count": 1 },
311 { "sql": "SHOW SLAVE STATUS", "column_index": 45, "row_count": 1 }
312 ]
313 }
314 };
315
316 --let $json_label = class_spec
317 --let $json_keys = prefix, tables, statements
318 --let $json_defaults = { "tables": [], "statements": [] }
319 --source include/create_json_unpacker.inc
320
321 --let $json_label = table
322 --let $json_keys = schema, table, column, use_prefix, row_count
323 --let $json_required = table
324 let $json_defaults = {
325 "schema": "performance_schema",
326 "column": "EVENT_NAME",
327 "use_prefix": 1,
328 "row_count": -1
329 };
330 --source include/create_json_unpacking_iterator.inc
331
332 --let $json_label = statement
333 --let $json_keys = sql, column_index, row_count
334 --let $json_required = sql, column_index
335 --let $json_defaults = { "row_count": -1 }
336 --source include/create_json_unpacking_iterator.inc
337
338 --delimiter ||
339 let $names = {
340 "mutex": [
341 { "old": "Master_info::data_lock",
342 "new": "Source_info::data_lock" },
343 { "old": "Master_info::run_lock",
344 "new": "Source_info::run_lock" },
345 { "old": "Master_info::sleep_lock",
346 "new": "Source_info::sleep_lock" },
347 { "old": "Master_info::info_thd_lock",
348 "new": "Source_info::info_thd_lock" },
349 { "old": "Master_info::rotate_lock",
350 "new": "Source_info::rotate_lock" },
351 { "old": "Slave_reporting_capability::err_lock",
352 "new": "Replica_reporting_capability::err_lock" },
353 { "old": "key_mts_temp_table_LOCK",
354 "new": "key_mta_temp_table_LOCK" },
355 { "old": "key_mts_gaq_LOCK",
356 "new": "key_mta_gaq_LOCK" },
357 { "old": "Relay_log_info::slave_worker_hash_lock",
358 "new": "Relay_log_info::replica_worker_hash_lock" },
359 { "old": "LOCK_slave_list",
360 "new": "LOCK_replica_list" },
361 { "old": "LOCK_slave_net_timeout",
362 "new": "LOCK_replica_net_timeout" },
363 { "old": "LOCK_sql_slave_skip_counter",
364 "new": "LOCK_sql_replica_skip_counter" }
365 ],
366
367 "rwlock": [
368 { "old": "LOCK_sys_init_slave",
369 "new": "LOCK_sys_init_replica" }
370 ],
371
372 "cond": [
373 { "old": "Relay_log_info::slave_worker_hash_lock",
374 "new": "Relay_log_info::replica_worker_hash_cond" },
375 { "old": "Master_info::data_cond",
376 "new": "Source_info::data_cond" },
377 { "old": "Master_info::start_cond",
378 "new": "Source_info::start_cond" },
379 { "old": "Master_info::stop_cond",
380 "new": "Source_info::stop_cond" },
381 { "old": "Master_info::sleep_cond",
382 "new": "Source_info::sleep_cond" },
383 { "old": "Master_info::rotate_cond",
384 "new": "Source_info::rotate_cond" },
385 { "old": "Relay_log_info::mts_gaq_cond",
386 "new": "Relay_log_info::mta_gaq_cond" }
387 ],
388
389 "memory": [
390 { "old": "Slave_job_group::group_relay_log_name",
391 "new": "Replica_job_group::group_relay_log_name" },
392 { "old": "rpl_slave::check_temp_dir",
393 "new": "rpl_replica::check_temp_dir" },
394 { "old": "SLAVE_INFO",
395 "new": "REPLICA_INFO" },
396 { "old": "show_slave_status_io_gtid_set",
397 "new": "show_replica_status_io_gtid_set" },
398 { "old": "Relay_log_info::mts_coor",
399 "new": "Relay_log_info::mta_coor" }
400 ],
401
402 "thread": [
403 { "old": "slave_io",
404 "new": "replica_io" },
405 { "old": "slave_sql",
406 "new": "replica_sql" },
407 { "old": "slave_worker",
408 "new": "replica_worker" }
409 ],
410
411 "stage": [
412 { "old": "Changing master",
413 "new": "Changing replication source" },
414 { "old": "Checking master version",
415 "new": "Checking source version" },
416 { "old": "Connecting to master",
417 "new": "Connecting to source" },
418 { "old": "Flushing relay log and master info repository.",
419 "new": "Flushing relay log and source info repository." },
420 { "old": "Killing slave",
421 "new": "Killing replica" },
422 { "old": "Master has sent all binlog to slave; waiting for more updates",
423 "new": "Source has sent all binlog to replica; waiting for more updates" },
424 { "old": "Queueing master event to the relay log",
425 "new": "Queueing source event to the relay log" },
426 { "old": "Reconnecting after a failed master event read",
427 "new": "Reconnecting after a failed source event read" },
428 { "old": "Reconnecting after a failed registration on master",
429 "new": "Reconnecting after a failed registration on source" },
430 { "old": "Registering slave on master",
431 "new": "Registering replica on source" },
432 { "old": "Sending binlog event to slave",
433 "new": "Sending binlog event to replica" },
434 { "old": "Slave has read all relay log; waiting for more updates",
435 "new": "Replica has read all relay log; waiting for more updates" },
436 { "old": "Waiting for slave workers to process their queues",
437 "new": "Waiting for replica workers to process their queues" },
438 { "old": "Waiting for Slave Worker queue",
439 "new": "Waiting for Replica Worker queue" },
440 { "old": "Waiting for Slave Workers to free pending events",
441 "new": "Waiting for Replica Workers to free pending events" },
442 { "old": "Waiting for Slave Worker to release partition",
443 "new": "Waiting for Replica Worker to release partition" },
444 { "old": "Waiting until MASTER_DELAY seconds after master executed event",
445 "new": "Waiting until SOURCE_DELAY seconds after source executed event" },
446 { "old": "Waiting for master to send event",
447 "new": "Waiting for source to send event" },
448 { "old": "Waiting for master update",
449 "new": "Waiting for source update" },
450 { "old": "Waiting for the slave SQL thread to free enough relay log space",
451 "new": "Waiting for the replica SQL thread to free relay log space" },
452 { "old": "Waiting for slave mutex on exit",
453 "new": "Waiting for replica mutex on exit" },
454 { "old": "Waiting for slave thread to start",
455 "new": "Waiting for replica thread to start" },
456 { "old": "Waiting for the slave SQL thread to advance position",
457 "new": "Waiting for the replica SQL thread to advance position" },
458 { "old": "Waiting to reconnect after a failed registration on master",
459 "new": "Waiting to reconnect after a failed registration on source" },
460 { "old": "Waiting to reconnect after a failed master event read",
461 "new": "Waiting to reconnect after a failed source event read" }
462 ],
463
464 "command": [
465 { "old": "Register Slave",
466 "new": "Register Replica",
467 "con": 1 }
468 ]
469 }
470 ||
471 --delimiter ;
472 --let $json = $names
473 --source include/json_check.inc
474
475 # ==== Purpose ====
476 #
477 # For a given instrumentation class, and a given table and column,
478 # assert that the column contains the old names and not the new names
479 # for the instrumentation class, or vice versa depending on
480 # @@session.terminology_use_previous.
481 #
482 # ==== Usage ====
483 #
484 # --let $table = TABLE
485 # --let $column = COLUMN
486 # [--let $schema = SCHEMA]
487 # --let $use_prefix = {0|1}
488 # --let $terminology_use_previous = {0|1}
489 # # In addition, the table `declared_names` must be setup.
490 # --source $assertions_for_table
491 #
492 # Parameters:
493 #
494 # declared_names
495 # This table should have the following definition:
496 # CREATE TABLE declared_names(
497 # old TEXT, new TEXT, old_prefixed TEXT, new_prefixed TEXT);
498 # The table should exist on both source and replica, and should
499 # contain the instrumentation names that are expected to be found
500 # on source and replica, respective. The
501 # 'old_prefixed/new_prefixed' columns should be equal to the
502 # 'old/new' columns, with the prefix of the instrumentation class
503 # included, for instance, "wait/synch/mutex/sql".
504 #
505 # $table, $column, $schema
506 # This script will (in effect) execute the following statement:
507 # SELECT $column FROM $schema.$table
508 # It joins this with declared_names, choosing the join column in
509 # declared_names according to $terminology_use_previous
510 # and $use_prefix.
511 #
512 # $terminology_use_previous
513 # The value of @@session.terminology_use_previous.
514 # This must agree with the actual value, and should be the same
515 # on server_1 and server_2.
516 #
517 # $use_prefix
518 # If this is 1, the table contents is expected to contain the
519 # prefix, e.g., "wait/synch/mutex/sql/". If it is 0, the table is
520 # expected to not contain the prefix.
521 #
522 # $row_count
523 # If this is -1, all instrumentation names in the table are
524 # expected to be found in this table. Otherwise, exactly the
525 # given number of instrumentation names are expected to be found.
526 --let $assertions_for_table = $MYSQLTEST_VARDIR/tmp/assertions_for_table.inc
527 --write_file $assertions_for_table END_OF_PROCEDURE
528 --let $prefixed = _prefixed
529 if (!$use_prefix) {
530 --let $prefixed =
531 }
532 # Make show_rpl_debug_info.inc dump the table if the test fails
533 --let $qualified_table = $schema.$table
534 if ($schema == '') {
535 --let $qualified_table = $table
536 }
537 --let $extra_debug_table = $qualified_table
538
539 # Iterate over connections
540 --let $con = 1
541 while ($con <= 2) {
542 --connection server_$con
543 # Number of declared names that we should check on this connection.
544 --let $declared_count = `SELECT COUNT(*) FROM declared_names`
545 # Check if we expect any identifiers at all on this connection.
546 if ($declared_count) {
547 --let $check_version = 0
548 # Iterate over versions, and check for each version that we have
549 # the expected number of names from that version in the result set.
550 while ($check_version < 2) {
551 if ($check_version == 0) {
552 --let $version = new
553 }
554 if ($check_version == 1) {
555 --let $version = old
556 }
557 if ($check_version == $terminology_use_previous) {
558 if ($row_count != -1) {
559 --let $expected_count = $row_count
560 }
561 if ($row_count == -1) {
562 --let $expected_count = $declared_count
563 }
564 }
565 if ($check_version != $terminology_use_previous) {
566 --let $expected_count = 0
567 }
568
569 # SQL to get a result set containing the names of the
570 # '$check_version' from this table. We join the table we
571 # observe with the table of expected identifiers.
572 let $sql_found_names =
573 FROM $qualified_table AS t, declared_names AS dn
574 WHERE t.$column <=> dn.$version$prefixed;
575
576 if ($debug) {
577 --echo # DEBUG: Observed the following '$version' names:
578 eval SELECT t.$column $sql_found_names;
579 }
580 # Make show_rpl_debug_info.inc execute the SELECT if the test fails
581 --delimiter |
582 let $extra_debug_sql =
583 SELECT t.$column $sql_found_names;
584 SELECT @@session.terminology_use_previous,
585 @@global.terminology_use_previous
586 |
587 --delimiter ;
588
589 let $select_count_found_names =
590 SELECT COUNT(DISTINCT t.$column) $sql_found_names;
591
592 --let $assert_escape = 1
593 --let $assert_cond = [$select_count_found_names] = $expected_count
594 --let $assert_text = There should be $expected_count unique '$version' $class names in $description on server $con
595 --source include/assert.inc
596
597 --inc $check_version
598 } # while check_version < 2
599 } # if declared_count
600 --inc $con
601 } # while con <= 2
602 END_OF_PROCEDURE
603
604 --echo
605 --echo #### Initialize Server State ####
606
607 # Start MTA, so we can observe the 'thread names' in the thread tables.
608 --connection server_2
609 --source include/disable_binlog.inc
610 SET @save_replica_parallel_workers = @@global.replica_parallel_workers;
611 SET @@global.replica_parallel_workers = 4;
612 --source include/start_slave_sql.inc
613
614 # The source will hang in the middle of the initial replication
615 # handshake, for the whole duration of the test. So we increase the
616 # timeout to prevent that the replica times out and reconnects, which
617 # would create extra messages in the log and make the test fail.
618 SET @save_replica_net_timeout = @@global.replica_net_timeout;
619 SET @@global.replica_net_timeout = 300;
620
621 # Auxiliary table used in the assertion logic.
622 CREATE TABLE statement_result (name VARCHAR(256), KEY(name));
623
624 # Make dump thread pause during 'register replica', so we can observe
625 # that thread state
626
627 # Make 'server_1' connection wait for dump thread to reach the state.
628 --connection server_1
629 --source include/disable_binlog.inc
630 CREATE TABLE statement_result (name VARCHAR(256), KEY(name));
631 --let $debug_point = syncpoint_begin_register_replica
632 --source include/add_debug_point.inc
633 send SET @@session.debug_sync = "now WAIT_FOR reached_begin_register_replica";
634 # Start connection
635 --connection server_2
636 START REPLICA IO_THREAD;
637 # Wait for 'server_1' to reach the state
638 --connection server_1
639 --reap
640
641 --let $terminology_use_previous = 0
642 while ($terminology_use_previous < 2) {
643 --echo
644 --echo #### Test terminology_use_previous=$terminology_use_previous ####
645 --echo
646
647 --connection server_1
648 eval SET @@session.terminology_use_previous = $terminology_use_previous;
649 SELECT @@session.terminology_use_previous;
650
651 --connection server_2
652 eval SET @@session.terminology_use_previous = $terminology_use_previous;
653 SELECT @@session.terminology_use_previous;
654
655 if (!$debug) {
656 --disable_query_log
657 }
658
659 --let $json_array = $classes
660 --source $json_class_start
661 while (!$json_class_done) {
662 --let $class = $json_class_value
663 --echo
664 --echo ---- $class ----
665
666 # Get the class spec from 'occurrences'
667 --let $json_object = $occurrences
668 --let $json_key = $class
669 --source include/json_lookup.inc
670 # Unpack the class spec
671 --let $json_object = $json_value
672 --source $json_class_spec_unpack
673
674 let $create_sql = CREATE TABLE declared_names AS
675 SELECT
676 jt.old AS old,
677 jt.new AS new,
678 CONCAT('$prefix', jt.old) AS old_prefixed,
679 CONCAT('$prefix', jt.new) AS new_prefixed
680 FROM
681 JSON_TABLE(
682 '$names', '$.$class[*]' COLUMNS (
683 old TEXT PATH '$.old',
684 new TEXT PATH '$.new',
685 con TEXT PATH '$.con' DEFAULT '2' ON EMPTY
686 )
687 ) AS jt;
688
689 --connection server_1
690 --eval $create_sql WHERE jt.con = 1
691 if ($debug) {
692 eval SELECT * FROM declared_names;
693 }
694 --connection server_2
695 --eval $create_sql WHERE jt.con = 2
696 if ($debug) {
697 eval SELECT * FROM declared_names;
698 }
699
700 # Iterate over tables.
701 --let $json_array = $tables
702 --source $json_table_start
703 while (!$json_table_done) {
704 --let $description = $schema.$table($column)
705 --echo * $description
706 --source $assertions_for_table
707
708 --source $json_table_next
709 } # while !json_table_done
710
711 # Iterate over statements.
712 --let $json_array = $statements
713 --source $json_statement_start
714 while (!$json_statement_done) {
715 --let $description = $sql(column $column_index)
716 --echo * $description
717
718 --let $statement = SET @@session.terminology_use_previous = $terminology_use_previous; $sql
719 --let $table = statement_result
720 --let $select_columns = $column_index
721 # Execute $statement, storing the result set into the table
722 # statement_result. Do this on both servers, just in case - it
723 # is decided in $assertions_for_table on which connections the
724 # result should be inspected.
725 --connection server_1
726 --source include/save_result_in_table.inc
727 --connection server_2
728 --source include/save_result_in_table.inc
729
730 --let $schema =
731 --let $column = name
732 --source $assertions_for_table
733
734 --source $json_statement_next
735 } # while !json_statement_done
736
737 --connection server_1
738 DROP TABLE declared_names;
739 TRUNCATE TABLE statement_result;
740 --connection server_2
741 DROP TABLE declared_names;
742 TRUNCATE TABLE statement_result;
743
744 --source $json_class_next
745 } # while !json_class_done
746 --enable_query_log
747
748 --inc $terminology_use_previous
749 } # while i <= 2
750
751 --echo # Check SET terminology_use_previous = DEFAULT
752 eval SET @@session.terminology_use_previous = DEFAULT;
753 eval SELECT @@session.terminology_use_previous;
754
755 --echo
756 --echo #### Clean up ####
757
758 # Release the dump thread which is hanging while executing the
759 # 'Register replica' command.
760 --connection server_1
761 SET @@session.debug_sync = "now SIGNAL continue_begin_register_replica";
762 # Wait for replica to start
763 --connection server_2
764 --source include/wait_for_slave_io_to_start.inc
765
766 --disable_warnings
767 SET @@global.replica_parallel_workers = @save_replica_parallel_workers;
768 --enable_warnings
769 SET @@global.replica_net_timeout = @save_replica_net_timeout;
770 --connection server_1
771 --source include/restore_binlog.inc
772 --let $debug_point = syncpoint_begin_register_replica
773 --source include/remove_debug_point.inc
774 DROP TABLE statement_result;
775 --source include/sync_slave_sql_with_master.inc
776
777 --remove_file $assertions_for_table
778 --source include/destroy_json_functions.inc
779
780 --source include/rpl_end.inc