mariadb/mysql-test/suite/rpl/t/sec_behind_master-5114.test
Sergei Golubchik f875c9f2a0 MDEV-5114 seconds_behind_master flips to 0 & spikes back, when running show slaves status
1. After a period of wait (where last_master_timestamp=0)
   do NOT restore the last_master_timestamp to the timestamp
   of the last executed event (which would mean we've just
   executed it, and we're that much behind the master).

2. Update last_master_timestamp before executing the event,
   not after.

Take the approach from the this commit (but with a different test
case that actually makes sense):

commit 0c75ab453fb8c5439576af8fe5add7a1b89f1569
Author: Luis Soares <luis.soares@sun.com>
Date:   Thu Apr 15 17:39:31 2010 +0100

    BUG#52166: Seconds_Behind_Master spikes after long idle period
2015-05-03 11:21:55 +02:00

27 lines
598 B
Text

source include/master-slave.inc;
source include/have_binlog_format_statement.inc;
call mtr.add_suppression("Unsafe statement written to the binary log");
CREATE TABLE t1 (a int);
send INSERT INTO t1 VALUES(SLEEP(2));
connection slave;
let $run = 10;
while ($run)
{
dec $run;
let $sbm=query_get_value(SHOW SLAVE STATUS, Seconds_Behind_Master, 1);
# for debugging uncomment echo and remove the if()
#echo Seconds_Behind_Master: $sbm;
if ($sbm)
{
let $run = 0;
}
sleep 0.5;
}
echo Seconds_Behind_Master: $sbm;
connection master;
reap;
drop table t1;
source include/rpl_end.inc;