~ubuntu-branches/ubuntu/precise/mysql-5.5/precise-201203300109

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_heartbeat.test

  • Committer: Package Import Robot
  • Author(s): Clint Byrum
  • Date: 2011-11-08 11:31:13 UTC
  • Revision ID: package-import@ubuntu.com-20111108113113-3ulw01fvi4vn8m25
Tags: upstream-5.5.17
ImportĀ upstreamĀ versionĀ 5.5.17

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# Testing master to slave heartbeat protocol
 
2
 
3
# Including:
 
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
 
9
 
 
10
-- source include/have_log_bin.inc
 
11
 
 
12
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
 
13
connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
 
14
 
 
15
connection master;
 
16
reset master;
 
17
 
 
18
connection slave;
 
19
set @restore_slave_net_timeout= @@global.slave_net_timeout;
 
20
set @@global.slave_net_timeout= 10;
 
21
 
 
22
###
 
23
### Checking the range
 
24
###
 
25
 
 
26
#
 
27
# default period slave_net_timeout/2
 
28
#
 
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';
 
32
 
 
33
#
 
34
# the max for the period is ULONG_MAX/1000; an attempt to exceed it is  denied
 
35
#
 
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';
 
40
 
 
41
#
 
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
 
44
#
 
45
connection slave;
 
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';
 
50
 
 
51
#
 
52
# the actual max and min must be accepted
 
53
#
 
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';
 
57
 
 
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';
 
61
 
 
62
reset slave;
 
63
 
 
64
#
 
65
# A warning if period greater than slave_net_timeout
 
66
#
 
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';
 
71
 
 
72
reset slave;
 
73
 
 
74
#
 
75
# A warning if slave_net_timeout is set to less than the current HB period
 
76
#
 
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 */;
 
82
 
 
83
reset slave;
 
84
 
 
85
 
 
86
###
 
87
### checking no rotation
 
88
###
 
89
 
 
90
connection master;
 
91
--disable_warnings
 
92
drop table if exists t1;
 
93
--enable_warnings
 
94
#
 
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.
 
101
#
 
102
 
 
103
connection slave;
 
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';
 
109
 
 
110
start slave;
 
111
 
 
112
connection master;
 
113
create table t1 (f1 int);
 
114
 
 
115
#connection slave;
 
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);
 
119
 
 
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.
 
124
 
 
125
real_sleep 15;
 
126
 
 
127
# check (compare with the previous show's results) that no rotation happened
 
128
source include/check_slave_param.inc;
 
129
 
 
130
###
 
131
### SHOW STATUS like 'Slave_heartbeat_period' and 'Slave_received_heartbeats'
 
132
###
 
133
 
 
134
--query_vertical show status like 'Slave_heartbeat_period';
 
135
 
 
136
#
 
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.
 
140
#
 
141
 
 
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)
 
146
{
 
147
  dec $slave_wait_param_counter;
 
148
  if (!$slave_wait_param_counter)
 
149
  {
 
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';
 
153
    exit;
 
154
  }
 
155
  sleep 0.1;
 
156
  let $slave_value= query_get_value("SHOW STATUS like 'Slave_received_heartbeats'", Value, 1);
 
157
}
 
158
--echo A heartbeat has been received by the slave
 
159
# cleanup
 
160
 
 
161
connection master;
 
162
drop table t1;
 
163
 
 
164
#connection slave;
 
165
sync_slave_with_master;
 
166
set @@global.slave_net_timeout= @restore_slave_net_timeout;
 
167
 
 
168
--source include/stop_slave.inc
 
169
 
 
170
--echo End of tests