2002-08-24 01:08:10 +02:00
|
|
|
#
|
2003-01-06 00:48:59 +01:00
|
|
|
# Test is run with max_binlog_size=2048 to force automatic rotation of the
|
2002-08-24 01:08:10 +02:00
|
|
|
# binary log
|
|
|
|
# Tests done:
|
|
|
|
# - Check that slaves reports correct failures if master.info has strange
|
|
|
|
# modes/information
|
|
|
|
# - Automatic binary log rotation
|
|
|
|
# - Ensure that temporary tables works over flush logs and binary log
|
|
|
|
# changes
|
|
|
|
# - Test creating a duplicate key error and recover from it
|
2003-01-06 00:48:59 +01:00
|
|
|
|
2003-01-28 07:38:28 +01:00
|
|
|
connect (master,localhost,root,,test,$MASTER_MYPORT,master.sock);
|
2003-01-06 00:48:59 +01:00
|
|
|
--disable_warnings
|
2002-11-16 19:19:10 +01:00
|
|
|
drop table if exists t1, t2, t3, t4;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
2003-01-28 07:38:28 +01:00
|
|
|
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
|
2000-12-15 01:43:13 +01:00
|
|
|
system cat /dev/null > var/slave-data/master.info;
|
|
|
|
system chmod 000 var/slave-data/master.info;
|
|
|
|
connection slave;
|
2003-01-06 00:48:59 +01:00
|
|
|
--disable_warnings
|
2002-11-16 19:19:10 +01:00
|
|
|
drop table if exists t1, t2, t3, t4;
|
2003-01-06 00:48:59 +01:00
|
|
|
--enable_warnings
|
2003-08-11 21:44:43 +02:00
|
|
|
|
|
|
|
# START SLAVE will fail because it can't read the file (mode 000)
|
|
|
|
# (system error 13)
|
2002-08-24 04:44:16 +02:00
|
|
|
--error 1201
|
2002-10-25 01:46:14 +02:00
|
|
|
start slave;
|
2000-12-15 01:43:13 +01:00
|
|
|
system chmod 600 var/slave-data/master.info;
|
2003-06-17 23:19:38 +02:00
|
|
|
# It will fail again because the file is empty so the slave cannot get valuable
|
|
|
|
# info about how to connect to the master from it (failure in
|
|
|
|
# init_strvar_from_file() in init_master_info()).
|
2002-08-24 04:44:16 +02:00
|
|
|
--error 1201
|
2002-10-25 01:46:14 +02:00
|
|
|
start slave;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2003-08-11 21:44:43 +02:00
|
|
|
|
|
|
|
# CHANGE MASTER will fail because it first parses master.info before changing
|
|
|
|
# it (so when master.info is bad, people have to use RESET SLAVE first).
|
2003-06-17 23:19:38 +02:00
|
|
|
--error 1201
|
|
|
|
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
|
2000-12-15 01:43:13 +01:00
|
|
|
reset slave;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2002-09-11 05:40:08 +02:00
|
|
|
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
|
2001-01-22 20:35:16 +01:00
|
|
|
connection master;
|
|
|
|
reset master;
|
|
|
|
connection slave;
|
2002-10-25 01:46:14 +02:00
|
|
|
start slave;
|
2000-12-15 01:43:13 +01:00
|
|
|
connection master;
|
2002-08-24 01:08:10 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test FLUSH LOGS
|
|
|
|
#
|
|
|
|
create temporary table temp_table (a char(80) not null);
|
|
|
|
insert into temp_table values ("testing temporary tables");
|
2001-01-03 01:15:48 +01:00
|
|
|
create table t1 (s text);
|
|
|
|
insert into t1 values('Could not break slave'),('Tried hard');
|
2002-10-25 01:46:14 +02:00
|
|
|
sync_slave_with_master;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2003-12-19 22:40:23 +01:00
|
|
|
--replace_column 1 # 8 # 9 # 23 # 33 #
|
2001-01-22 20:35:16 +01:00
|
|
|
show slave status;
|
2001-01-03 01:15:48 +01:00
|
|
|
select * from t1;
|
2000-12-15 04:17:18 +01:00
|
|
|
connection master;
|
|
|
|
flush logs;
|
2001-11-28 02:20:24 +01:00
|
|
|
create table t2(m int not null auto_increment primary key);
|
2001-01-03 01:15:48 +01:00
|
|
|
insert into t2 values (34),(67),(123);
|
2000-12-15 04:17:18 +01:00
|
|
|
flush logs;
|
2002-10-25 02:32:42 +02:00
|
|
|
show binary logs;
|
2002-08-24 01:08:10 +02:00
|
|
|
create table t3 select * from temp_table;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2002-10-25 01:46:14 +02:00
|
|
|
sync_slave_with_master;
|
2002-08-24 01:08:10 +02:00
|
|
|
|
|
|
|
select * from t3;
|
|
|
|
connection master;
|
|
|
|
drop table temp_table, t3;
|
|
|
|
|
|
|
|
#
|
|
|
|
# Now lets make some duplicate key mess and see if we can recover from it
|
|
|
|
#
|
|
|
|
|
|
|
|
# First insert a value on the slave
|
|
|
|
connection slave;
|
2001-01-24 17:15:34 +01:00
|
|
|
insert into t2 values(1234);
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
#same value on the master
|
|
|
|
connection master;
|
2001-11-28 02:20:24 +01:00
|
|
|
set insert_id=1234;
|
|
|
|
insert into t2 values(NULL);
|
2001-01-24 17:15:34 +01:00
|
|
|
connection slave;
|
2002-01-25 06:49:47 +01:00
|
|
|
wait_for_slave_to_stop;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
#restart slave skipping one event
|
2002-07-23 17:31:22 +02:00
|
|
|
set global sql_slave_skip_counter=1;
|
2002-10-25 01:46:14 +02:00
|
|
|
start slave;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
connection master;
|
2001-01-24 20:47:09 +01:00
|
|
|
|
2001-01-23 16:20:51 +01:00
|
|
|
#let slave catch up
|
2002-10-25 01:46:14 +02:00
|
|
|
sync_slave_with_master;
|
2001-01-23 16:20:51 +01:00
|
|
|
connection master;
|
2003-03-11 10:49:06 +01:00
|
|
|
purge master logs to 'master-bin.000002';
|
2003-07-12 23:31:21 +02:00
|
|
|
show master logs;
|
|
|
|
# we just tests if synonyms are accepted
|
|
|
|
purge binary logs to 'master-bin.000002';
|
2003-03-11 10:49:06 +01:00
|
|
|
show binary logs;
|
2003-11-19 23:39:08 +01:00
|
|
|
# sleeping 10 seconds or more would make the slave believe connection is down
|
|
|
|
--real_sleep 1;
|
2003-07-12 23:31:21 +02:00
|
|
|
purge master logs before now();
|
2002-10-25 02:32:42 +02:00
|
|
|
show binary logs;
|
2001-01-03 01:15:48 +01:00
|
|
|
insert into t2 values (65);
|
2002-10-25 01:46:14 +02:00
|
|
|
sync_slave_with_master;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2003-12-19 22:40:23 +01:00
|
|
|
--replace_column 1 # 8 # 9 # 23 # 33 #
|
2001-01-22 20:35:16 +01:00
|
|
|
show slave status;
|
2001-01-03 01:15:48 +01:00
|
|
|
select * from t2;
|
2002-08-24 01:08:10 +02:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test forcing the replication log to rotate
|
|
|
|
#
|
|
|
|
|
2001-01-17 13:47:33 +01:00
|
|
|
connection master;
|
2002-08-24 01:08:10 +02:00
|
|
|
create temporary table temp_table (a char(80) not null);
|
|
|
|
insert into temp_table values ("testing temporary tables part 2");
|
2001-01-24 17:15:34 +01:00
|
|
|
let $1=100;
|
2003-01-06 00:48:59 +01:00
|
|
|
|
2001-01-24 17:15:34 +01:00
|
|
|
create table t3 (n int);
|
2001-09-28 07:05:54 +02:00
|
|
|
disable_query_log;
|
2001-01-24 17:15:34 +01:00
|
|
|
while ($1)
|
|
|
|
{
|
2001-03-27 19:23:04 +02:00
|
|
|
#eval means expand $ expressions
|
|
|
|
eval insert into t3 values($1 + 4);
|
2001-01-24 17:15:34 +01:00
|
|
|
dec $1;
|
|
|
|
}
|
2001-09-28 07:05:54 +02:00
|
|
|
enable_query_log;
|
2003-12-16 12:20:17 +01:00
|
|
|
select count(*) from t3 where n >= 4;
|
2002-08-24 01:08:10 +02:00
|
|
|
create table t4 select * from temp_table;
|
2002-10-25 02:32:42 +02:00
|
|
|
show binary logs;
|
2001-02-20 07:08:24 +01:00
|
|
|
show master status;
|
2001-01-24 17:15:34 +01:00
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
2002-08-24 01:08:10 +02:00
|
|
|
select * from t4;
|
|
|
|
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2003-12-19 22:40:23 +01:00
|
|
|
--replace_column 1 # 8 # 9 # 23 # 33 #
|
2001-02-20 07:08:24 +01:00
|
|
|
show slave status;
|
2001-03-27 06:03:08 +02:00
|
|
|
# because of concurrent insert, the table may not be up to date
|
|
|
|
# if we do not lock
|
|
|
|
lock tables t3 read;
|
2001-03-27 19:23:04 +02:00
|
|
|
select count(*) from t3 where n >= 4;
|
2001-03-27 06:03:08 +02:00
|
|
|
unlock tables;
|
2001-01-24 17:15:34 +01:00
|
|
|
#clean up
|
|
|
|
connection master;
|
2002-09-22 09:35:15 +02:00
|
|
|
drop table if exists t1,t2,t3,t4;
|
2002-10-25 01:46:14 +02:00
|
|
|
sync_slave_with_master;
|