Debian Codegraph @

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

raw
1 # ==== Purpose ====
2 #
3 # Verify that the positions that are reported by the applier thread during
4 # STOP SLAVE are the same as that of the most recent checkpoint in case of
5 # Multi Threaded Slave.
6 #
7 # ==== Implementation ====
8 #
9 # 1) Create two databases and do some DML operations on these databases.
10 # 2) Sync the slave applier with master to insure that a checkpoint is done.
11 # 3) Set bigger values for replica_checkpoint_period/group so that no further
12 # checkpoints are done on slave server.
13 # 4) Execute few more DMLS on master and wait till they are applied on slave.
14 # 5) This is to prove that applier thread has few more committed transactions
15 # after the checkpoint done at step 2.
16 # 6) Execute STOP SLAVE command.
17 # 7) Assert that the positions that are reported in error log are as per the
18 # latest checkpoint.
19 #
20 # ==== References ====
21 #
22 # Bug#27300658: IN MTS SQL THREAD EXITING AND INITIALIZING
23 # MESSAGE WITH DIFFERENT POSITION
24
25 # This test case is binary log format agnostic
26 --source include/have_binlog_format_row.inc
27 --source include/have_debug.inc
28 --source include/only_mts_replica_parallel_workers.inc
29 # do not execute when binlog compression is on as the debug
30 # point below is not activated
31 --source include/not_binlog_transaction_compression_on.inc
32 --source include/master-slave.inc
33
34 # Do some DMLs on master and sync with slave to make sure that one checkpoint
35 # is done.
36 CREATE DATABASE db1;
37 CREATE DATABASE db2;
38 CREATE TABLE db1.t1 ( id INT(11) PRIMARY KEY ) ENGINE=INNODB;
39 CREATE TABLE db2.t1 ( id INT(11) PRIMARY KEY ) ENGINE=INNODB;
40 INSERT INTO db1.t1 VALUES (40);
41 INSERT INTO db2.t1 VALUES (40);
42 --source include/sync_slave_sql_with_master.inc
43
44 # Save the global variables that are being modified. Set bigger values for
45 # replica_checkpoint_group/period so that no further checkpoints are done
46 # automatically.
47 SET @save_debug = @@GLOBAL.debug;
48 SET @save_replica_checkpoint_group= @@GLOBAL.replica_checkpoint_group;
49 SET @save_replica_checkpoint_period= @@GLOBAL.replica_checkpoint_period;
50 SET GLOBAL replica_checkpoint_group=512;
51 SET GLOBAL replica_checkpoint_period=3000000;
52
53 # Do some DMLs on master.
54 --source include/rpl_connection_master.inc
55 --let $i=30
56 while ($i)
57 {
58 --eval insert into db1.t1 values ($i)
59 --eval insert into db2.t1 values ($i)
60 dec $i;
61 }
62 --source include/sync_slave_io_with_master.inc
63
64 # Wait till all the transactions are applied on slave. This will ensure that
65 # at the time of STOP SLAVE few more committited transactions are present
66 # above the recent LWM.
67 --source include/rpl_connection_slave.inc
68 --let $table=db1.t1
69 --let $count=31
70 --source include/wait_until_rows_count.inc
71
72 --let $table=db2.t1
73 --let $count=31
74 --source include/wait_until_rows_count.inc
75 --source include/stop_slave_io.inc
76
77 # Wait for coordinator to populate worker's queues.
78 --let $show_statement= SHOW PROCESSLIST
79 --let $field= State
80 --let $condition= = 'Replica has read all relay log; waiting for more updates'
81 --source include/wait_show_condition.inc
82
83
84 # Initiate one more DML on master. While the DML is being processed by slave
85 # applier it will receive a STOP SLAVE due to debug simulation. Applier will
86 # execute gracefully after completing the current group in progress and print
87 # appropriate exit positions.
88 --source include/rpl_connection_master.inc
89 BEGIN;
90 INSERT INTO db1.t1 VALUES (50);
91 COMMIT;
92
93 --source include/rpl_connection_slave.inc
94 # Debug simulation which will ensure that SLAVE STOPS as a regular exit
95 # without an error. This ensures we have the same scenario as that of the bug
96 # report.
97 SET global debug="+d,simulate_stop_when_mta_in_group";
98 --source include/start_slave_io.inc
99
100 --source include/wait_for_slave_sql_to_stop.inc
101 --let $exec_master_log_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1)
102 --let $exec_master_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Master_Log_File, 1)
103
104 # Assert that the positions that are reported by the applier thread during
105 # STOP SLAVE are the same as that of the most recent checkpoint in case of
106 # Multi Threaded Slave.
107 --let $assert_text= Assert that the expected entry is in the error log during STOP SLAVE
108 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
109 --let $assert_only_after = Coordinator thread of multi-threaded replica is being stopped in the middle of assigning a group of events
110 --let $assert_select= Replica SQL thread for channel '' exiting, replication stopped in log '$exec_master_log_file' at position $exec_master_log_pos
111 --let $assert_count= 1
112 --source include/assert_grep.inc
113
114 SET GLOBAL debug=@save_debug;
115 SET @@GLOBAL.replica_checkpoint_group= @save_replica_checkpoint_group;
116 set @@GLOBAL.replica_checkpoint_period= @save_replica_checkpoint_period;
117 --source include/start_slave.inc
118
119 # Assert that the positions that are reported by the applier thread during
120 # START SLAVE are the same as the positions reported during STOP SLAVE.
121 --let $assert_text= Assert that the expected entry is in the error log during START SLAVE
122 --let $assert_file=$MYSQLTEST_VARDIR/log/mysqld.2.err
123 --let $assert_only_after = Replica SQL thread exiting, replication stopped in log
124 --let $assert_select= Replica SQL thread for channel '' initialized, starting replication in log '$exec_master_log_file' at position $exec_master_log_pos
125 --let $assert_count= 1
126 --source include/assert_grep.inc
127
128 --source include/rpl_connection_master.inc
129 --source include/sync_slave_sql_with_master.inc
130
131 --source include/rpl_connection_master.inc
132 DROP DATABASE db1;
133 DROP DATABASE db2;
134 --source include/rpl_end.inc