Debian Codegraph @

mysql-test/suite/rpl/t/sec_behind_master-5114.test

raw
1 source include/have_binlog_format_statement.inc;
2 source include/master-slave.inc;
3
4 call mtr.add_suppression("Unsafe statement written to the binary log");
5
6
7 # Make sure that the start time of the first event is certainly different
8 # from the next event
9 --let $timestamp= `SELECT @@timestamp`
10 --disable_query_log
11 eval SET TIMESTAMP= $timestamp-100;
12 --enable_query_log
13 CREATE TABLE t1 (a int);
14
15 # Make sure that the slave is done with the first event, and all checks
16 # that we'll perform later will be really against the second event
17 sync_slave_with_master;
18
19 connection master;
20
21 # Restore the timestamp now. It doesn't matter that it's not precise,
22 # it just needs to be very different from the earlier event
23 --disable_query_log
24 eval SET TIMESTAMP= $timestamp;
25 --enable_query_log
26
27 send INSERT INTO t1 VALUES(SLEEP(2));
28
29 connection slave;
30
31 # When the slave starts executing the event, Seconds_Behind_Master
32 # should start growing steadilly. The bugfix ensures that they are
33 # calculated based on the start time of the current event, rather
34 # than the start time of the previous event. To check it, we only need
35 # the first non-zero value
36
37 let $run = 20;
38 while ($run)
39 {
40 dec $run;
41 let $sbm=query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1);
42 # for debugging uncomment echo and remove the if()
43 # echo Seconds_Behind_Master: $sbm;
44 if ($sbm)
45 {
46 let $run = 0;
47 }
48 sleep 0.5;
49 }
50
51 # Normally the first non-zero value should be 1. However, due to race
52 # conditions on slow servers, sometimes the check might miss the value 1,
53 # and only catch a higher one. It does not matter, we just need to make
54 # sure it didn't start with 100+, as it would have with bug MDEV-5114
55
56 --disable_query_log
57 eval SELECT $sbm > 0 and $sbm < 99 AS Seconds_Behind_Master_is_less_than_100;
58 --enable_query_log
59
60 connection master;
61 reap;
62 drop table t1;
63 source include/rpl_end.inc;