Debian Codegraph @

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

raw
1 #
2 #BUG#11752315 : STOP SLAVE UNABLE TO COMPLETE WHEN SLAVE THREAD IS TRYING
3 # TO RECONNECT TO
4 #
5 # ==== Purpose ====
6 #
7 #Tests that the slave does not go to a sleep for a long duration after the
8 #master is killed and we do a START_SLAVE and STOP_SLAVE.
9 #
10 # ==== Method ====
11 #
12 #This is a new functionality of having an interruptable sleep of the slave.
13 #We find the thread id for the slave thread. On finding the thread ID of the
14 #slave thread we kill the slave thread. A successful kill in less than 60 sec
15 #should serve the purpose of checking the functionality.
16 #
17
18 --source include/have_log_bin.inc
19 --source include/master-slave.inc
20
21 connection slave;
22 --let $i= 100
23 while ($i > 0) {
24 dec $i;
25 --let $connection_id=`SELECT id FROM information_schema.processlist where state LIKE 'Waiting for master to send event'`
26 if ($connection_id) {
27 let $i= 0;
28 }
29 if ($i > 0) {
30 --sleep 0.1
31 }
32 }
33
34 if(!$connection_id)
35 {
36 # Something went wrong (timing)
37 # Show process list so that we can debug. In this case we will abort with
38 # wrong result
39 -- echo "Could not find connect id. Dumping process list for debugging"
40 SELECT * FROM information_schema.processlist;
41 exit;
42 }
43
44 set @time_before_kill := (select CURRENT_TIMESTAMP);
45
46 --echo [Time before the query]
47 --echo [Connection ID of the slave I/O thread found]
48
49 --replace_regex /kill [0-9]*/kill <connection_id>/
50 --eval kill $connection_id
51 --source include/wait_for_slave_io_to_stop.inc
52
53 set @time_after_kill := (select CURRENT_TIMESTAMP);
54
55 --echo [Time after the query]
56
57 if(`select TIMESTAMPDIFF(SECOND,@time_after_kill, @time_before_kill) > 60`)
58 {
59 --echo # assert : The difference between the timestamps 'time_after_kill' and 'time_before_kill' should be less than 60sec.
60 --die
61 }
62 --echo [Killing of the slave IO thread was successful]
63
64 START SLAVE IO_THREAD;
65 --source include/wait_for_slave_io_to_start.inc
66
67 # Ensure that the slave io thread started properly
68 connection master;
69 create table t1 (a int primary key);
70 sync_slave_with_master;
71 connection master;
72 drop table t1;
73
74 # End of test
75 --source include/rpl_end.inc