2
2
-- source include/have_binlog_format_row.inc
3
3
-- source include/master-slave.inc
5
# Test is dependent on binlog positions
5
# Note: The test is dependent on binlog positions
7
7
# prepare version for substitutions
8
8
let $VERSION=`select version()`;
10
# stop slave before he will start replication also sync with master
11
# for avoiding undetermenistic behaviour
16
# Make sure the slave sql and io thread has stopped
17
--source include/wait_for_slave_to_stop.inc
20
# create some events on master
21
create table t1(n int not null auto_increment primary key);
22
insert into t1 values (1),(2),(3),(4);
24
create table t2(n int not null auto_increment primary key);
25
insert into t2 values (1),(2);
26
insert into t2 values (3),(4);
29
# try to replicate all queries until drop of t1
31
start slave until master_log_file='master-bin.000001', master_log_pos=311;
10
# Create some events on master
12
CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
13
INSERT INTO t1 VALUES (1),(2),(3),(4);
15
# Save master log postion for query DROP TABLE t1
17
let $master_pos_drop_t1= query_get_value(SHOW BINLOG EVENTS, Pos, 7);
19
CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
20
# Save master log postion for query CREATE TABLE t2
22
let $master_pos_create_t2= query_get_value(SHOW BINLOG EVENTS, Pos, 8);
24
INSERT INTO t2 VALUES (1),(2);
26
# Save master log postion for query INSERT INTO t2 VALUES (1),(2);
27
let $master_pos_insert1_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 12);
28
sync_slave_with_master;
30
# Save relay log postion for query INSERT INTO t2 VALUES (1),(2);
31
let $relay_pos_insert1_t2= query_get_value(show slave status, Relay_Log_Pos, 1);
34
INSERT INTO t2 VALUES (3),(4);
36
# Save master log postion for query INSERT INTO t2 VALUES (1),(2);
37
let $master_pos_drop_t2= query_get_value(SHOW BINLOG EVENTS, End_log_pos, 17);
38
sync_slave_with_master;
40
--source include/stop_slave.inc
44
eval CHANGE MASTER TO MASTER_USER='root', MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT;
47
# Try to replicate all queries until drop of t1
49
echo START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_drop_t1;
51
eval START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=$master_pos_drop_t1;
32
53
--source include/wait_for_slave_sql_to_stop.inc
33
# here table should be still not deleted
35
source include/show_slave_status.inc;
37
# this should fail right after start
38
start slave until master_log_file='master-no-such-bin.000001', master_log_pos=291;
55
# Here table should be still not deleted
57
--replace_result $master_pos_drop_t1 MASTER_POS_DROP_T1
58
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
59
query_vertical SHOW SLAVE STATUS;
61
# This should fail right after start
62
START SLAVE UNTIL MASTER_LOG_FILE='master-no-such-bin.000001', MASTER_LOG_POS=291;
39
63
--source include/wait_for_slave_sql_to_stop.inc
40
64
# again this table should be still not deleted
42
source include/show_slave_status.inc;
66
--replace_result $master_pos_drop_t1 MASTER_POS_DROP_T1
67
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
68
query_vertical SHOW SLAVE STATUS;
44
# try replicate all up to and not including the second insert to t2;
45
start slave until relay_log_file='slave-relay-bin.000004', relay_log_pos=1014;
70
# Try replicate all up to and not including the second insert to t2;
71
echo START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=relay_pos_insert1_t2;
73
eval START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', RELAY_LOG_POS=$relay_pos_insert1_t2;
46
75
--source include/wait_for_slave_sql_to_stop.inc
48
source include/show_slave_status.inc;
77
--replace_result $relay_pos_insert1_t2 RELAY_POS_INSERT1_T2 $master_pos_insert1_t2 MASTER_POS_INSERT1_T2
78
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
79
query_vertical SHOW SLAVE STATUS;
83
--source include/wait_for_slave_to_start.inc
57
# Make sure the slave sql and io thread has stopped
58
--source include/wait_for_slave_to_stop.inc
85
sync_slave_with_master;
86
--source include/stop_slave.inc
60
# this should stop immediately as we are already there
61
start slave until master_log_file='master-bin.000001', master_log_pos=740;
88
# This should stop immediately as we are already there
89
echo START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=master_pos_create_t2;
91
eval START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=$master_pos_create_t2;
93
let $slave_param= Until_Log_Pos;
94
let $slave_param_value= $master_pos_create_t2;
95
--source include/wait_for_slave_param.inc
62
96
--source include/wait_for_slave_sql_to_stop.inc
63
97
# here the sql slave thread should be stopped
64
98
--replace_result bin.000005 bin.000004 bin.000006 bin.000004 bin.000007 bin.000004
65
source include/show_slave_status.inc;
99
--replace_result $master_pos_create_t2 MASTER_POS_CREATE_T2 $master_pos_drop_t2 MASTER_POS_DROP_T2
100
--replace_column 1 # 4 # 7 # 8 # 9 # 16 # 23 # 33 # 35 # 36 #
101
query_vertical SHOW SLAVE STATUS;
67
103
#testing various error conditions
69
start slave until master_log_file='master-bin', master_log_pos=561;
71
start slave until master_log_file='master-bin.000001', master_log_pos=561, relay_log_pos=12;
73
start slave until master_log_file='master-bin.000001';
75
start slave until relay_log_file='slave-relay-bin.000002';
77
start slave until relay_log_file='slave-relay-bin.000002', master_log_pos=561;
105
START SLAVE UNTIL MASTER_LOG_FILE='master-bin', MASTER_LOG_POS=561;
107
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=561, RELAY_LOG_POS=12;
109
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001';
111
START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000009';
113
START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=561;
78
114
# Warning should be given for second command
79
start slave sql_thread;
80
start slave until master_log_file='master-bin.000001', master_log_pos=740;
116
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=740;