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.
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.
13
# Then, on slave, run START SLAVE UNTIL with incorrect arguments and
14
# verify that it gives an error.
16
# ==== Related bugs ====
18
# Bug in this test: BUG#37717: rpl.rpl_stm_until 'stmt' fails sporadically on pushbuild
20
-- source include/have_binlog_format_mixed_or_statement.inc
21
-- source include/master-slave.inc
23
# Test is dependent on binlog positions
25
# Stop slave before it starts replication. Also sync with master
26
# to avoid nondeterministic behaviour.
28
sync_slave_with_master;
29
--source include/stop_slave.inc
31
--echo ==== Create some events on master ====
35
create table t1(n int not null auto_increment primary key);
36
insert into t1 values (1),(2),(3),(4);
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);
43
--echo ==== Replicate one event at a time on slave ====
45
# try to replicate all queries until drop of t1
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
53
source include/show_slave_status2.inc;
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
61
source include/show_slave_status2.inc;
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
68
source include/show_slave_status2.inc;
75
sync_slave_with_master;
76
--source include/stop_slave.inc
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;
85
--echo ==== Test various error conditions ====
88
start slave until master_log_file='master-bin', master_log_pos=561;
90
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
92
start slave until master_log_file='master-bin.000001';
94
start slave until relay_log_file='slave-relay-bin.000002';
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;
102
# bug#47210 first execution of "start slave until" stops too early
104
# testing that a slave rotate event that is caused by stopping the slave
105
# does not intervene anymore in UNTIL condition.
109
source include/stop_slave.inc;
111
drop table if exists t1;
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';
119
drop table if exists t1;
122
create table t1 (a int primary key auto_increment);
124
let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1);
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
133
source include/stop_slave.inc;
134
let $slave_exec_pos= query_get_value(SHOW SLAVE STATUS, Exec_Master_Log_Pos, 1);
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;
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;
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;
164
# Bug #47142 "slave start until" stops 1 event too late in 4.1 to 5.0 replication
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.
173
--source include/master-slave-reset.inc
176
drop table if exists t1; # there is create table t1 in bug47142_master-bin.000001
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
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
188
show tables /* t1 must exist */;
190
# clean-up of Bug #47142 testing
192
drop table t1; # drop on slave only, master does not have t1.