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
6CALL mtr.add_suppression("Unsafe statement written to the binary log using statement format since BINLOG_FORMAT = STATEMENT");
7
8# Load some data into t1
9create table t1 (word char(20) not null);
10load data infile '../../std_data/words.dat' into table t1;
11--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
12eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
13select * from t1 limit 10;
14
15#
16# Test slave with wrong password
17#
18sync_slave_with_master;
19stop slave;
20connection master;
21create temporary table tmp select * from mysql.global_priv where host="localhost" and user="root";
22set password for root@"localhost" = password('foo');
23connection slave;
24start slave;
25connection 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
29real_sleep 2;
30replace into mysql.global_priv select * from tmp;
31drop temporary table tmp;
32flush privileges;
33# Give slave time to connect (will retry every second)
34sleep 2;
35
36create table t3(n int);
37insert into t3 values(1),(2);
38sync_slave_with_master;
39select * from t3;
40select sum(length(word)) from t1;
41connection master;
42drop table t1,t3;
43sync_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
48connection master;
49# we'll use table-level locking to delay slave SQL thread
50eval create table t1 (n int);
51sync_slave_with_master;
52connection master;
53reset master;
54connection slave;
55stop slave;
56reset slave;
57
58connection master;
59let $1=5000;
60# Generate 16K of relay log
61disable_query_log;
62while ($1)
63{
64 eval insert into t1 values($1);
65 dec $1;
66}
67enable_query_log;
68
69# Try to cause a large relay log lag on the slave by locking t1
70connection slave;
71lock tables t1 read;
72start slave;
73connection master;
74--source include/sync_slave_io_with_master.inc
75unlock tables;
76
77#test handling of aborted connection in the middle of update
78
79connection master;
80create table t2(id int);
81insert into t2 values(connection_id());
82
83connection master1;
84# Avoid generating result
85create temporary table t3(n int);
86--disable_warnings
87insert into t3 select get_lock('crash_lock%20C', 1) from t2;
88--enable_warnings
89
90connection master;
91send update t1 set n = n + get_lock('crash_lock%20C', 2);
92connection master1;
93let $wait_condition= SELECT count(*) > 0 FROM information_schema.processlist WHERE info LIKE 'update%' AND state='User lock';
94source include/wait_condition.inc;
95select (@id := id) - id from t2;
96kill @id;
97drop table t2;
98drop temporary table t3;
99connection 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
104reap;
105--enable_warnings
106connection 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
113select count(*) from t1;
114connection master1;
115drop table t1;
116
117# End of 4.1 tests
118--source include/rpl_end.inc
119