Debian Codegraph @

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

raw
1 #
2 # Test engine native conflict resolution for ndb
3 # NDB$EPOCH_TRANS() function
4 #
5 #
6 --source include/have_ndb.inc
7 --source include/have_binlog_format_mixed_or_row.inc
8 --source suite/ndb_rpl/ndb_master-slave.inc
9 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
10
11 --echo Setup circular replication
12
13 --connection slave
14 RESET MASTER;
15 let $SLAVE_SERVER_ID= `select @@server_id`;
16 echo SLAVE_SERVER_ID: $SLAVE_SERVER_ID;
17
18 --connection master
19 --replace_result $SLAVE_MYPORT SLAVE_PORT
20 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1",SOURCE_PORT=$SLAVE_MYPORT,SOURCE_USER="root"
21 START SLAVE;
22 let $MASTER_SERVER_ID= `select @@server_id`;
23 echo MASTER_SERVER_ID: $MASTER_SERVER_ID;
24
25 --echo Setup ndb_replication and exceptions tables
26
27 --disable_warnings
28 --disable_query_log
29 --connection master
30 drop table if exists mysql.ndb_replication;
31 CREATE TABLE mysql.ndb_replication
32 (db VARBINARY(63),
33 table_name VARBINARY(63),
34 server_id INT UNSIGNED,
35 binlog_type INT UNSIGNED,
36 conflict_fn VARBINARY(128),
37 PRIMARY KEY USING HASH (db,table_name,server_id))
38 ENGINE=NDB PARTITION BY KEY(db,table_name);
39 --enable_warnings
40 --enable_query_log
41
42 --echo Populate ndb_replication table as necessary
43 eval replace into mysql.ndb_replication values
44 ("test", "t1", $SLAVE_SERVER_ID, 7, NULL),
45 ("test", "t1", $MASTER_SERVER_ID, 7, "NDB\$EPOCH()"),
46 ("test", "t2", $SLAVE_SERVER_ID, 7, NULL),
47 ("test", "t2", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()");
48
49 #
50 # Test illegal exception table definitions
51 #
52 --disable_query_log
53 call mtr.add_suppression("Replica: exceptions table .* has wrong definition .*");
54 call mtr.add_suppression("Exceptions table *");
55 --enable_query_log
56
57 # Check that all mandatory columns need NDB$ suffix
58
59 create table test.t1$EX
60 (SERVER_ID int unsigned,
61 NDB$MASTER_SERVER_ID int unsigned,
62 NDB$MASTER_EPOCH bigint unsigned,
63 NDB$COUNT int unsigned,
64 a int not null,
65 NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL,
66 NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL,
67 primary key(SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT))
68 ENGINE=NDB;
69
70 create table test.t1 (
71 a int not null,
72 b int not null,
73 c varchar(2000),
74 primary key (a,b)) engine=ndb;
75
76 --let server_num=1.1
77 --let $pattern=%Exceptions table %
78 --let $limit=1
79 # Note warning is displayed in lower case, real warning is correct
80 --source suite/ndb_rpl/t/show_mysqld_warnings.inc
81
82 drop table test.t1$EX, test.t1;
83
84 # Check that referencing old/new values of primary key is not supported
85
86 create table test.t1$EX
87 (NDB$SERVER_ID int unsigned,
88 NDB$MASTER_SERVER_ID int unsigned,
89 NDB$MASTER_EPOCH bigint unsigned,
90 NDB$COUNT int unsigned,
91 a$old int,
92 a$new int,
93 NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL,
94 NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL,
95 primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT))
96 ENGINE=NDB;
97
98 create table test.t1 (
99 a int not null,
100 b int not null,
101 c varchar(2000),
102 primary key (a,b)) engine=ndb;
103
104 --let server_num=1.1
105 --let $pattern=%Exceptions table %
106 --let $limit=1
107 # Note warning is displayed in lower case, real warning is correct
108 --source suite/ndb_rpl/t/show_mysqld_warnings.inc
109
110 drop table test.t1$EX, test.t1;
111
112 # Check that referencing old/new values allow for null values
113
114 create table test.t1$EX
115 (NDB$SERVER_ID int unsigned,
116 NDB$MASTER_SERVER_ID int unsigned,
117 NDB$MASTER_EPOCH bigint unsigned,
118 NDB$COUNT int unsigned,
119 c$old varchar(2000) not null,
120 c$new varchar(2000) not null,
121 NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL,
122 NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL,
123 primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT))
124 ENGINE=NDB CHARACTER SET latin1;
125
126 create table test.t1 (
127 a int not null,
128 b int not null,
129 c varchar(2000),
130 primary key (a,b)) engine=ndb CHARACTER SET latin1;
131
132 --let server_num=1.1
133 --let $pattern=%Exceptions table %
134 --let $limit=1
135 # Note warning is displayed in lower case, real warning is correct
136 --source suite/ndb_rpl/t/show_mysqld_warnings.inc
137
138 drop table test.t1$EX, test.t1;
139
140 create table test.t1$EX
141 (NDB$SERVER_ID int unsigned,
142 NDB$MASTER_SERVER_ID int unsigned,
143 NDB$MASTER_EPOCH bigint unsigned,
144 NDB$COUNT int unsigned,
145 a int not null,
146 NDB$OP_TYPE ENUM('WRITE_ROW','UPDATE_ROW', 'DELETE_ROW') NOT NULL,
147 NDB$CFT_CAUSE ENUM('ROW_DOES_NOT_EXIST','ROW_ALREADY_EXISTS','DATA_IN_CONFLICT','TRANS_IN_CONFLICT') NOT NULL,
148 primary key(NDB$SERVER_ID, NDB$MASTER_SERVER_ID, NDB$MASTER_EPOCH, NDB$COUNT))
149 ENGINE=NDB;
150
151 create table test.t1 (
152 a int not null,
153 b int not null,
154 c varchar(2000),
155 primary key (a,b)) engine=ndb;
156
157 #
158 # Test different column order than original table
159 # for both primary key and non primary columns.
160 # Test non primary key column declared not null,
161 # but with a default value.
162 #
163 create table test.t2$ex
164 (ndb$server_id int unsigned,
165 ndb$master_server_id int unsigned,
166 ndb$master_epoch bigint unsigned,
167 ndb$count int unsigned,
168 d varchar(2000),
169 c int not null default 99,
170 b int not null,
171 a int not null,
172 d$old varchar(2000),
173 d$new varchar(2000),
174 ndb$op_type enum('write_row','update_row', 'delete_row') not null,
175 ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null,
176 ndb$orig_transid bigint unsigned not null,
177 e int,
178 primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count))
179 engine=ndb CHARACTER SET latin1;
180
181 create table test.t2 (
182 x int default 21,
183 a int not null,
184 b int not null,
185 c int,
186 d varchar(2000),
187 e int,
188 primary key(a,b)) engine=ndb CHARACTER SET latin1;
189
190
191 --sync_slave_with_master slave
192
193 --connection master
194 --echo Add some data
195 let $1=10;
196 disable_query_log;
197 while ($1)
198 {
199 eval insert into test.t1 values($1, $1+1, concat("Initial data ",$1));
200 eval insert into test.t2(a,b,c,d,e) values($1, $1+1, $1+2, concat("Initial data ",$1),17);
201 dec $1;
202 }
203 enable_query_log;
204
205 --sync_slave_with_master slave
206
207 --connection slave
208 stop slave;
209
210 --connection slave
211 --echo Slave contents
212 select * from t1 order by a;
213 select * from test.t2 order by a;
214
215 --connection master
216 let $1=10;
217 disable_query_log;
218 while ($1)
219 {
220 eval update test.t1 set c = concat("Master updated data ",$1) where a = $1;
221 begin;
222 eval update test.t2 set d = concat("Master updated data ",$1) where a = $1 and b = $1+1;
223 commit;
224 dec $1;
225 }
226 enable_query_log;
227
228 --connection slave
229 let $1=10;
230 disable_query_log;
231 while ($1)
232 {
233 eval update test.t1 set c = concat("Slave updated data ",$1) where a = $1;
234 begin;
235 eval update test.t2 set d = concat("Slave updated data ",$1) where a = $1 and b = $1+1;
236 commit;
237 dec $1;
238 }
239 enable_query_log;
240
241 --connection master
242 --echo Master contents
243 select * from test.t1 order by a;
244 select * from test.t2 order by a;
245
246 --connection slave
247 --echo Slave contents
248 select * from test.t1 order by a;
249 select * from test.t2 order by a;
250
251
252 --sync_slave_with_master master
253
254 --echo Primary should have rejected change from Secondary, keeping its value
255
256 select * from t1 order by a;
257 select * from t2 order by a;
258
259 --connection slave
260 start slave;
261
262 --connection master
263
264 --sync_slave_with_master slave
265
266 --connection slave
267
268 --echo Secondary should have been realigned to Primary
269 --echo Slave contents
270 select * from t1 order by a;
271 select * from t2 order by a;
272
273 --echo Show rollback of whole secondary transaction
274 --echo --------------------------------------------
275
276 --connection slave
277 flush logs;
278 --sync_slave_with_master master
279 --echo Slave contents
280 select * from t1 order by a;
281 select * from t2 order by a;
282
283 --connection master
284 select count(*) from t1$EX;
285 select NDB$OP_TYPE,NDB$CFT_CAUSE from t1$EX
286 order by a;
287 select count(*) from t2$ex;
288 select a, b, c, d, d$old, d$new, e, ndb$count > 0,ndb$op_type,ndb$cft_cause, ndb$orig_transid > 0 from t2$ex order by a;
289
290
291 #
292 # Test using table name and column names in utf8
293 #
294 SET NAMES utf8;
295
296 eval replace into mysql.ndb_replication values
297 ("test", "アアア", $SLAVE_SERVER_ID, 7, NULL),
298 ("test", "アアア", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()");
299
300 create table test.`アアア$ex`
301 (ndb$server_id int unsigned,
302 ndb$master_server_id int unsigned,
303 ndb$master_epoch bigint unsigned,
304 ndb$count int unsigned,
305 `キキキ` varchar(2000) charset utf8,
306 `カカカ` int not null,
307 ndb$op_type enum('write_row','update_row', 'delete_row') not null,
308 ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null,
309 ndb$orig_transid bigint unsigned not null,
310 primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count))
311 engine=ndb;
312
313 create table test.`アアア` (
314 `カカカ` int primary key,
315 `キキキ` varchar(2000) charset utf8) engine=ndb;
316
317 SET NAMES latin1;
318
319 --let $pattern=%suspicious % column op_type %
320 --let $limit=1
321 --source suite/ndb_rpl/t/show_mysqld_warnings.inc
322
323 SET NAMES utf8;
324 drop table test.`アアア`,test.`アアア$ex`;
325
326 #
327 # Test referencing old/new values of column names in utf8
328 #
329 SET NAMES utf8;
330
331 eval replace into mysql.ndb_replication values
332 ("test", "アアア", $SLAVE_SERVER_ID, 7, NULL),
333 ("test", "アアア", $MASTER_SERVER_ID, 7, "NDB\$EPOCH_TRANS()");
334
335 create table test.`アアア$ex`
336 (ndb$server_id int unsigned,
337 ndb$master_server_id int unsigned,
338 ndb$master_epoch bigint unsigned,
339 ndb$count int unsigned,
340 `キキキ$old` varchar(2000) charset utf8,
341 `キキキ$new` varchar(2000) charset utf8,
342 `カカカ` int not null,
343 ndb$op_type enum('write_row','update_row', 'delete_row') not null,
344 ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null,
345 ndb$orig_transid bigint unsigned not null,
346 primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count))
347 engine=ndb;
348
349 create table test.`アアア` (
350 `カカカ` int primary key,
351 `キキキ` varchar(2000) charset utf8) engine=ndb;
352
353 SET NAMES latin1;
354
355 --let $pattern=%suspicious % column op_type %
356 --let $limit=1
357 --source suite/ndb_rpl/t/show_mysqld_warnings.inc
358
359 --connection slave
360 flush logs;
361 --sync_slave_with_master master
362
363 # Cleanup
364 --connection master
365 drop table test.t1$EX, test.t1, test.t2$ex, test.t2;
366 SET NAMES utf8;
367 drop table test.`アアア`, test.`アアア$ex`;
368 SET NAMES latin1;
369 --sync_slave_with_master slave
370
371 --connection slave
372 flush logs;
373 --sync_slave_with_master master
374
375 drop table mysql.ndb_replication;
376 stop slave;
377 reset slave;
378 #change master to master_host='';
379 --source include/rpl_end.inc