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 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382
|
# Testing master to slave heartbeat protocol
#
# Including:
# - user interface, grammar, checking the range and warnings about
# unreasonable values for the heartbeat period
# - no rotation of relay log if heartbeat is less that replica_net_timeout
# - SELECT COUNT_RECEIVED_HEARTBEATS FROM p_S.replication_connection_status
# - SELECT HEARTBEAT_INTERVAL FROM p_s.replication_connection_configuration
# - SELECT LAST_HEARTBEAT_TIMESTAMP FROM p_s.replication_connection_status
--source include/not_group_replication_plugin.inc
--let $rpl_skip_start_slave= 1
--let $rpl_skip_reset_master_and_slave= 1
--let $rpl_skip_change_master= 1
--source include/master-slave.inc
--let $rpl_connection_name= slave
--source include/rpl_connection.inc
set @restore_replica_net_timeout= @@global.replica_net_timeout;
set @@global.replica_net_timeout= 10;
#
# check for null value of the last_heartbeat_timestamp variable when the slave is not enabled
#
--query_vertical SELECT LAST_HEARTBEAT_TIMESTAMP FROM performance_schema.replication_connection_status
###
### Checking the range
###
#
# default period replica_net_timeout/2
#
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root';
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
#
# the max for the heartbeat_interval is ULONG_MAX/1000; an attempt to exceed it is denied
#
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
--error ER_REPLICA_HEARTBEAT_VALUE_OUT_OF_RANGE
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_HEARTBEAT_PERIOD= 4294968;
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
#
# the min value for the heartbeat_interval is 1 millisecond an attempt to assign a
# lesser will be warned with treating the value as zero
#
--let $rpl_connection_name= slave
--source include/rpl_connection.inc
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
### 5.1 mtr does not have --warning ER_REPLICA_HEARTBEAT_VALUE_OUT_OF_RANGE
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_HEARTBEAT_PERIOD= 0.0009999;
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
#
# the actual max and min must be accepted
#
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_HEARTBEAT_PERIOD= 4294967;
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_HEARTBEAT_PERIOD= 0.001;
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
reset slave;
#
# A warning if heartbeat_interval greater than replica_net_timeout
#
set @@global.replica_net_timeout= 5;
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_HEARTBEAT_PERIOD= 5.001;
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
reset slave;
#
# A warning if replica_net_timeout is set to less than the current HB period
#
set @@global.replica_net_timeout= 5;
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_HEARTBEAT_PERIOD= 4;
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
set @@global.replica_net_timeout= 3 /* must be a warning */;
reset slave;
###
### checking no rotation
###
--let $rpl_connection_name= master
--source include/rpl_connection.inc
--disable_warnings
drop table if exists t1;
--enable_warnings
#
# Even though master_heartbeat_period= 0.5 is 20 times less than
# @@global.replica_net_timeout= 10 in some circumstances master will
# not be able to send any heartbeat during the slave's net timeout
# and slave's relay log will rotate.
# The probability for such a scenario is pretty small so the following
# part is almost deterministic.
#
--let $rpl_connection_name= slave
--source include/rpl_connection.inc
set @@global.replica_net_timeout= 10;
--replace_result $MASTER_MYPORT SOURCE_PORT
# no error this time but rather a warning
--replace_column 2 ####
eval CHANGE REPLICATION SOURCE to SOURCE_HOST='127.0.0.1',SOURCE_PORT=$MASTER_MYPORT, SOURCE_USER='root', SOURCE_HEARTBEAT_PERIOD= 0.5;
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
start slave;
--let $rpl_connection_name= master
--source include/rpl_connection.inc
create table t1 (f1 int);
--source include/sync_slave_sql_with_master.inc
let $slave_param= Relay_Log_File;
let $slave_param_value= query_get_value(SHOW SLAVE STATUS, Relay_Log_File, 1);
# there is an explicit sleep lasting longer than replica_net_timeout
# to ensure that nothing will come to slave from master for that period.
# That would cause reconnecting and relaylog rotation w/o the fix i.e
# without a heartbeat received.
sleep 15;
# check (compare with the previous show's results) that no rotation happened
source include/check_slave_param.inc;
###
### Check the values of HEARTBEAT_INTERVAL and COUNT_RECEIVED_HEARTBEATS
###
--query_vertical SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration
#
# proof that there has been received at least one heartbeat;
# The exact number of received heartbeat is an indeterministic value
# and therefore it's not recorded into results.
#
# Checking the fact that at least one heartbeat is received
--let $wait_condition = SELECT COUNT_RECEIVED_HEARTBEATS > 0 FROM performance_schema.replication_connection_status
--source include/wait_condition.inc
--echo A heartbeat has been received by the slave
#
# check for non-null value of the last_heartbeat_timestamp variable when the slave is enabled
#
--let $assert_text= last_heartbeat_timestamp should not be empty
--let $assert_cond= \'[SELECT LAST_HEARTBEAT_TIMESTAMP FROM performance_schema.replication_connection_status]\' != ""
--source include/assert.inc
# cleanup
--let $rpl_connection_name= master
--source include/rpl_connection.inc
drop table t1;
--source include/sync_slave_sql_with_master.inc
set @@global.replica_net_timeout= @restore_replica_net_timeout;
# ==== Bug#18185490: IF MASTER_HEARTBEAT_PERIOD OPTION IS NOT PROVIDED IT IS AUTO SETTING TO DEFAULT ====
# Change master was always resetting the heartbeat_interval to default value
# and count_received_heartbeats to 0 on change master. After the bug fix,
# change master should only change heartbeat_interval if the corresponding option
# is given and never change count_received_heartbeats
--let $rpl_connection_name= slave
--source include/rpl_connection.inc
--source include/stop_slave.inc
CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD= 10;
--let $assert_text= HEARTBEAT_INTERVAL should be 10.000
--let $assert_cond= [SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration] = 10.000
--source include/assert.inc
--echo
--echo # Verify that heartbeat period is not reset to default implicitly and
--echo # received_heartbeat is not set to 0 by this.
--echo
CHANGE REPLICATION SOURCE TO SOURCE_RETRY_COUNT= 3;
--let $assert_text= HEARTBEAT_INTERVAL should be 10.000
--let $assert_cond= [SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration] = 10.000
--source include/assert.inc
--let $assert_text= COUNT_RECEIVED_HEARTBEATS should NOT be set to 0
--let $assert_cond= [SELECT COUNT_RECEIVED_HEARTBEATS FROM performance_schema.replication_connection_status] <> 0
--source include/assert.inc
###############################################################################
# BUG#18777899 HEARTBEAT_PERIOD AUTOMATICALLY SETS TO DEFAULT POST RESET SLAVE
# COMMAND
#
# Due to the buggy behaviour, a RESET SLAVE command on the slave server
# reset heartbeat_period to default. RESET SLAVE is generally expected to
# delete slave logs and forget the replicaiton positions. This erroneous
# behavior was therefore un-intuitive.
#
# In the test we test the behaviour of heartbeat_period with RESET SLAVE,
# STOP SLAVE, CHANGE MASTER, START SLAVE and RESET SLAVE ALL.
#
# 1. RESET SLAVE:
# ===========
#
# Execute a RESET SLAVE and verify that the heartbeat_period is what we
# set in the latest CHANGE MASTER and not the the default value.
#
# 2. CHANGE MASTER, START SLAVE:
# ==========================
#
# a. Changing host resets heartbeat_period to default.
# b. Changing port resets heartbeat_period to default.
# c. changing host and port resets heartbeat_period to default.
#
# 3. RESET SLAVE ALL:
# ===============
#
# Execute a RESET SLAVE ALL and verify that the heartbeat_period is set to 0.
###############################################################################
--source include/stop_slave.inc
RESET SLAVE;
RESET MASTER;
--let $MASTER_AUTO_POSITION=SOURCE_AUTO_POSITION=0
if (`SELECT @@GLOBAL.gtid_mode = 'ON'`)
{
--let $MASTER_AUTO_POSITION=SOURCE_AUTO_POSITION=1
}
--replace_result $MASTER_AUTO_POSITION SOURCE_AUTO_POSITION
--eval CHANGE REPLICATION SOURCE TO $MASTER_AUTO_POSITION
--source include/start_slave.inc
--let $assert_cond= [SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration] = 10.000
--let $assert_text= HEARTBEAT_INTERVAL should still be 10.000 after RESET SLAVE.
--source include/assert.inc
--source include/stop_slave_io.inc
--replace_result $MASTER_MYPORT SOURCE_PORT
eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= 'localhost', SOURCE_PORT= $MASTER_MYPORT;
--source include/start_slave.inc
--let $default_heartbeat_period= @@global.replica_net_timeout/2;
--let $assert_cond= [SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration] = $default_heartbeat_period
--let $assert_text= HEARTBEAT_INTERVAL should reset to default.
--source include/assert.inc
--echo #
--echo # Change from default to make sure changing HOST resets heartbeat_interval
--echo # to default.
--echo #
--source include/stop_slave_io.inc
CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD = 10;
--source include/start_slave.inc
# The DROP TABLE below is a transaction that will make MTS to be synced
# properly on very slow systems.
--connection master
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--source include/sync_slave_sql_with_master.inc
--source include/stop_slave.inc
eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '127.0.0.1';
--source include/start_slave.inc
--let $assert_cond= [SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration] = $default_heartbeat_period
--let $assert_text= heartbeat_interval should reset to default on changing host.
--source include/assert.inc
# The DROP TABLE below is a transaction that will make MTS to be synced
# properly on very slow systems.
--connection master
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--source include/sync_slave_sql_with_master.inc
--echo #
--echo # Change from default to make sure changing PORT resets heartbeat_interval
--echo # to default.
--echo #
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT SOURCE_PORT
CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD = 10;
--source include/start_slave.inc
# The DROP TABLE below is a transaction that will make MTS to be synced
# properly on very slow systems.
--connection master
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--source include/sync_slave_sql_with_master.inc
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT SOURCE_PORT
eval CHANGE REPLICATION SOURCE TO SOURCE_PORT= $MASTER_MYPORT;
--source include/start_slave.inc
--let $assert_cond= [SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration] = $default_heartbeat_period
--let $assert_text= heartbeat_interval should reset to default on changing port.
--source include/assert.inc
# The DROP TABLE below is a transaction that will make MTS to be synced
# properly on very slow systems.
--connection master
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--source include/sync_slave_sql_with_master.inc
--echo #
--echo # Change from default to make sure changing HOST and PORT resets
--echo # heartbeat_period to default.
--echo #
--source include/stop_slave.inc
--replace_result $MASTER_MYPORT SOURCE_PORT
eval CHANGE REPLICATION SOURCE TO SOURCE_HOST= '127.0.0.1', SOURCE_PORT= $MASTER_MYPORT;
--source include/start_slave.inc
--let $assert_cond= [SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration] = $default_heartbeat_period
--let $assert_text= heartbeat_interval should reset to default on changing host and port.
--source include/assert.inc
# The DROP TABLE below is a transaction that will make MTS to be synced
# properly on very slow systems.
--connection master
--disable_warnings
DROP TABLE IF EXISTS t1;
--enable_warnings
--source include/sync_slave_sql_with_master.inc
--source include/stop_slave.inc
RESET SLAVE ALL;
--let $assert_cond= \'[SELECT HEARTBEAT_INTERVAL FROM performance_schema.replication_connection_configuration]\' = ""
--let $assert_text= heartbeat_interval should reset to zero by RESET SLAVE ALL.
--source include/assert.inc
# Make this a slave again to successfully pass through cleanup routines.
--replace_result $MASTER_MYPORT SOURCE_PORT
--replace_column 2 ####
--eval CHANGE REPLICATION SOURCE to SOURCE_HOST= '127.0.0.1', SOURCE_PORT= $MASTER_MYPORT, SOURCE_USER= 'root'
# The table might have replicated again after RESET SLAVE.
--source include/start_slave.inc
--connection master
--disable_warnings
DROP TABLE IF EXISTS t1;
--source include/sync_slave_sql_with_master.inc
--enable_warnings
--source include/rpl_end.inc
|