1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
|
-- source include/have_binlog_format_row.inc
-- source include/master-slave.inc
##############################################################################
# The test is dependent on binlog positions. The test is divided into two
# sections. The first section checks START SLAVE UNTIL MASTER_LOG_FILE =
# 'log_name', MASTER_LOG_POS = log_pos followed by a couple of failure
# scenarios. The second section checks START SLAVE UNTIL RELAY_LOG_FILE =
# 'log_name', RELAY_LOG_POS = log_pos.
##############################################################################
# Create some events on master
connection master;
CREATE TABLE t1(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
INSERT INTO t1 VALUES (1),(2),(3),(4);
# Save master log position for query DROP TABLE t1
let $master_pos_drop_t1= query_get_value(SHOW MASTER STATUS, Position, 1);
DROP TABLE t1;
# Save master log position for query DROP TABLE t1
save_master_pos;
#let $master_pos_drop_t1= query_get_value(SHOW BINLOG EVENTS, Pos, 10);
let $master_log_file= query_get_value(SHOW BINLOG EVENTS, Log_name, 10);
# Save master log position for query CREATE TABLE t2
let $master_pos_create_t2= query_get_value(SHOW MASTER STATUS, Position, 1);
CREATE TABLE t2(n INT NOT NULL AUTO_INCREMENT PRIMARY KEY);
#show binlog events;
INSERT INTO t2 VALUES (1),(2);
# Save master log position for query INSERT INTO t2 VALUES (1),(2);
let $master_pos_insert1_t2= query_get_value(SHOW MASTER STATUS, Position, 1);
INSERT INTO t2 VALUES (3),(4);
DROP TABLE t2;
# Save master log position for query DROP TABLE t2;
let $master_pos_drop_t2= query_get_value(SHOW MASTER STATUS, Position, 1);
sync_slave_with_master;
#show binlog events;
--source include/stop_slave.inc
# Reset slave.
--source include/reset_slave.inc
--replace_result $MASTER_MYPORT MASTER_MYPORT
eval CHANGE MASTER TO MASTER_USER='root', MASTER_CONNECT_RETRY=1, MASTER_HOST='127.0.0.1', MASTER_PORT=$MASTER_MYPORT;
# Try to replicate all queries until drop of t1
connection slave;
--replace_result $master_pos_drop_t1 master_pos_drop_t1
eval START SLAVE UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=$master_pos_drop_t1;
--source include/wait_for_slave_sql_to_stop.inc
# Here table should be still not deleted
SELECT * FROM t1;
--let $slave_param= Exec_Master_Log_Pos
--let $slave_param_value= $master_pos_drop_t1
--source include/check_slave_param.inc
# This should fail right after start
START SLAVE UNTIL MASTER_LOG_FILE='master-no-such-bin.000001', MASTER_LOG_POS=291;
--source include/wait_for_slave_sql_to_stop.inc
# again this table should be still not deleted
SELECT * FROM t1;
--let $slave_param= Exec_Master_Log_Pos
--let $slave_param_value= $master_pos_drop_t1
--source include/check_slave_param.inc
# clean up
START SLAVE;
--source include/wait_for_slave_to_start.inc
connection master;
sync_slave_with_master;
--source include/stop_slave.inc
# This should stop immediately as we are already there
--replace_result $master_pos_create_t2 master_pos_create_t2
eval START SLAVE SQL_THREAD UNTIL MASTER_LOG_FILE='$master_log_file', MASTER_LOG_POS=$master_pos_create_t2;
let $slave_param= Until_Log_Pos;
let $slave_param_value= $master_pos_create_t2;
--source include/wait_for_slave_param.inc
--source include/wait_for_slave_sql_to_stop.inc
# here the sql slave thread should be stopped
--let $slave_param= Exec_Master_Log_Pos
--let $slave_param_value= $master_pos_drop_t2
--source include/check_slave_param.inc
#testing various error conditions
--replace_result 561 MASTER_LOG_POS
--error 1277
START SLAVE UNTIL MASTER_LOG_FILE='master-bin', MASTER_LOG_POS=561;
--replace_result 561 MASTER_LOG_POS 12 RELAY_LOG_POS
--error 1277
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=561, RELAY_LOG_POS=12;
--error 1277
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001';
--error 1277
START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000009';
--replace_result 561 MASTER_LOG_POS
--error 1277
START SLAVE UNTIL RELAY_LOG_FILE='slave-relay-bin.000002', MASTER_LOG_POS=561;
--replace_result 740 MASTER_LOG_POS
START SLAVE UNTIL MASTER_LOG_FILE='master-bin.000001', MASTER_LOG_POS=740;
--source include/stop_slave.inc
--source include/reset_slave.inc
--source include/start_slave.inc
##############################################################################
# The second section - checks START SLAVE UNTIL RELAY_LOG_FILE =# 'log_name',
# RELAY_LOG_POS = log_pos. This section of the test does the following:
# 1) At master, create a table and inserts a value. Let slave replicate this.
# 2) Stop slave sql thread.
# 3) Insert some more values at master. Note that io thread copies this insert
# 4) Use start slave until to start the sql thread and check if it
# stops at the correct position.
##############################################################################
--source include/rpl_reset.inc
--connection master
CREATE TABLE t1 (a INT);
INSERT INTO t1 VALUES (1);
--sync_slave_with_master
--source include/stop_slave_sql.inc
--connection master
INSERT INTO t1 VALUES (2);
--let $master_log_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
INSERT INTO t1 VALUES (3);
--source include/sync_slave_io_with_master.inc
--let $relay_log_file= query_get_value(SHOW SLAVE STATUS, Relay_Log_File,1)
--source include/get_relay_log_pos.inc
--replace_result $relay_log_pos relay_log_pos
--eval start slave until relay_log_file='$relay_log_file', relay_log_pos=$relay_log_pos
--source include/wait_for_slave_sql_to_stop.inc
--let $assert_cond= COUNT(*) = 2 FROM t1
--let $assert_text= table t1 should have two rows.
--source include/assert.inc
#cleanup
--source include/start_slave.inc
--connection master
DROP TABLE t1;
--sync_slave_with_master
--source include/rpl_end.inc
|