~ubuntu-branches/ubuntu/precise/mysql-5.1/precise

« back to all changes in this revision

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

  • Committer: Bazaar Package Importer
  • Author(s): Norbert Tretkowski
  • Date: 2010-03-17 14:56:02 UTC
  • Revision ID: james.westby@ubuntu.com-20100317145602-x7e30l1b2sb5s6w6
Tags: upstream-5.1.45
ImportĀ upstreamĀ versionĀ 5.1.45

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
# ==== Purpose ====
 
2
#
 
3
# Verify that START SLAVE UNTIL replicates until the given binlog
 
4
# position but not longer.  Verify that START SLAVE UNTIL with various
 
5
# incorrect arguments gives an error.
 
6
#
 
7
# ==== Method ====
 
8
#
 
9
# On master, create a table and insert some rows.  On slave, START
 
10
# SLAVE UNTIL so that it reads one event at a time, and check the
 
11
# table and the slave status each time.
 
12
#
 
13
# Then, on slave, run START SLAVE UNTIL with incorrect arguments and
 
14
# verify that it gives an error.
 
15
#
 
16
# ==== Related bugs ====
 
17
#
 
18
# Bug in this test: BUG#37717: rpl.rpl_stm_until 'stmt' fails sporadically on pushbuild
 
19
 
 
20
-- source include/have_binlog_format_mixed_or_statement.inc
 
21
-- source include/master-slave.inc
 
22
 
 
23
# Test is dependent on binlog positions
 
24
 
 
25
# Stop slave before it starts replication.  Also sync with master
 
26
# to avoid nondeterministic behaviour.
 
27
--echo [on slave]
 
28
sync_slave_with_master;
 
29
--source include/stop_slave.inc
 
30
 
 
31
--echo ==== Create some events on master ====
 
32
 
 
33
--echo [on master]
 
34
connection master;
 
35
create table t1(n int not null auto_increment primary key);
 
36
insert into t1 values (1),(2),(3),(4);
 
37
drop table t1;
 
38
create table t2(n int not null auto_increment primary key);
 
39
insert into t2 values (1),(2);
 
40
insert into t2 values (3),(4);
 
41
drop table t2;
 
42
 
 
43
--echo ==== Replicate one event at a time on slave ====
 
44
 
 
45
# try to replicate all queries until drop of t1
 
46
--echo [on slave]
 
47
connection slave;
 
48
start slave until master_log_file='master-bin.000001', master_log_pos=323;
 
49
--source include/wait_for_slave_io_to_start.inc
 
50
--source include/wait_for_slave_sql_to_stop.inc
 
51
# here table should be still not deleted
 
52
select * from t1;
 
53
source include/show_slave_status2.inc;
 
54
 
 
55
# this should fail right after start
 
56
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
 
57
--source include/wait_for_slave_io_to_start.inc
 
58
--source include/wait_for_slave_sql_to_stop.inc
 
59
# again this table should be still not deleted
 
60
select * from t1;
 
61
source include/show_slave_status2.inc;
 
62
 
 
63
# try replicate all up to and not including the second insert to t2;
 
64
start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=746;
 
65
--source include/wait_for_slave_io_to_start.inc
 
66
--source include/wait_for_slave_sql_to_stop.inc
 
67
select * from t2;
 
68
source include/show_slave_status2.inc;
 
69
 
 
70
# clean up
 
71
start slave;
 
72
--echo [on master]
 
73
connection master;
 
74
--echo [on slave]
 
75
sync_slave_with_master;
 
76
--source include/stop_slave.inc
 
77
 
 
78
# this should stop immediately as we are already there
 
79
start slave until master_log_file='master-bin.000001', master_log_pos=776;
 
80
--source include/wait_for_slave_io_to_start.inc
 
81
--source include/wait_for_slave_sql_to_stop.inc
 
82
--replace_result bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
 
83
source include/show_slave_status2.inc;
 
84
 
 
85
--echo ==== Test various error conditions ====
 
86
 
 
87
--error 1277
 
88
start slave until master_log_file='master-bin', master_log_pos=561;
 
89
--error 1277
 
90
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
 
91
--error 1277
 
92
start slave until master_log_file='master-bin.000001';
 
93
--error 1277
 
