Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_ui.test

raw
1 --source include/have_ndb.inc
2 --source include/have_binlog_format_mixed_or_row.inc
3 --source suite/ndb_rpl/ndb_master-slave.inc
4
5 #
6 # Slave behaviour when replicating unique index operations
7 #
8 #
9
10 --connection master
11
12 CREATE TABLE t1 (pk int primary key, uk int not null, unique(uk)) engine=ndb;
13
14 # Now perform some operations which do not result in uniqueness
15 # violations when applied in-order, but which can result in them
16 # when applied out-of-order
17 # 5 distinct values chosen to increase the chance of different
18 # fragments (and therefore potentially different SUMA->Binlog
19 # orders) being seen.
20 #
21 insert into t1 values (1,1);
22 insert into t1 values (2,2);
23 insert into t1 values (3,3);
24 insert into t1 values (4,4);
25 insert into t1 values (5,5);
26
27 --sorted_result
28 select * from t1 where uk in (1,2,3,4,5);
29
30 # Do a 'right shift' on the unique key values
31 update t1 set uk=uk-1 order by pk;
32
33 --sorted_result
34 select * from t1 where uk in (0,1,2,3,4);
35
36 --echo Master table contents
37 select * from t1 order by pk;
38
39 flush logs;
40
41 --sync_slave_with_master
42
43 --connection slave
44
45 --echo Slave table contents
46 select * from t1 order by pk;
47 select * from t1 where uk in (0,1,2,3,4);
48
49 --connection master
50 drop table t1;
51
52 # bug12974714
53 CREATE TABLE t1 (a int not null,
54 b int auto_increment,
55 uk int null, primary key(a,b), unique(uk))
56 engine=ndb partition by key(a);
57 CREATE TABLE t2 (a int not null auto_increment primary key) engine = ndb;
58
59 begin;
60 insert into t1 values (1,null,1), (1,null, 2), (1,null, 3), (1,null, 4);
61 insert into t2 values (null), (null), (null), (null);
62 insert into t2 select null from t2;
63 insert into t2 select null from t2;
64 insert into t2 select null from t2;
65 insert into t2 select null from t2;
66 insert into t2 select null from t2;
67 insert into t2 select null from t2;
68 insert into t2 select null from t2;
69 insert into t2 select null from t2;
70 commit;
71 select count(*) from t1;
72 select count(*) from t2;
73 --sync_slave_with_master
74
75 --connection slave
76 select count(*) from t1;
77 select count(*) from t2;
78
79 --connection master
80 drop table t1;
81 drop table t2;
82 --sync_slave_with_master
83
84 --echo Test that real uniqeuness constraint violations are detected
85 --echo when replicating
86 --connection master
87 create table t1 (a int primary key, b int, c int, unique(c)) engine=ndb;
88
89 insert into t1 values (1,1,1), (2,2,2), (3,3,3), (4,4,4), (5,5,5), (6,6,6);
90 --sync_slave_with_master
91
92 --echo Modify replica so that there can be conflicts in replication
93 --connection slave
94 insert into t1 values (11,11,11), (12,12,12), (13,13,13), (14,14,14);
95
96 call mtr.add_suppression(".*duplicate key in table.*");
97 call mtr.add_suppression(".*Duplicate key on write or update.*");
98 call mtr.add_suppression(".*duplicate value in unique index.*");
99 call mtr.add_suppression(".*coordinator and worker threads are stopped.*");
100
101 --echo Single insert
102 --connection master
103 insert into t1 values (7,7,11);
104
105 --connection slave
106 --let $slave_sql_errno= 1022
107 --source include/wait_for_slave_sql_error.inc
108
109 delete from t1 where c=11;
110 start replica;
111
112 --connection master
113 --sync_slave_with_master
114
115 --echo Single update
116 --connection master
117 update t1 set c=12 where a=2;
118
119 --connection slave
120 --let $slave_sql_errno= 1022
121 --source include/wait_for_slave_sql_error.inc
122
123 delete from t1 where c=12;
124
125 start replica;
126
127 --connection master
128 --sync_slave_with_master
129
130 --connection master
131
132 --echo Check blob handling
133
134 create table t2 (a int primary key, b text, c int, unique(c)) engine=ndb;
135 insert into t2 values (1, repeat('VRA', 10000),1);
136 insert into t2 values (2, repeat('VRA', 10000),2);
137 insert into t2 values (3, repeat('VRA', 10000),3);
138 insert into t2 values (4, repeat('VRA', 10000),4);
139 insert into t2 values (5, repeat('VRA', 10000),5);
140 insert into t2 values (6, repeat('VRA', 10000),6);
141 insert into t2 values (7, repeat('VRA', 10000),7);
142 insert into t2 values (8, repeat('VRA', 10000),8);
143 insert into t2 values (9, repeat('VRA', 10000),9);
144
145 --sync_slave_with_master
146 --connection slave
147
148 insert into t2 values (11, repeat('VRA', 10000), 11);
149
150 --connection master
151 update t2 set b=repeat('GEO', 20000), c=c+10 order by c desc;
152
153 --connection slave
154 --let $slave_sql_errno= 1022
155 --source include/wait_for_slave_sql_error.inc
156
157 delete from t2 where c=11;
158
159 start replica;
160
161 --connection master
162 --sync_slave_with_master
163
164 --connection master
165 drop table t1;
166 drop table t2;
167 --sync_slave_with_master
168
169
170 --source include/rpl_end.inc