2006-04-24 10:21:09 +02:00
|
|
|
# This test uses chmod, can't be run with root permissions
|
|
|
|
-- source include/not_as_root.inc
|
|
|
|
|
2007-06-07 19:18:01 +02:00
|
|
|
-- source include/have_log_bin.inc
|
|
|
|
|
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
|
|
|
|
2005-12-22 06:39:02 +01:00
|
|
|
# Requires statement logging
|
2006-08-30 09:22:43 +02:00
|
|
|
-- source include/have_binlog_format_mixed_or_statement.inc
|
2005-12-22 06:39:02 +01:00
|
|
|
|
2004-07-15 03:19:07 +02:00
|
|
|
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
|
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
|
2006-12-19 15:10:15 +01:00
|
|
|
connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
|
2006-12-22 00:38:34 +01:00
|
|
|
# Create empty file
|
|
|
|
write_file $MYSQLTEST_VARDIR/slave-data/master.info;
|
|
|
|
EOF
|
|
|
|
chmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info;
|
2000-12-15 01:43:13 +01:00
|
|
|
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)
|
2004-11-12 13:34:00 +01:00
|
|
|
--replace_result $MYSQL_TEST_DIR TESTDIR
|
2005-02-24 22:33:42 +01:00
|
|
|
--error 1105,1105,29
|
2002-10-25 01:46:14 +02:00
|
|
|
start slave;
|
2006-12-22 00:38:34 +01:00
|
|
|
chmod 0600 $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 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;
|
2007-06-11 22:15:39 +02:00
|
|
|
source include/show_slave_status.inc;
|
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;
|
2007-06-13 05:52:43 +02:00
|
|
|
--source include/wait_for_slave_sql_to_stop.inc
|
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;
|
2007-05-21 11:33:58 +02:00
|
|
|
|
|
|
|
# Calculate time to use in "purge master logs before" by taking
|
|
|
|
# last modification time of t2 and adding 1 second
|
|
|
|
# This is donw in order to handle the case where file system
|
|
|
|
# time differs from mysqld's time
|
|
|
|
--disable_result_log
|
|
|
|
select @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND)
|
|
|
|
from information_schema.tables
|
|
|
|
where TABLE_SCHEMA="test" and TABLE_NAME="t2";
|
|
|
|
--enable_result_log
|
|
|
|
|
|
|
|
purge master logs before (@time_for_purge);
|
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;
|
2007-06-11 22:15:39 +02:00
|
|
|
source include/show_slave_status.inc;
|
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;
|
|
|
|
|
2007-06-11 22:15:39 +02:00
|
|
|
source include/show_slave_status.inc;
|
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;
|
2005-02-22 00:15:31 +01:00
|
|
|
|
2005-07-28 02:22:47 +02:00
|
|
|
# End of 4.1 tests
|