94
start slave until relay_log_file='slave-relay-bin.000002';
 
95
--error 1277
 
96
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
 
97
# Warning should be given for second command
 
98
start slave sql_thread;
 
99
start slave until master_log_file='master-bin.000001', master_log_pos=776;
 
100
 
 
101
#
 
102
# bug#47210  first execution of "start slave until" stops too early  
 
103
#
 
104
# testing that a slave rotate event that is caused by stopping the slave
 
105
# does not intervene anymore in UNTIL condition.
 
106
#
 
107
 
 
108
connection slave;
 
109
source include/stop_slave.inc;
 
110
--disable_warnings
 
111
drop table if exists t1;
 
112
--enable_warnings
 
113
reset slave;
 
114
--replace_result $MASTER_MYPORT MASTER_PORT
 
115
eval change master to master_host='127.0.0.1',master_port=$MASTER_MYPORT, master_user='root'; 
 
116
 
 
117
connection master;
 
118
--disable_warnings
 
119
drop table if exists t1;
 
120
--enable_warnings
 
121
reset master;
 
122
create table t1 (a int primary key auto_increment);
 
123
save_master_pos;
 
124
let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
 
125
 
 
126
connection slave;
 
127
start slave;
 
128
sync_with_master;
 
129
 
 
130
# at this point slave will close the relay log stamping it with its own
 
131
# Rotate log event. This event won't be examined on matter of the master 
 
132
# UNTIL pos anymore.
 
133
source include/stop_slave.inc;
 
134
let $slave_exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
 
135
 
 
136
--echo master and slave are in sync now
 
137
let $diff_pos= `select $master_pos - $slave_exec_pos`;
 
138
eval select $diff_pos as zero;
 
139
 
 
140
connection master;
 
141
insert into t1 set a=null;
 
142
let $until_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
 
143
insert into t1 set a=null;
 
144
select count(*) as two from t1;
 
145
 
 
146
connection slave;
 
147
--replace_result $until_pos UNTIL_POS;
 
148
eval start slave until master_log_file='master-bin.000001', master_log_pos= $until_pos;
 
149
source include/wait_for_slave_sql_to_stop.inc;
 
150
let $slave_exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
 
151
--echo slave stopped at the prescribed position
 
152
let $diff_pos= `select $until_pos - $slave_exec_pos`;
 
153
eval select $diff_pos as zero;
 
154
select count(*) as one from t1;
 
155
 
 
156
 
 
157
connection master;
 
158
drop table t1;
 
159
 
 
160
connection slave;
 
161
start slave;
 
162
sync_with_master;
 
163
 
 
164
 # Bug #47142   "slave start until" stops 1 event too late in 4.1 to 5.0 replication
 
165
#
 
166
# testing fixes that refine the start position of prior-5.0 master's event
 
167
# and by that provide correct execution of 
 
168
# START SLAVE UNTIL ... master_log_pos= x;
 
169
# Keep the test at the end of the file because it manipulates with binlog files 
 
170
# to substitute the genuine one with a prepared on 4.1 server.
 
171
#
 
172
 
 
173
--source include/master-slave-reset.inc
 
174
 
 
175
connection master;
 
176
drop table if exists t1; # there is create table t1 in bug47142_master-bin.000001
 
177
flush logs;
 
178
let $MYSQLD_DATADIR= `select @@datadir`;
 
179
--remove_file $MYSQLD_DATADIR/master-bin.000001
 
180
--copy_file $MYSQL_TEST_DIR/std_data/bug47142_master-bin.000001 $MYSQLD_DATADIR/master-bin.000001
 
181
 
 
182
connection slave;
 
183
stop slave;
 
184
reset slave;
 
185
start slave until master_log_file='master-bin.000001', master_log_pos=294 /* to stop right before DROP */;
 
186
--source include/wait_for_slave_sql_to_stop.inc
 
187
 
 
188
show tables /* t1 must exist */;
 
189
 
 
190
# clean-up of Bug #47142 testing
 
191
 
 
192
drop table t1; # drop on slave only, master does not have t1. 
 
193
stop slave;
 
194
reset slave;
 
195
 
 
196
connection master;
 
197
reset master;
 
198
 
 
199
# End of tests