~linuxjedi/drizzle/trunk-bug-667053

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_rotate_logs.test

  • Committer: brian
  • Date: 2008-06-25 05:29:13 UTC
  • Revision ID: brian@localhost.localdomain-20080625052913-6upwo0jsrl4lnapl
clean slate

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# This test uses chmod, can't be run with root permissions
 
2
-- source include/not_as_root.inc
 
3
 
 
4
-- source include/have_log_bin.inc
 
5
 
 
6
#
 
7
# Test is run with max_binlog_size=2048 to force automatic rotation of the
 
8
# binary log
 
9
# Tests done:
 
10
# - Check that slaves reports correct failures if master.info has strange
 
11
#   modes/information
 
12
# - Automatic binary log rotation
 
13
# - Ensure that temporary tables works over flush logs and binary log
 
14
#   changes
 
15
# - Test creating a duplicate key error and recover from it
 
16
 
 
17
# Requires statement logging
 
18
-- source include/have_binlog_format_mixed_or_statement.inc
 
19
 
 
20
connect (master,localhost,root,,test,$MASTER_MYPORT,$MASTER_MYSOCK);
 
21
--disable_warnings
 
22
drop table if exists t1, t2, t3, t4;
 
23
--enable_warnings
 
24
connect (slave,localhost,root,,test,$SLAVE_MYPORT,$SLAVE_MYSOCK);
 
25
# Create empty file
 
26
write_file $MYSQLTEST_VARDIR/slave-data/master.info;
 
27
EOF
 
28
chmod 0000 $MYSQLTEST_VARDIR/slave-data/master.info;
 
29
connection slave;
 
30
--disable_warnings
 
31
drop table if exists t1, t2, t3, t4;
 
32
--enable_warnings
 
33
 
 
34
# START SLAVE will fail because it can't read the file (mode 000)
 
35
# (system error 13)
 
36
--replace_result $MYSQL_TEST_DIR TESTDIR
 
37
--error 1105,1105,29
 
38
start slave;
 
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()).
 
43
--error 1201
 
44
start slave;
 
45
--replace_result $MASTER_MYPORT MASTER_PORT
 
46
 
 
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).
 
49
--error 1201
 
50
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root';
 
51
reset slave;
 
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'; 
 
54
connection master;
 
55
reset master;
 
56
connection slave;
 
57
start slave;
 
58
connection master;
 
59
 
 
60
#
 
61
# Test FLUSH LOGS
 
62
#
 
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;
 
69
select * from t1;
 
70
connection master;
 
71
flush logs;
 
72
create table t2(m int not null auto_increment primary key);
 
73
insert into t2 values (34),(67),(123);
 
74
flush logs;
 
75
source include/show_binary_logs.inc;
 
76
create table t3 select * from temp_table;
 
77
 
 
78
sync_slave_with_master;
 
79
 
 
80
select * from t3;
 
81
connection master;
 
82
drop table temp_table, t3;
 
83
 
 
84
#
 
85
# Now lets make some duplicate key mess and see if we can recover from it
 
86
#
 
87
 
 
88
# First insert a value on the slave
 
89
connection slave;
 
90
insert into t2 values(1234);
 
91
 
 
92
#same value on the master
 
93
connection master;
 
94
set insert_id=1234;
 
95
insert into t2 values(NULL);
 
96
connection slave;
 
97
--source include/wait_for_slave_sql_to_stop.inc
 
98
 
 
99
#restart slave skipping one event
 
100
set global sql_slave_skip_counter=1;
 
101
start slave;
 
102
 
 
103
connection master;
 
104
 
 
105
#let slave catch up
 
106
sync_slave_with_master;
 
107
connection 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;
 
113
 
 
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
 
118
--disable_result_log
 
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";
 
122
--enable_result_log
 
123
 
 
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;
 
129
select * from t2;
 
130
 
 
131
#
 
132
# Test forcing the replication log to rotate
 
133
 
134
 
 
135
connection master;
 
136
create temporary table temp_table (a char(80) not null);
 
137
insert into temp_table values ("testing temporary tables part 2");
 
138
let $1=100;
 
139
 
 
140
create table t3 (n int);
 
141
disable_query_log;
 
142
while ($1)
 
143
{
 
144
#eval means expand $ expressions
 
145
 eval insert into t3 values($1 + 4);
 
146
 dec $1;
 
147
}
 
148
enable_query_log;
 
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;
 
153
save_master_pos;
 
154
connection slave;
 
155
sync_with_master;
 
156
select * from t4;
 
157
 
 
158
source include/show_slave_status2.inc;
 
159
# because of concurrent insert, the table may not be up to date
 
160
# if we do not lock
 
161
lock tables t3 read;
 
162
select count(*) from t3 where n >= 4;
 
163
unlock tables;
 
164
#clean up
 
165
connection master;
 
166
drop table if exists t1,t2,t3,t4;
 
167
sync_slave_with_master;
 
168
 
 
169
--echo End of 4.1 tests
 
170
 
 
171
#
 
172
# Bug #29420: crash with show and purge binlogs
 
173
#
 
174
--error 1220
 
175
show binlog events in 'non existing_binlog_file';
 
176
purge master logs before now();
 
177
--error 1220
 
178
show binlog events in '';
 
179
purge master logs before now();
 
180
 
 
181
--echo End of 5.0 tests