| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Verify if the slave SQL thread is avoiding to update position when a Rotate |
| 4 |
# event is applied in the middle of a group. |
| 5 |
# |
| 6 |
# This test will execute two INSERT statements in the master and will use |
| 7 |
# a debug sync point in the slave to rotate the relay log (restarting the IO |
| 8 |
# thread) after each Write_rows event be queued into the relay log. |
| 9 |
# |
| 10 |
# The slave SQL thread should not update its position while in the middle of |
| 11 |
# the transaction. |
| 12 |
# |
| 13 |
# After the last stop of the IO thread, the SQL thread will also be stopped. |
| 14 |
# |
| 15 |
# Both threads will be started to finish the test. |
| 16 |
# |
| 17 |
# A problematic SQL thread will restart in the middle of the transaction and |
| 18 |
# will skip the first INSERT statement. |
| 19 |
# |
| 20 |
# ==== Related Bugs and Worklogs ==== |
| 21 |
# |
| 22 |
# Bug #18482854 RPL : ROTATE_LOG_EVENT INCORRECTLY ADVANCES GROUP_RELAY_LOG_POS |
| 23 |
# IN A GROUP |
| 24 |
# |
| 25 |
--source include/have_binlog_format_row.inc |
| 26 |
--source include/master-slave.inc |
| 27 |
# Test should run only on debug build |
| 28 |
source include/have_debug.inc; |
| 29 |
source include/have_debug_sync.inc; |
| 30 |
|
| 31 |
# test requires that IO thread searches for WRITE_ROWS_EVENT |
| 32 |
# which in case compression is enabled this is wrapped in |
| 33 |
# a transaction payload event, thence the signal needed below |
| 34 |
# is never emitted. Test is incompatible with compression, |
| 35 |
# skipping it. |
| 36 |
--source include/not_binlog_transaction_compression_on.inc |
| 37 |
|
| 38 |
--disable_query_log |
| 39 |
call mtr.add_suppression("The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state"); |
| 40 |
--enable_query_log |
| 41 |
|
| 42 |
--echo # Initial setup |
| 43 |
--source include/rpl_connection_master.inc |
| 44 |
CREATE TABLE t1 (c1 INT) ENGINE=InnoDB; |
| 45 |
|
| 46 |
--echo # Sync slave with master and setup debug sync point |
| 47 |
--source include/sync_slave_sql_with_master.inc |
| 48 |
SET @save_debug=@@global.debug; |
| 49 |
SET GLOBAL DEBUG='+d,stop_io_after_reading_write_rows_log_event'; |
| 50 |
|
| 51 |
--echo # Insert the data in the master |
| 52 |
--source include/rpl_connection_master.inc |
| 53 |
|
| 54 |
--let iterations= 2 |
| 55 |
--let $inserts= 0 |
| 56 |
BEGIN; |
| 57 |
while ($inserts < $iterations) |
| 58 |
{ |
| 59 |
--eval INSERT INTO t1 (c1) VALUES ($inserts) |
| 60 |
--inc $inserts |
| 61 |
} |
| 62 |
COMMIT; |
| 63 |
|
| 64 |
--echo # Restart the IO thread keeping SQL thread running until last relay log split |
| 65 |
|
| 66 |
--source include/rpl_connection_slave.inc |
| 67 |
--let $restarts= $iterations |
| 68 |
|
| 69 |
while ($restarts) |
| 70 |
{ |
| 71 |
--source include/wait_for_slave_io_to_stop.inc |
| 72 |
--dec $restarts |
| 73 |
if ($restarts) |
| 74 |
{ |
| 75 |
START SLAVE IO_THREAD; |
| 76 |
} |
| 77 |
} |
| 78 |
|
| 79 |
--echo # Stop the SQL thread (it should be in the middle of the transaction/group) |
| 80 |
--let $slave_sql_errno= convert_error(ER_MTA_INCONSISTENT_DATA) |
| 81 |
--source include/stop_slave_sql.inc |
| 82 |
|
| 83 |
--echo # Remove the debug point and restart the both threads |
| 84 |
SET GLOBAL DEBUG= @save_debug; |
| 85 |
--source include/start_slave.inc |
| 86 |
|
| 87 |
--echo # Do one more insert on master and then sync slave with master |
| 88 |
--source include/rpl_connection_master.inc |
| 89 |
--eval INSERT INTO t1 (c1) VALUES ($inserts) |
| 90 |
--source include/sync_slave_sql_with_master.inc |
| 91 |
|
| 92 |
--echo # Now compare master and slave's t1 table data |
| 93 |
--source include/rpl_connection_master.inc |
| 94 |
--let diff_tables= master:t1, slave:t1 |
| 95 |
--source include/diff_tables.inc |
| 96 |
|
| 97 |
--echo # Cleanup |
| 98 |
--source include/rpl_connection_master.inc |
| 99 |
DROP TABLE t1; |
| 100 |
--source include/rpl_end.inc |