rpl_stm_000001.test 3.39 KB
Newer Older
1
-- source include/have_binlog_format_mixed_or_statement.inc
2
-- source include/master-slave.inc
3

4
create table t1 (word char(20) not null);
5
load data infile '../std_data_ln/words.dat' into table t1;
6
--replace_result $MYSQL_TEST_DIR MYSQL_TEST_DIR
sasha@mysql.sashanet.com's avatar
sasha@mysql.sashanet.com committed
7
eval load data local infile '$MYSQL_TEST_DIR/std_data/words.dat' into table t1;
8
select * from t1 limit 10;
9 10 11 12 13 14 15

#
# Test slave with wrong password
#
save_master_pos;
connection slave;
sync_with_master;
16
stop slave;
17
connection master;
18
set password for root@"localhost" = password('foo');
19
connection slave;
20
start slave;
21
connection master;
22
#
23
# Give slave time to do at last one failed connect retry
24 25
# This one must be short so that the slave will not stop retrying
real_sleep 2;
26
set password for root@"localhost" = password('');
27 28 29
# Give slave time to connect (will retry every second)
sleep 2;

30 31
create table t3(n int);
insert into t3 values(1),(2);
32
save_master_pos;
33
connection slave;
34
sync_with_master;
35
select * from t3;
36
select sum(length(word)) from t1;
37
connection master;
38
drop table t1,t3;
39 40 41
save_master_pos;
connection slave;
sync_with_master;
42

43 44 45 46 47
# Test if the slave SQL thread can be more than 16K behind the slave
# I/O thread (> IO_SIZE)

connection master;
# we'll use table-level locking to delay slave SQL thread
48
eval create table t1 (n int) engine=$engine_type;
49
sync_slave_with_master;
50 51 52
connection master;
reset master;
connection slave;
53
stop slave;
54 55
reset slave;

56
connection master;
57
let $1=5000;
58
# Generate 16K of relay log
59
disable_query_log;
60 61
while ($1)
{
62
 eval insert into t1 values($1);
63 64
 dec $1;
}
65 66
enable_query_log;

67
# Try to cause a large relay log lag on the slave by locking t1
68
connection slave;
69
lock tables t1 read;
70
start slave;
71
#hope this is long enough for I/O thread to fetch over 16K relay log data
72
sleep 3;
73 74
unlock tables;

75 76
#test handling of aborted connection in the middle of update

77
connection master;
78 79 80
create table t2(id int);
insert into t2 values(connection_id());
save_master_pos;
81 82

connection master1;
83 84 85
# Avoid generating result
create temporary table t3(n int);
insert into t3 select get_lock('crash_lock%20C', 1) from t2;
86 87

connection master;
88
send update t1 set n = n + get_lock('crash_lock%20C', 2);
89
connection master1;
90
sleep 3;
91 92
select (@id := id) - id from t2;
kill @id;
93
# We don't drop t3 as this is a temporary table
94 95
drop table t2;
connection master;
96
--error 1053,2013
97 98
reap;
connection slave;
99 100
# The SQL slave thread should now have stopped because the query was killed on
# the master (so it has a non-zero error code in the binlog).
101
wait_for_slave_to_stop;
102 103

# The following test can't be done because the result of Pos will differ
104
# on different computers
105
# --replace_result $MASTER_MYPORT MASTER_PORT
106 107
# show slave status;

108
set global sql_slave_skip_counter=1;
109
start slave;
110 111 112 113 114
select count(*) from t1;
connection master1;
drop table t1;
create table t1 (n int);
insert into t1 values(3456);
115
insert into mysql.user (Host, User, Password)
116
 VALUES ("10.10.10.%", "blafasel2", password("blafasel2"));
117 118 119
select select_priv,user from mysql.user where user = _binary'blafasel2';
update mysql.user set Select_priv = "Y" where User= _binary"blafasel2";
select select_priv,user from mysql.user where user = _binary'blafasel2';
120 121 122 123
save_master_pos;
connection slave;
sync_with_master;
select n from t1;
124
select select_priv,user from mysql.user where user = _binary'blafasel2';
125 126
connection master1;
drop table t1;
127
delete from mysql.user where user="blafasel2";
128 129 130
save_master_pos;
connection slave;
sync_with_master;
131 132

# End of 4.1 tests