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

« back to all changes in this revision

Viewing changes to mysql-test/suite/rpl/t/rpl_skip_error.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 --slave-skip-errors works correctly.  The error messages
 
4
# specified by --slave-skip-errors on slave should be ignored.  If
 
5
# such errors occur, they should not be reported and not cause the
 
6
# slave to stop.
 
7
#
 
8
# ==== Method ====
 
9
#
 
10
# We run the slave with --slave-skip-errors=1062 (the code for
 
11
# duplicate key).  Then we have two set of tests. In the first 
 
12
# set, we insert value 1 in a table on the slave, and then, on 
 
13
# master, we insert value 1 in the table. In the second set, we 
 
14
# insert several values on the master, disable the binlog and
 
15
# delete one of the values and re-enable the binlog. Right after,
 
16
# we perform an update on the set of values in order to generate
 
17
# a duplicate key on the slave. The errors should be ignored on
 
18
# the slave.
 
19
 
20
# ==== Related bugs ====
 
21
#
 
22
# BUG#28839: Errors in strict mode silently stop SQL thread if --slave-skip-errors exists
 
23
# bug in this test: BUG#30594: rpl.rpl_skip_error is nondeterministic:
 
24
# BUG#39393: slave-skip-errors does not work when using ROW based replication
 
25
 
 
26
source include/master-slave.inc;
 
27
source include/have_innodb.inc;
 
28
 
 
29
--echo ==== Test Without sql_mode=strict_trans_tables ====
 
30
 
 
31
--echo [on master]
 
32
create table t1 (n int not null primary key);
 
33
 
 
34
--echo [on slave]
 
35
sync_slave_with_master;
 
36
insert into t1 values (1);
 
37
 
 
38
--echo [on master]
 
39
connection master;
 
40
# Here we expect (ignored) error, since 1 is already in slave table 
 
41
insert into t1 values (1);
 
42
# These should work fine
 
43
insert into t1 values (2),(3);
 
44
 
 
45
sync_slave_with_master;
 
46
--echo [on slave]
 
47
select * from t1 order by n;
 
48
 
 
49
--echo ==== Test With sql_mode=strict_trans_tables ====
 
50
insert into t1 values (7),(8);
 
51
--echo [on master]
 
52
connection master;
 
53
set sql_mode=strict_trans_tables;
 
54
insert into t1 values (7), (8), (9);
 
55
--echo [on slave]
 
56
sync_slave_with_master;
 
57
select * from t1 order by n;
 
58
source include/show_slave_status2.inc;
 
59
 
 
60
--echo ==== Clean Up ====
 
61
connection master;
 
62
drop table t1;
 
63
sync_slave_with_master;
 
64
# End of 4.1 tests
 
65
 
 
66
#
 
67
# #28839 Errors in strict mode silently stop SQL thread if --slave-skip-errors exists
 
68
#
 
69
connection master;
 
70
create table t1(a int primary key);
 
71
insert into t1 values (1),(2);
 
72
SET SQL_LOG_BIN=0;
 
73
delete from t1;
 
74
SET SQL_LOG_BIN=1;
 
75
set sql_mode=strict_trans_tables;
 
76
insert into t1 values (1), (2), (3);
 
77
 
 
78
--echo [on slave]
 
79
sync_slave_with_master;
 
80
select * from t1;
 
81
source include/show_slave_status2.inc;
 
82
 
 
83
 
 
84
--echo ==== Clean Up ====
 
85
 
 
86
connection master;
 
87
drop table t1;
 
88
sync_slave_with_master;
 
89
# End of 5.0 tests
 
90
 
 
91
#
 
92
# BUG#39393: slave-skip-errors does not work when using ROW based replication
 
93
#
 
94
--echo ==== Using Innodb ====
 
95
 
 
96
connection master;
 
97
 
 
98
SET SQL_LOG_BIN=0;
 
99
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
 
100
SHOW CREATE TABLE t1;
 
101
SET SQL_LOG_BIN=1;
 
102
 
 
103
connection slave;
 
104
 
 
105
CREATE TABLE t1(id INT NOT NULL PRIMARY KEY, data INT) Engine=InnoDB;
 
106
SHOW CREATE TABLE t1;
 
107
 
 
108
connection master;
 
109
 
 
110
INSERT INTO t1 VALUES(1, 1);
 
111
INSERT INTO t1 VALUES(2, 1);
 
112
INSERT INTO t1 VALUES(3, 1);
 
113
INSERT INTO t1 VALUES(4, 1);
 
114
 
 
115
SET SQL_LOG_BIN=0;
 
116
DELETE FROM t1 WHERE id = 4;
 
117
SET SQL_LOG_BIN=1;
 
118
UPDATE t1 SET id= id + 3, data = 2;
 
119
 
 
120
sync_slave_with_master;
 
121
 
 
122
let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
123
echo $error;
 
124
 
 
125
--echo **** We cannot execute a select as there are differences in the 
 
126
--echo **** behavior between STMT and RBR.
 
127
 
 
128
--echo ==== Using MyIsam ====
 
129
 
 
130
connection master;
 
131
 
 
132
SET SQL_LOG_BIN=0;
 
133
CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
 
134
SHOW CREATE TABLE t2;
 
135
SET SQL_LOG_BIN=1;
 
136
 
 
137
connection slave;
 
138
 
 
139
CREATE TABLE t2(id INT NOT NULL PRIMARY KEY, data INT) Engine=MyIsam;
 
140
SHOW CREATE TABLE t2;
 
141
 
 
142
connection master;
 
143
 
 
144
INSERT INTO t2 VALUES(1, 1);
 
145
INSERT INTO t2 VALUES(2, 1);
 
146
INSERT INTO t2 VALUES(3, 1);
 
147
INSERT INTO t2 VALUES(5, 1);
 
148
 
 
149
SET SQL_LOG_BIN=0;
 
150
DELETE FROM t2 WHERE id = 5;
 
151
SET SQL_LOG_BIN=1;
 
152
UPDATE t2 SET id= id + 3, data = 2;
 
153
 
 
154
sync_slave_with_master;
 
155
 
 
156
let $error= query_get_value("SHOW SLAVE STATUS", Last_SQL_Error, 1);
 
157
echo $error;
 
158
 
 
159
--echo **** We cannot execute a select as there are differences in the 
 
160
--echo **** behavior between STMT and RBR.
 
161
 
 
162
--echo ==== Clean Up ====
 
163
 
 
164
connection master;
 
165
 
 
166
DROP TABLE t1;
 
167
DROP TABLE t2;
 
168
 
 
169
sync_slave_with_master;