| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# The purpose of this script is to test that the binary log thread |
| 4 |
# does not exit in case events are written after some "idle" time, |
| 5 |
# after which the source sends heartbeat messages to the replica |
| 6 |
# |
| 7 |
# ==== Requirements ==== |
| 8 |
# |
| 9 |
# R1. Dump thread with heartbeat option enabled should disconnect |
| 10 |
# only if an error occurs (send/flush). |
| 11 |
# |
| 12 |
# ==== Implementation ==== |
| 13 |
# |
| 14 |
# 1. Setup a simple replication topology : source -> replica |
| 15 |
# 2. Setup heartbeat period to 1 ms |
| 16 |
# 3. Execute `mysqlslap` in a loop. |
| 17 |
# Let the source send heartbeat messages between iterations. |
| 18 |
# 4. Sync the replica. |
| 19 |
# 5. Verify that dump thread was not restarted between mysqlslap |
| 20 |
# iterations. Dump thread should exit only if a network is |
| 21 |
# unstable, e.g. there was an error on "send" or "flush". |
| 22 |
# 6. Cleanup |
| 23 |
# |
| 24 |
# ==== References ==== |
| 25 |
# |
| 26 |
# BUG#34860923 Timeout on cv in waiting with heartbeat cause dump thread to stop |
| 27 |
# |
| 28 |
|
| 29 |
--echo |
| 30 |
--echo 1. Setup a simple replication topology : source -> replica |
| 31 |
--echo |
| 32 |
--source include/master-slave.inc |
| 33 |
--source include/have_binlog_format_row.inc |
| 34 |
|
| 35 |
--echo |
| 36 |
--echo 2. Setup heartbeat period to 1 ms |
| 37 |
--echo |
| 38 |
--source include/rpl_connection_slave.inc |
| 39 |
--source include/stop_slave.inc |
| 40 |
--let $saved_heartbeat_period = `SELECT Heartbeat FROM mysql.slave_master_info` |
| 41 |
CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD=0.001; |
| 42 |
--source include/start_slave.inc |
| 43 |
|
| 44 |
--source include/rpl_connection_master.inc |
| 45 |
CREATE TABLE test.t(a INT); |
| 46 |
|
| 47 |
--echo |
| 48 |
--echo 3. Execute `mysqlslap` in a loop. |
| 49 |
--echo Let the source send heartbeat messages between iterations. |
| 50 |
--echo |
| 51 |
|
| 52 |
--let $mysqlslap_total_iters = 50 |
| 53 |
--let $i = 0 |
| 54 |
|
| 55 |
--let $rpl_connection_name= server_1 |
| 56 |
--source include/rpl_connection.inc |
| 57 |
|
| 58 |
while ($i < $mysqlslap_total_iters) |
| 59 |
{ |
| 60 |
--exec $MYSQL_SLAP --create-schema=test --delimiter=";" --iterations=5 --query="INSERT INTO test.t VALUES (1)" --concurrency=1 --silent 2>&1 |
| 61 |
--inc $i |
| 62 |
--sleep 0.1 |
| 63 |
} |
| 64 |
|
| 65 |
--echo |
| 66 |
--echo 4. Sync the replica |
| 67 |
--echo |
| 68 |
--source include/rpl_connection_master.inc |
| 69 |
--source include/sync_slave_sql_with_master.inc |
| 70 |
|
| 71 |
--echo |
| 72 |
--echo 5. Verify that Dump thread was not restarted between |
| 73 |
--echo mysqlslap iterations. Dump thread should exit only |
| 74 |
--echo if network is unstable, e.g. there was an error on 'send' or 'flush' |
| 75 |
--echo |
| 76 |
|
| 77 |
--let $assert_text = Binary dump log thread should be started twice |
| 78 |
--let $assert_file = $MYSQLTEST_VARDIR/log/mysqld.1.err |
| 79 |
--let $assert_select = Start binlog_dump to |
| 80 |
--let $assert_count = 2 |
| 81 |
--source include/assert_grep.inc |
| 82 |
|
| 83 |
--echo |
| 84 |
--echo 6. Cleanup |
| 85 |
--echo |
| 86 |
|
| 87 |
|
| 88 |
--source include/rpl_connection_slave.inc |
| 89 |
--source include/stop_slave.inc |
| 90 |
--replace_result $saved_heartbeat_period SAVED_HEARTBEAT_PERIOD |
| 91 |
--eval CHANGE REPLICATION SOURCE TO SOURCE_HEARTBEAT_PERIOD=$saved_heartbeat_period |
| 92 |
--source include/start_slave.inc |
| 93 |
|
| 94 |
--source include/rpl_connection_master.inc |
| 95 |
DROP TABLE test.t; |
| 96 |
|
| 97 |
--source include/rpl_end.inc |