| 1 |
# Test for |
| 2 |
# Bug#797: If a query is ignored on slave (replicate-ignore-table) the |
| 3 |
# slave still checks that it has the same error as on the master. |
| 4 |
########################################################################## |
| 5 |
# 2006-02-07 JBM Added error code 1022 for NDB Engine + ORDER BY |
| 6 |
########################################################################## |
| 7 |
--source include/force_myisam_default.inc |
| 8 |
--source include/have_myisam.inc |
| 9 |
--source include/not_group_replication_plugin.inc |
| 10 |
--source include/master-slave.inc |
| 11 |
|
| 12 |
--disable_query_log |
| 13 |
CALL mtr.add_suppression( |
| 14 |
CONCAT("Unsafe statement written to the binary log ", |
| 15 |
"using statement format since BINLOG_FORMAT = STATEMENT.")); |
| 16 |
--enable_query_log |
| 17 |
|
| 18 |
--connection master |
| 19 |
# Attention: |
| 20 |
# The table t1 MUST use some non transactional storage engine in order to |
| 21 |
# replay the scenario of Bug#797. |
| 22 |
create table t1 (a int primary key) engine = myisam; |
| 23 |
create table t4 (a int primary key); |
| 24 |
|
| 25 |
# The insert statement which follows |
| 26 |
# - fails with ER_DUP_KEY or ER_DUP_ENTRY |
| 27 |
# - but must be copied to the binlog when using mixed or statement based |
| 28 |
# replication because the first row gets inserted into the table using |
| 29 |
# the non transactional storage engine. |
| 30 |
--error ER_DUP_KEY, ER_DUP_ENTRY |
| 31 |
insert into t1 values (1),(1); |
| 32 |
# For debugging: |
| 33 |
# Expect to see "insert into t1 values (1),(1)" in the output of |
| 34 |
# --source include/show_binlog_events.inc |
| 35 |
insert into t4 values (1),(2); |
| 36 |
# as the t1 table is ignored on the slave, the slave should be able to sync |
| 37 |
--source include/sync_slave_sql_with_master.inc |
| 38 |
# check that the table has been ignored, because otherwise the test is nonsense |
| 39 |
show tables like 't1'; |
| 40 |
show tables like 't4'; |
| 41 |
SELECT * FROM test.t4 ORDER BY a; |
| 42 |
--connection master |
| 43 |
drop table t1; |
| 44 |
--source include/sync_slave_sql_with_master.inc |
| 45 |
|
| 46 |
# Now test that even critical errors (connection killed) are ignored if the |
| 47 |
# rules allow it. The "kill" idea was copied from rpl000001.test. |
| 48 |
|
| 49 |
--connection master1 |
| 50 |
select get_lock('crash_lock%20C', 10); |
| 51 |
|
| 52 |
--connection master |
| 53 |
# Attention: |
| 54 |
# t2 MUST use some non transactional storage engine in order to replay the |
| 55 |
# intended scenario. |
| 56 |
create table t2 (a int primary key) engine = myisam; |
| 57 |
insert into t2 values(1),(2); |
| 58 |
let $master_id= `select connection_id()`; |
| 59 |
# The "if( a = 1, 10, get_lock ...." takes care that we have probably |
| 60 |
# already processed the first row before the waiting for the lock starts. |
| 61 |
send update t2 set a = a + if(a = 1, 10, get_lock('crash_lock%20C', 10)); |
| 62 |
|
| 63 |
--connection master1 |
| 64 |
# Wait until we can be sure that the execution of the update is in the phase |
| 65 |
# where it waits for getting the user lock. |
| 66 |
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist |
| 67 |
WHERE info LIKE 'update%' AND state = 'User lock'; |
| 68 |
--source include/wait_condition_or_abort.inc |
| 69 |
--replace_result $master_id <master_id> |
| 70 |
eval kill $master_id; |
| 71 |
# Wait until it is safe to issue DROP TABLE without causing deadlock. |
| 72 |
# let $wait_condition= SELECT count(*) = 0 FROM information_schema.processlist |
| 73 |
# WHERE info LIKE 'update%' AND state = 'User lock'; |
| 74 |
let $wait_condition= SELECT count(*) = 0 FROM information_schema.processlist |
| 75 |
WHERE id = $master_id; |
| 76 |
--source include/wait_condition_or_abort.inc |
| 77 |
# For debugging: |
| 78 |
# Expect to see "update t2 set a = a + if(a = 1, ........." |
| 79 |
# --source include/show_binlog_events.inc |
| 80 |
drop table t2; |
| 81 |
insert into t4 values (3),(4); |
| 82 |
--connection master |
| 83 |
# The get_lock function causes warning for unsafe statement in case of using |
| 84 |
# binlog_format=statement. |
| 85 |
--disable_warnings |
| 86 |
--error 0,ER_QUERY_INTERRUPTED,2013 |
| 87 |
reap; |
| 88 |
--enable_warnings |
| 89 |
--connection master1 |
| 90 |
--source include/sync_slave_sql_with_master.inc |
| 91 |
SELECT * FROM test.t4 ORDER BY a; |
| 92 |
|
| 93 |
--connection master1 |
| 94 |
DROP TABLE test.t4; |
| 95 |
--source include/sync_slave_sql_with_master.inc |
| 96 |
# End of 4.1 tests |
| 97 |
# Adding comment for force manual merge 5.0 -> wl1012. delete me if needed |
| 98 |
|
| 99 |
|
| 100 |
--source include/rpl_end.inc |