| 1 |
# Requires binlog_format=statement format since query involving |
| 2 |
# get_lock() is logged in row format if binlog_format=mixed or row. |
| 3 |
-- source include/have_binlog_format_statement.inc |
| 4 |
-- source include/master-slave.inc |
| 5 |
|
| 6 |
CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT"); |
| 7 |
|
| 8 |
# Load some data into t1 |
| 9 |
create table t1 (word char(20) not null); |
| 10 |
load data infile '../../std_data/words.dat' into table t1; |
| 11 |
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR |
| 12 |
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1; |
| 13 |
select * from t1 limit 10; |
| 14 |
|
| 15 |
# |
| 16 |
# Test slave with wrong password |
| 17 |
# |
| 18 |
sync_slave_with_master; |
| 19 |
stop slave; |
| 20 |
connection master; |
| 21 |
create temporary table tmp select * from mysql.global_priv where host="localhost" and user="root"; |
| 22 |
set password for root@"localhost" = password('foo'); |
| 23 |
connection slave; |
| 24 |
start slave; |
| 25 |
connection master; |
| 26 |
# |
| 27 |
# Give slave time to do at last one failed connect retry |
| 28 |
# This one must be short so that the slave will not stop retrying |
| 29 |
real_sleep 2; |
| 30 |
replace into mysql.global_priv select * from tmp; |
| 31 |
drop temporary table tmp; |
| 32 |
flush privileges; |
| 33 |
# Give slave time to connect (will retry every second) |
| 34 |
sleep 2; |
| 35 |
|
| 36 |
create table t3(n int); |
| 37 |
insert into t3 values(1),(2); |
| 38 |
sync_slave_with_master; |
| 39 |
select * from t3; |
| 40 |
select sum(length(word)) from t1; |
| 41 |
connection master; |
| 42 |
drop table t1,t3; |
| 43 |
sync_slave_with_master; |
| 44 |
|
| 45 |
# Test if the slave SQL thread can be more than 16K behind the slave |
| 46 |
# I/O thread (> IO_SIZE) |
| 47 |
|
| 48 |
connection master; |
| 49 |
# we'll use table-level locking to delay slave SQL thread |
| 50 |
eval create table t1 (n int); |
| 51 |
sync_slave_with_master; |
| 52 |
connection master; |
| 53 |
reset master; |
| 54 |
connection slave; |
| 55 |
stop slave; |
| 56 |
--source include/reset_slave.inc |
| 57 |
|
| 58 |
connection master; |
| 59 |
let $1=5000; |
| 60 |
# Generate 16K of relay log |
| 61 |
disable_query_log; |
| 62 |
while ($1) |
| 63 |
{ |
| 64 |
eval insert into t1 values($1); |
| 65 |
dec $1; |
| 66 |
} |
| 67 |
enable_query_log; |
| 68 |
|
| 69 |
# Try to cause a large relay log lag on the slave by locking t1 |
| 70 |
connection slave; |
| 71 |
lock tables t1 read; |
| 72 |
start slave; |
| 73 |
connection master; |
| 74 |
--source include/sync_slave_io_with_master.inc |
| 75 |
unlock tables; |
| 76 |
|
| 77 |
#test handling of aborted connection in the middle of update |
| 78 |
|
| 79 |
connection master; |
| 80 |
create table t2(id int); |
| 81 |
insert into t2 values(connection_id()); |
| 82 |
|
| 83 |
connection master1; |
| 84 |
# Avoid generating result |
| 85 |
create temporary table t3(n int); |
| 86 |
--disable_warnings |
| 87 |
insert into t3 select get_lock('crash_lock%20C', 1) from t2; |
| 88 |
--enable_warnings |
| 89 |
|
| 90 |
connection master; |
| 91 |
send update t1 set n = n + get_lock('crash_lock%20C', 2); |
| 92 |
connection master1; |
| 93 |
let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE info LIKE 'update%' AND state='User lock'; |
| 94 |
source include/wait_condition.inc; |
| 95 |
select (@id := id) - id from t2; |
| 96 |
kill @id; |
| 97 |
drop table t2; |
| 98 |
drop temporary table t3; |
| 99 |
connection master; |
| 100 |
# The get_lock function causes warning for unsafe statement. |
| 101 |
--disable_warnings |
| 102 |
# 2013 = CR_SERVER_LOST |
| 103 |
--error ER_QUERY_INTERRUPTED,ER_CONNECTION_KILLED,2013 |
| 104 |
reap; |
| 105 |
--enable_warnings |
| 106 |
connection slave; |
| 107 |
# The SQL slave thread should now have stopped because the query was killed on |
| 108 |
# the master (so it has a non-zero error code in the binlog). |
| 109 |
# 1927 = ER_CONNECTION_KILLED |
| 110 |
--let $slave_sql_errno= 1927 |
| 111 |
--source include/wait_for_slave_sql_error_and_skip.inc |
| 112 |
|
| 113 |
select count(*) from t1; |
| 114 |
connection master1; |
| 115 |
drop table t1; |
| 116 |
|
| 117 |
# End of 4.1 tests |
| 118 |
--source include/rpl_end.inc |