2002-08-24 02:08:10 +03:00
|
|
|
#
|
2003-01-06 01:48:59 +02:00
|
|
|
# Test is run with max_binlog_size=2048 to force automatic rotation of the
|
2002-08-24 02:08:10 +03: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 01:48:59 +02:00
|
|
|
|
2005-12-22 06:39:02 +01:00
|
|
|
# Requires statement logging
|
|
|
|
-- source include/have_binlog_format_statement.inc
|
|
|
|
|
2004-07-15 04:19:07 +03:00
|
|
|
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
2003-01-06 01:48:59 +02:00
|
|
|
--disable_warnings
|
2002-11-16 20:19:10 +02:00
|
|
|
drop table if exists t1, t2, t3, t4;
|
2003-01-06 01:48:59 +02:00
|
|
|
--enable_warnings
|
2003-01-28 08:38:28 +02:00
|
|
|
connect (slave,localhost,root,,test,$SLAVE_MYPORT,slave.sock);
|
2006-01-24 08:30:54 +01:00
|
|
|
system cat /dev/null > $MYSQLTEST_VARDIR/slave-data/master.info;
|
|
|
|
system chmod 000 $MYSQLTEST_VARDIR/slave-data/master.info;
|
2000-12-14 17:43:13 -07:00
|
|
|
connection slave;
|
2003-01-06 01:48:59 +02:00
|
|
|
--disable_warnings
|
2002-11-16 20:19:10 +02:00
|
|
|
drop table if exists t1, t2, t3, t4;
|
2003-01-06 01:48:59 +02:00
|
|
|
--enable_warnings
|
2003-08-11 22:44:43 +03:00
|
|
|
|
|
|
|
# START SLAVE will fail because it can't read the file (mode 000)
|
|
|
|
# (system error 13)
|
2004-11-12 14:34:00 +02:00
|
|
|
--replace_result $MYSQL_TEST_DIR TESTDIR
|
2005-02-24 23:33:42 +02:00
|
|
|
--error 1105,1105,29
|
2002-10-24 17:46:14 -06:00
|
|
|
start slave;
|
2006-01-24 08:30:54 +01:00
|
|
|
system chmod 600 $MYSQLTEST_VARDIR/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 05:44:16 +03:00
|
|
|
--error 1201
|
2002-10-24 17:46:14 -06:00
|
|
|
start slave;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2003-08-11 22:44:43 +03: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-14 17:43:13 -07:00
|
|
|
reset slave;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2002-09-11 06:40:08 +03:00
|
|
|
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
|
2001-01-22 12:35:16 -07:00
|
|
|
connection master;
|
|
|
|
reset master;
|
|
|
|
connection slave;
|
2002-10-24 17:46:14 -06:00
|
|
|
start slave;
|
2000-12-14 17:43:13 -07:00
|
|
|
connection master;
|
2002-08-24 02:08:10 +03: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 02:15:48 +02:00
|
|
|
create table t1 (s text);
|
|
|
|
insert into t1 values('Could not break slave'),('Tried hard');
|
2002-10-24 17:46:14 -06:00
|
|
|
sync_slave_with_master;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2005-12-22 06:39:02 +01:00
|
|
|
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
|
2001-01-22 12:35:16 -07:00
|
|
|
show slave status;
|
2001-01-03 02:15:48 +02:00
|
|
|
select * from t1;
|
2000-12-14 20:17:18 -07:00
|
|
|
connection master;
|
|
|
|
flush logs;
|
2001-11-27 18:20:24 -07:00
|
|
|
create table t2(m int not null auto_increment primary key);
|
2001-01-03 02:15:48 +02:00
|
|
|
insert into t2 values (34),(67),(123);
|
2000-12-14 20:17:18 -07:00
|
|
|
flush logs;
|
2002-10-24 18:32:42 -06:00
|
|
|
show binary logs;
|
2002-08-24 02:08:10 +03:00
|
|
|
create table t3 select * from temp_table;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2002-10-24 17:46:14 -06:00
|
|
|
sync_slave_with_master;
|
2002-08-24 02:08:10 +03: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 09:15:34 -07:00
|
|
|
insert into t2 values(1234);
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
#same value on the master
|
|
|
|
connection master;
|
2001-11-27 18:20:24 -07:00
|
|
|
set insert_id=1234;
|
|
|
|
insert into t2 values(NULL);
|
2001-01-24 09:15:34 -07:00
|
|
|
connection slave;
|
2002-01-24 22:49:47 -07:00
|
|
|
wait_for_slave_to_stop;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
#restart slave skipping one event
|
2002-07-23 18:31:22 +03:00
|
|
|
set global sql_slave_skip_counter=1;
|
2002-10-24 17:46:14 -06:00
|
|
|
start slave;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
connection master;
|
2001-01-24 12:47:09 -07:00
|
|
|
|
2001-01-23 08:20:51 -07:00
|
|
|
#let slave catch up
|
2002-10-24 17:46:14 -06:00
|
|
|
sync_slave_with_master;
|
2001-01-23 08:20:51 -07:00
|
|
|
connection master;
|
2003-03-11 13:49:06 +04: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 13:49:06 +04: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
|
2005-07-15 17:51:43 +02:00
|
|
|
--real_sleep 1
|
2003-07-12 23:31:21 +02:00
|
|
|
purge master logs before now();
|
2002-10-24 18:32:42 -06:00
|
|
|
show binary logs;
|
2001-01-03 02:15:48 +02:00
|
|
|
insert into t2 values (65);
|
2002-10-24 17:46:14 -06:00
|
|
|
sync_slave_with_master;
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2005-12-22 06:39:02 +01:00
|
|
|
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
|
2001-01-22 12:35:16 -07:00
|
|
|
show slave status;
|
2001-01-03 02:15:48 +02:00
|
|
|
select * from t2;
|
2002-08-24 02:08:10 +03:00
|
|
|
|
|
|
|
#
|
|
|
|
# Test forcing the replication log to rotate
|
|
|
|
#
|
|
|
|
|
2001-01-17 05:47:33 -07:00
|
|
|
connection master;
|
2002-08-24 02:08:10 +03:00
|
|
|
create temporary table temp_table (a char(80) not null);
|
|
|
|
insert into temp_table values ("testing temporary tables part 2");
|
2001-01-24 09:15:34 -07:00
|
|
|
let $1=100;
|
2003-01-06 01:48:59 +02:00
|
|
|
|
2001-01-24 09:15:34 -07:00
|
|
|
create table t3 (n int);
|
2001-09-27 23:05:54 -06:00
|
|
|
disable_query_log;
|
2001-01-24 09:15:34 -07:00
|
|
|
while ($1)
|
|
|
|
{
|
2001-03-27 10:23:04 -07:00
|
|
|
#eval means expand $ expressions
|
|
|
|
eval insert into t3 values($1 + 4);
|
2001-01-24 09:15:34 -07:00
|
|
|
dec $1;
|
|
|
|
}
|
2001-09-27 23:05:54 -06:00
|
|
|
enable_query_log;
|
2003-12-16 13:20:17 +02:00
|
|
|
select count(*) from t3 where n >= 4;
|
2002-08-24 02:08:10 +03:00
|
|
|
create table t4 select * from temp_table;
|
2002-10-24 18:32:42 -06:00
|
|
|
show binary logs;
|
2001-02-19 23:08:24 -07:00
|
|
|
show master status;
|
2001-01-24 09:15:34 -07:00
|
|
|
save_master_pos;
|
|
|
|
connection slave;
|
|
|
|
sync_with_master;
|
2002-08-24 02:08:10 +03:00
|
|
|
select * from t4;
|
|
|
|
|
2004-05-10 12:15:40 +02:00
|
|
|
--replace_result $MASTER_MYPORT MASTER_PORT
|
2005-12-22 06:39:02 +01:00
|
|
|
--replace_column 1 # 8 # 9 # 16 # 23 # 33 #
|
2001-02-19 23:08:24 -07:00
|
|
|
show slave status;
|
2001-03-26 21:03:08 -07: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 10:23:04 -07:00
|
|
|
select count(*) from t3 where n >= 4;
|
2001-03-26 21:03:08 -07:00
|
|
|
unlock tables;
|
2001-01-24 09:15:34 -07:00
|
|
|
#clean up
|
|
|
|
connection master;
|
2002-09-22 10:35:15 +03:00
|
|
|
drop table if exists t1,t2,t3,t4;
|
2002-10-24 17:46:14 -06:00
|
|
|
sync_slave_with_master;
|
2005-02-22 00:15:31 +01:00
|
|
|
|
2005-07-28 03:22:47 +03:00
|
|
|
# End of 4.1 tests
|