1
# Testing master to slave heartbeat protocol
4
# - user interface, grammar, checking the range and warnings about
5
# unreasonable values for the heartbeat period;
6
# - no rotation of relay log if heartbeat is less that slave_net_timeout
7
# - SHOW STATUS like 'Slave_received_heartbeats' action
8
# - SHOW STATUS like 'Slave_heartbeat_period' report
10
-- source include/have_log_bin.inc
12
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
13
connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
19
set @restore_slave_net_timeout= @@global.slave_net_timeout;
20
set @@global.slave_net_timeout= 10;
23
### Checking the range
27
# default period slave_net_timeout/2
29
--replace_result $MASTER_MYPORT MASTER_PORT
30
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
31
--query_vertical show status like 'Slave_heartbeat_period';
34
# the max for the period is ULONG_MAX/1000; an attempt to exceed it is denied
36
--replace_result $MASTER_MYPORT MASTER_PORT
37
--error ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
38
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 4294968;
39
--query_vertical show status like 'Slave_heartbeat_period';
42
# the min value for the period is 1 millisecond an attempt to assign a
43
# lesser will be warned with treating the value as zero
46
--replace_result $MASTER_MYPORT MASTER_PORT
47
### 5.1 mtr does not have --warning ER_SLAVE_HEARTBEAT_VALUE_OUT_OF_RANGE
48
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 0.0009999;
49
--query_vertical show status like 'Slave_heartbeat_period';
52
# the actual max and min must be accepted
54
--replace_result $MASTER_MYPORT MASTER_PORT
55
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 4294967;
56
--query_vertical show status like 'Slave_heartbeat_period';
58
--replace_result $MASTER_MYPORT MASTER_PORT
59
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 0.001;
60
--query_vertical show status like 'Slave_heartbeat_period';
65
# A warning if period greater than slave_net_timeout
67
set @@global.slave_net_timeout= 5;
68
--replace_result $MASTER_MYPORT MASTER_PORT
69
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 5.001;
70
--query_vertical show status like 'Slave_heartbeat_period';
75
# A warning if slave_net_timeout is set to less than the current HB period
77
set @@global.slave_net_timeout= 5;
78
--replace_result $MASTER_MYPORT MASTER_PORT
79
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 4;
80
--query_vertical show status like 'Slave_heartbeat_period';
81
set @@global.slave_net_timeout= 3 /* must be a warning */;
87
### checking no rotation
92
drop table if exists t1;
95
# Even though master_heartbeat_period= 0.5 is 20 times less than
96
# @@global.slave_net_timeout= 10 in some circumstances master will
97
# not be able to send any heartbeat during the slave's net timeout
98
# and slave's relay log will rotate.
99
# The probability for such a scenario is pretty small so the following
100
# part is almost deterministic.
104
set @@global.slave_net_timeout= 10;
105
--replace_result $MASTER_MYPORT MASTER_PORT
106
# no error this time but rather a warning
107
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root', master_heartbeat_period= 0.5;
108
--query_vertical show status like 'Slave_heartbeat_period';
113
create table t1 (f1 int);
116
sync_slave_with_master;
117
let $slave_param= Relay_Log_File;
118
let $slave_param_value= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
120
# there is an explicit sleep lasting longer than slave_net_timeout
121
# to ensure that nothing will come to slave from master for that period.
122
# That would cause reconnecting and relaylog rotation w/o the fix i.e
123
# without a heartbeat received.
127
# check (compare with the previous show's results) that no rotation happened
128
source include/check_slave_param.inc;
131
### SHOW STATUS like 'Slave_heartbeat_period' and 'Slave_received_heartbeats'
134
--query_vertical show status like 'Slave_heartbeat_period';
137
# proof that there has been received at least one heartbeat;
138
# The exact number of received heartbeat is an indeterministic value
139
# and therefore it's not recorded into results.
142
let $slave_wait_param_counter= 300;
143
let $slave_value= query_get_value("SHOW STATUS like 'Slave_received_heartbeats'", Value, 1);
144
# Checking the fact that at least one heartbeat is received
145
while (!$slave_value)
147
dec $slave_wait_param_counter;
148
if (!$slave_wait_param_counter)
150
--echo ERROR: failed while waiting for slave parameter $slave_param: $slave_param_value
151
query_vertical show slave status;
152
SHOW STATUS like 'Slave_received_heartbeats';
156
let $slave_value= query_get_value("SHOW STATUS like 'Slave_received_heartbeats'", Value, 1);
158
--echo A heartbeat has been received by the slave
165
sync_slave_with_master;
166
set @@global.slave_net_timeout= @restore_slave_net_timeout;
168
--source include/stop_slave.inc