1
# This test uses chmod, can't be run with root permissions
2
-- source include/not_as_root.inc
4
-- source include/have_log_bin.inc
7
# Test is run with max_binlog_size=2048 to force automatic rotation of the
10
# - Check that slaves reports correct failures if master.info has strange
12
# - Automatic binary log rotation
13
# - Ensure that temporary tables works over flush logs and binary log
15
# - Test creating a duplicate key error and recover from it
17
# Requires statement logging
18
-- source include/have_binlog_format_mixed_or_statement.inc
20
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
22
drop table if exists t1, t2, t3, t4;
24
connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
26
write_file $MYSQLTEST_VARDIR/slave-data/master.info;
28
chmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info;
31
drop table if exists t1, t2, t3, t4;
34
# START SLAVE will fail because it can't read the file (mode 000)
36
--replace_result $MYSQL_TEST_DIR TESTDIR
39
chmod 0600 $MYSQLTEST_VARDIR/slave-data/master.info;
40
# It will fail again because the file is empty so the slave cannot get valuable
41
# info about how to connect to the master from it (failure in
42
# init_strvar_from_file() in init_master_info()).
45
--replace_result $MASTER_MYPORT MASTER_PORT
47
# CHANGE MASTER will fail because it first parses master.info before changing
48
# it (so when master.info is bad, people have to use RESET SLAVE first).
50
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
52
--replace_result $MASTER_MYPORT MASTER_PORT
53
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
63
create temporary table temp_table (a char(80) not null);
64
insert into temp_table values ("testing temporary tables");
65
create table t1 (s text);
66
insert into t1 values('Could not break slave'),('Tried hard');
67
sync_slave_with_master;
68
source include/show_slave_status2.inc;
72
create table t2(m int not null auto_increment primary key);
73
insert into t2 values (34),(67),(123);
75
source include/show_binary_logs.inc;
76
create table t3 select * from temp_table;
78
sync_slave_with_master;
82
drop table temp_table, t3;
85
# Now lets make some duplicate key mess and see if we can recover from it
88
# First insert a value on the slave
90
insert into t2 values(1234);
92
#same value on the master
95
insert into t2 values(NULL);
97
--source include/wait_for_slave_sql_to_stop.inc
99
#restart slave skipping one event
100
set global sql_slave_skip_counter=1;
106
sync_slave_with_master;
108
purge master logs to 'master-bin.000002';
109
source include/show_master_logs.inc;
110
# we just tests if synonyms are accepted
111
purge binary logs to 'master-bin.000002';
112
source include/show_binary_logs.inc;
114
# Calculate time to use in "purge master logs before" by taking
115
# last modification time of t2 and adding 1 second
116
# This is donw in order to handle the case where file system
117
# time differs from mysqld's time
119
select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND)
120
from information_schema.tables
121
where TABLE_SCHEMA="test" and TABLE_NAME="t2";
124
purge master logs before (@time_for_purge);
125
source include/show_binary_logs.inc;
126
insert into t2 values (65);
127
sync_slave_with_master;
128
source include/show_slave_status2.inc;
132
# Test forcing the replication log to rotate
136
create temporary table temp_table (a char(80) not null);
137
insert into temp_table values ("testing temporary tables part 2");
140
create table t3 (n int);
144
#eval means expand $ expressions
145
eval insert into t3 values($1 + 4);
149
select count(*) from t3 where n >= 4;
150
create table t4 select * from temp_table;
151
source include/show_binary_logs.inc;
152
source include/show_master_status.inc;
158
source include/show_slave_status2.inc;
159
# because of concurrent insert, the table may not be up to date
162
select count(*) from t3 where n >= 4;
166
drop table if exists t1,t2,t3,t4;
167
sync_slave_with_master;
169
--echo End of 4.1 tests
172
# Bug #29420: crash with show and purge binlogs
175
show binlog events in 'non existing_binlog_file';
176
purge master logs before now();
178
show binlog events in '';
179
purge master logs before now();
181
--echo End of 5.0 tests