📄 rpl_rotate_logs.test
字号:
# This test uses chmod, can't be run with root permissions-- source include/not_as_root.inc-- source include/have_log_bin.inc## Test is run with max_binlog_size=2048 to force automatic rotation of the# 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 itconnect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);--disable_warningsdrop table if exists t1, t2, t3, t4;--enable_warningsconnect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);# Create empty filewrite_file $MYSQLTEST_VARDIR/slave-data/master.info;EOFchmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info;connection slave;--disable_warningsdrop table if exists t1, t2, t3, t4;--enable_warnings# START SLAVE will fail because it can't read the file (mode 000)# (system error 13)--replace_result $MYSQL_TEST_DIR TESTDIR--error 1105,1105,29start slave;chmod 0600 $MYSQLTEST_VARDIR/slave-data/master.info;# 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()).--error 1201start slave;--replace_result $MASTER_MYPORT MASTER_PORT# 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).--error 1201eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';reset slave;--replace_result $MASTER_MYPORT MASTER_PORTeval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root'; connection master;reset master;connection slave;start slave;connection master;## Test FLUSH LOGS#create temporary table temp_table (a char(80) not null);insert into temp_table values ("testing temporary tables");create table t1 (s text);insert into t1 values('Could not break slave'),('Tried hard');sync_slave_with_master;--replace_result $MASTER_MYPORT MASTER_PORT--replace_column 1 # 8 # 9 # 23 # 33 #show slave status;select * from t1;connection master;flush logs;create table t2(m int not null auto_increment primary key);insert into t2 values (34),(67),(123);flush logs;show binary logs;create table t3 select * from temp_table;sync_slave_with_master;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 slaveconnection slave;insert into t2 values(1234);#same value on the masterconnection master;set insert_id=1234;insert into t2 values(NULL);connection slave;wait_for_slave_to_stop;#restart slave skipping one eventset global sql_slave_skip_counter=1;start slave;connection master;#let slave catch upsync_slave_with_master;connection master;purge master logs to 'master-bin.000002';show master logs;# we just tests if synonyms are acceptedpurge binary logs to 'master-bin.000002';show binary logs;# 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_logselect @time_for_purge:=DATE_ADD(UPDATE_TIME, INTERVAL 1 SECOND) from information_schema.tables where TABLE_SCHEMA="test" and TABLE_NAME="t2";--enable_result_logpurge master logs before (@time_for_purge);show binary logs;insert into t2 values (65);sync_slave_with_master;--replace_result $MASTER_MYPORT MASTER_PORT--replace_column 1 # 8 # 9 # 23 # 33 #show slave status;select * from t2;## Test forcing the replication log to rotate# connection master;create temporary table temp_table (a char(80) not null);insert into temp_table values ("testing temporary tables part 2");let $1=100;create table t3 (n int);disable_query_log;while ($1){#eval means expand $ expressions eval insert into t3 values($1 + 4); dec $1;}enable_query_log;select count(*) from t3 where n >= 4;create table t4 select * from temp_table;show binary logs;show master status;save_master_pos;connection slave;sync_with_master;select * from t4;--replace_result $MASTER_MYPORT MASTER_PORT--replace_column 1 # 8 # 9 # 23 # 33 #show slave status;# because of concurrent insert, the table may not be up to date# if we do not locklock tables t3 read;select count(*) from t3 where n >= 4;unlock tables;#clean upconnection master;drop table if exists t1,t2,t3,t4;sync_slave_with_master;--echo End of 4.1 tests## Bug #29420: crash with show and purge binlogs#--error 1220show binlog events in 'non existing_binlog_file';purge master logs before now();--error 1220show binlog events in '';purge master logs before now();--echo End of 5.0 tests
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -