| 1 |
# ==== Purpose ==== |
| 2 |
# |
| 3 |
# Test the behavior of slave when binlog_format=statement and a query |
| 4 |
# that updates a non-transactional table is killed on the master, |
| 5 |
# after being only half-way completed. |
| 6 |
# |
| 7 |
# The following should hold: |
| 8 |
# - The statement should be logged with error code ER_QUERY_INTERRUPTED. |
| 9 |
# - The slave should normally stop with an error. |
| 10 |
# - If the table or database is filtered out, the slave should not stop. |
| 11 |
# |
| 12 |
# To test this, we test three cases: |
| 13 |
# 1. Killed query on master generates error on slave. |
| 14 |
# 2. Killed query on master, on a filtered-out table, does not |
| 15 |
# generate error on slave. |
| 16 |
# 3. Killed query on master, on a table in a filtered-out database, |
| 17 |
# does not generate error on slave. |
| 18 |
# |
| 19 |
# ==== Implemenation ==== |
| 20 |
# |
| 21 |
# For case 1, we extecute a statement and kill it in the middle, then |
| 22 |
# verify that the slave stops with the correct error. |
| 23 |
# |
| 24 |
# For cases 2 and 3, we execute a statement and kill it in the middle, |
| 25 |
# then verify that the slave replicates without problems. In case 2, |
| 26 |
# the statement is executed when the current database is filtered-out. |
| 27 |
# In case 3, the statement modifies a table that is filtered-out. |
| 28 |
# |
| 29 |
# Slave filters are specified in rpl_kill_query.cnf |
| 30 |
# |
| 31 |
# The procedure to generate a killed statement is similar in all three |
| 32 |
# cases. See extra/rpl_tests/rpl_kill_query.inc for details. |
| 33 |
# |
| 34 |
# ==== References ==== |
| 35 |
# |
| 36 |
# BUG#18145032: NO EMPTY TRANSACTION IS CREATED FOR A FILTERED CREATE TEMPORARY TABLE WITH GTIDS |
| 37 |
# - Test created as part of this fix, since it touches the code for |
| 38 |
# filtering. |
| 39 |
|
| 40 |
--source include/have_binlog_format_statement.inc |
| 41 |
--source include/master-slave.inc |
| 42 |
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); |
| 43 |
CALL mtr.add_suppression("The replica coordinator and worker threads are stopped, possibly leaving data in inconsistent state"); |
| 44 |
--sync_slave_with_master |
| 45 |
--connection master |
| 46 |
|
| 47 |
--echo ==== Case 1: Killed query on master -> error on slave ==== |
| 48 |
|
| 49 |
--let $database= db1 |
| 50 |
--let $table= t1 |
| 51 |
--source extra/rpl_tests/rpl_kill_query.inc |
| 52 |
|
| 53 |
--echo ---- Verify there is an error on slave ---- |
| 54 |
--source include/sync_slave_io_with_master.inc |
| 55 |
--let $slave_sql_errno= convert_error(ER_ERROR_ON_SOURCE) |
| 56 |
--source include/wait_for_slave_sql_error.inc |
| 57 |
|
| 58 |
--echo ---- Verify that nothing was inserted on slave ----- |
| 59 |
--let $assert_text= Nothing should be inserted on slave |
| 60 |
--let $assert_cond= [slave:SELECT COUNT(*) FROM $database.t1] = 0 |
| 61 |
--source include/assert.inc |
| 62 |
|
| 63 |
--echo ---- Clean up ---- |
| 64 |
--source include/stop_slave_io.inc |
| 65 |
RESET SLAVE; |
| 66 |
RESET MASTER; |
| 67 |
DROP DATABASE db1; |
| 68 |
--source include/rpl_connection_master.inc |
| 69 |
RESET MASTER; |
| 70 |
--source include/rpl_connection_slave.inc |
| 71 |
--source include/start_slave.inc |
| 72 |
--source include/rpl_connection_master.inc |
| 73 |
|
| 74 |
--echo ==== Case 2: Master kills query -> no error if slave filters by db ==== |
| 75 |
|
| 76 |
--let $database= ignored_db |
| 77 |
--let $table= t1 |
| 78 |
--source extra/rpl_tests/rpl_kill_query.inc |
| 79 |
|
| 80 |
--echo ---- Verify all was replicated ok ---- |
| 81 |
--source include/sync_slave_sql_with_master.inc |
| 82 |
--source include/rpl_connection_master.inc |
| 83 |
|
| 84 |
--echo ==== Case 3: Master kills query -> no error if slave filters by table ==== |
| 85 |
|
| 86 |
--let $database= db1 |
| 87 |
--let $table= ignored_table |
| 88 |
--source extra/rpl_tests/rpl_kill_query.inc |
| 89 |
|
| 90 |
--echo ---- Verify all was replicated ok ---- |
| 91 |
--source include/sync_slave_sql_with_master.inc |
| 92 |
|
| 93 |
--source include/rpl_end.inc |