~ubuntu-branches/ubuntu/trusty/mariadb-5.5/trusty-proposed

« back to all changes in this revision

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

  • Committer: Package Import Robot
  • Author(s): Otto Kekäläinen
  • Date: 2013-12-22 10:27:05 UTC
  • Revision ID: package-import@ubuntu.com-20131222102705-mndw7s12mz0szrcn
Tags: upstream-5.5.32
Import upstream version 5.5.32

Show diffs side-by-side

added added

removed removed

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