Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # This test case will test the concurrency between the receiver (a.k.a. I/O)
4 # thread and the applier (a.k.a. SQL) thread when the receiver is writing
5 # events to the same relay log file the applier is reading (the "hot" log).
6 #
7 # The test uses debug instrumentation to pause the receiver thread while
8 # holding the locks it uses when writing events to the relay log, and make
9 # the SQL thread to consume the events on the same relay log file.
10 #
11 # ==== Related Bugs and Worklogs ====
12 #
13 # WL#8599: Reduce contention in IO and SQL threads
14 #
15
16 --source include/have_debug.inc
17 --source include/have_debug_sync.inc
18 --source include/master-slave.inc
19
20 # Create one table, populate it, then drop it
21 CREATE TABLE t1 (c1 INT) ENGINE=InnoDB;
22 --source include/sync_slave_sql_with_master.inc
23
24 # Hold the applier thread executing a new event.
25 LOCK TABLES t1 WRITE;
26
27 --source include/rpl_connection_master.inc
28 INSERT INTO t1 (c1) VALUES (1);
29
30 # Wait until the applier reached the waiting point
31 --source include/rpl_connection_slave.inc
32 --let $show_statement= SHOW PROCESSLIST
33 --let $field= State
34 --let $condition= = 'Waiting for table metadata lock'
35 --source include/wait_show_condition.inc
36
37 --source include/rpl_connection_master.inc
38 --let $num_inserts= 5
39 --echo Populate the table with additional $num_inserts rows
40 --disable_query_log
41 --let $i= 1
42 while ($i < $num_inserts)
43 {
44 --inc $i
45 --eval INSERT INTO t1 (c1) VALUES ($i)
46 }
47 --enable_query_log
48
49 --source include/sync_slave_io_with_master.inc
50
51 # Add debug instrumentation to hold the receiver thread
52 # while writing to the relay log.
53 --let $debug_point=pause_on_queue_event_after_write_buffer
54 --source include/add_debug_point.inc
55
56 # Generate a new transaction to make the receiver to work
57 --source include/rpl_connection_master.inc
58 DROP TABLE t1;
59
60 # Wait until the receiver reached the debug point
61 --source include/rpl_connection_slave.inc
62 SET DEBUG_SYNC='now WAIT_FOR receiver_reached_pause_on_queue_event';
63
64 # At this point, we have the receiver thread holding the relay log LOCK_log
65 # and mi->data_lock. The applier thread is applying the same relay log file
66 # and should progress normally.
67
68 # Let the applier "fly"...
69 UNLOCK TABLES;
70
71 --echo Wait until all the inserts are applied
72 --let $wait_condition= SELECT COUNT(*) = $num_inserts FROM t1
73 --source include/wait_condition_or_abort.inc
74
75 # It is possible to show the events in the active relay log
76 --let $binlog_file= slave-relay-bin.000002
77 --let $binlog_limit= 1, 6
78 --let $keep_gtid_events= 1
79 --let $mask_anonymous_gtid_events= 1
80 --source include/show_relaylog_events.inc
81
82 --let $debug_point=pause_on_queue_event_after_write_buffer
83 --source include/remove_debug_point.inc
84 SET DEBUG_SYNC='now SIGNAL receiver_continue_queuing_event';
85
86 # Cleanup
87 --source include/rpl_end.inc