rpl_slave_net_timeout.test 2.71 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35
#
#  Testing reconnecting by slave as specified by `slave_net_timeout'
#
#  Bug #50296 Slave reconnects earlier than the prescribed slave_net_timeout value
#
--source include/have_csv.inc
--source include/master-slave.inc


# save global env
connection master;
set @save_general_log = @@global.general_log;
set @save_log_output = @@global.log_output;

connection slave;
set @save_slave_net_timeout = @@global.slave_net_timeout;

connection master;
set @@global.general_log = ON;
set @@global.log_output = 'table,file';

connection slave;
--source include/stop_slave.inc
#
# if heartbeat is disabled then reconnecting to the idle master
# should happen with `slave_net_timeout' period.
# Since it's the real time that is measured, `slave_net_timeout'
# merely guarantees that reconnecting can *not* happen earlier of a value specified.
# That is there can't an exact estimate for how many time it will happen.
#
# The following lines verify that having idle master 
# for more than 2 * slave_net_timeout seconds and 
# slave.net_read_timeout < slave_net_timeout
# won't cause reconnecting by the slave within at least 
# slave_net_timeout interval.
Andrei Elkin's avatar
Andrei Elkin committed
36
--replace_result $MASTER_MYPORT MASTER_PORT 
37 38 39
eval change master to master_host = '127.0.0.1',master_port = $MASTER_MYPORT,
master_user = 'root', master_heartbeat_period = 0;

40 41 42
set @@global.slave_net_timeout = @@global.net_read_timeout * 2;
let $idle_time=`select @@global.slave_net_timeout * 2`;

43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64
let $slave_net_timeout = `select @@global.slave_net_timeout`;

--source include/start_slave.inc

--disable_query_log
--disable_result_log
eval select 'master is idle for ', sleep($idle_time);
--enable_result_log
--enable_query_log

--source include/stop_slave.inc

# querying general-log

connection master;

# In particular the last reconnection timestamp must be greater or equal to
# the previous one + slave_net_timeout

select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time desc limit 1 into @ts_last;
select event_time from (select event_time from mysql.general_log as t_1 where command_type like 'Connect' order by event_time desc limit 2) as t_2 order by event_time asc limit 1 into @ts_prev;

65 66 67
--let $assert_cond= time_to_sec(@ts_last) - time_to_sec(@ts_prev) >= $slave_net_timeout
--let $assert_text= time between last reconnection and the reconnection before that should be >= slave_net_timeout
--source include/assert.inc
68 69 70 71 72 73 74 75 76 77

# cleanup 

# restore global env
connection master;
set @@global.general_log = @save_general_log;
set @@global.log_output = @save_log_output;
connection slave;
set @@global.slave_net_timeout = @save_slave_net_timeout;

78
--let $rpl_only_running_threads= 1
79
--source include/rpl_end.inc