MySQL 5.6.14 Source Code Document
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ndb_rpl_conflict_epoch_1.inc
1 #
2 # Include file for testing ndb$epoch conflict function
3 #
4 #
5 
6 create table `test`.`t1$EX`
7  (server_id int unsigned,
8  master_server_id int unsigned,
9  master_epoch bigint unsigned,
10  count int unsigned,
11  a int not null,
12  d int,
13  primary key(server_id, master_server_id, master_epoch, count)) engine ndb;
14 
15 
16 --echo Create table
17 create table test.t1(a int primary key, b varchar(255)) engine = ndb;
18 
19 --echo Create other table
20 create table test.t2(a int primary key, b int) engine = ndb;
21 
22 --source suite/ndb_rpl/t/ndb_conflict_info_init.inc
23 
24 --echo ----------------------------------
25 --echo Test 1 : Basic two-way replication
26 --echo ----------------------------------
27 
28 insert into test.t1 values (1, "Metropole");
29 
30 --echo -- Give time for a new epoch on the Master
31 # This is 3 seconds to be > GCP_Save time, so that the next epoch
32 # will be visibly greater than the one inserted above
33 # (e.g. if we have 4 bits of extra GCI resolution, the max
34 # representable GCI is XXX/15. If we insert at XXX/16, we
35 # need to wait until we get to XXX+1/0 at least, to avoid
36 # the Primary Master undoing the update)
37 #
38 --sleep 3
39 
40 --echo -- Insert something to ensure the new epoch is noticed
41 #
42 # Required in case our initial insert's epoch gets rounded up to
43 # 0xffffffff, in which case 'later' updates from the slave will
44 # be in conflict until some newer gci_hi is the MaxReplicatedEpoch
45 #
46 replace into test.t2 values (2, 1);
47 --sync_slave_with_master slave
48 --connection slave
49 --echo -- Flushed to slave
50 select * from test.t1 order by a;
51 --disable_query_log
52 FLUSH LOGS;
53 --enable_query_log
54 --sync_slave_with_master master
55 --connection master
56 --echo -- Flushed back to Master
57 select * from test.t1 order by a;
58 --connection slave
59 
60 --echo -- Now update data on slave
61 update test.t1 set b="Favorit" where a=1;
62 
63 --sync_slave_with_master master
64 
65 --connection master
66 --echo -- Now check data on master
67 select * from test.t1 order by a;
68 
69 --source suite/ndb_rpl/t/ndb_conflict_info.inc
70 
71 --connection slave
72 --echo -- Now perform multiple consecutive updates on the slave
73 
74 update test.t1 set b="Elephant house" where a=1;
75 update test.t1 set b="Beach house" where a=1;
76 
77 select * from test.t1 order by a;
78 
79 --sync_slave_with_master master
80 --connection master
81 --echo -- Now check they've applied on the master
82 select * from test.t1 order by a;
83 
84 --source suite/ndb_rpl/t/ndb_conflict_info.inc
85 
86 --echo --------------------------------------------
87 --echo Test 2 : Normal Insert from Secondary Master
88 --echo --------------------------------------------
89 
90 --connection slave
91 --echo -- Insert a new row on the Slave
92 insert into test.t1 values (2, "Forrest");
93 
94 --sync_slave_with_master master
95 --connection master
96 --echo -- Check it exists on the Master
97 select * from test.t1 order by a;
98 
99 --connection slave
100 --echo -- Update from the slave
101 update test.t1 set b="Reds" where a=2;
102 
103 --sync_slave_with_master master
104 --connection master
105 select * from test.t1 order by a;
106 
107 --connection slave
108 delete from test.t1 where a=2;
109 
110 --sync_slave_with_master master
111 --connection master
112 select * from test.t1 order by a;
113 
114 --source suite/ndb_rpl/t/ndb_conflict_info.inc
115 
116 --echo -------------------------------
117 --echo Test 3 : Insert-Insert conflict
118 --echo -------------------------------
119 
120 --connection slave
121 stop slave;
122 --connection master
123 
124 --echo -- Insert a row on the Primary Master
125 insert into test.t1 values (2, "Loopy Lornas");
126 
127 --connection slave
128 --echo -- Insert a row on the secondary Master
129 insert into test.t1 values (2, "Cloisters");
130 
131 --sync_slave_with_master master
132 --connection master
133 --echo -- Examine data on Primary Master (should be unaffected)
134 select * from test.t1 order by a;
135 
136 --echo -- Examine conflict indicators on Primary Master
137 --source suite/ndb_rpl/t/ndb_conflict_info.inc
138 
139 --echo -- Examine data on isolated secondary Master (should be as-set)
140 --connection slave
141 select * from test.t1 order by a;
142 
143 --echo -- Restart secondary Masters slave
144 start slave;
145 
146 --connection master
147 --sync_slave_with_master slave
148 --connection slave
149 
150 --echo -- Reexamine secondary Master's data (should be same as Primary Masters)
151 select * from test.t1 order by a;
152 
153 --echo -------------------------------
154 --echo Test 4 : Update-Update conflict
155 --echo -------------------------------
156 
157 --connection slave
158 --echo -- Stop replication to secondary master
159 stop slave;
160 
161 --connection master
162 --echo -- Update row on Primary Master
163 
164 update test.t1 set b="Peters Yard" where a=2;
165 
166 --echo -- Show data on Primary Master
167 
168 select * from test.t1 order by a;
169 --source suite/ndb_rpl/t/ndb_conflict_info.inc
170 
171 --connection slave
172 
173 --echo -- Update row on Secondary Master
174 update test.t1 set b="Toast" where a=2;
175 
176 --sync_slave_with_master master
177 
178 --echo -- Examine data on Primary Master - should be unaffected
179 
180 select * from test.t1 order by a;
181 --source suite/ndb_rpl/t/ndb_conflict_info.inc
182 
183 --connection slave
184 --echo -- Check data on secondary - should be as set
185 
186 select * from test.t1 order by a;
187 
188 --echo -- Now restart slave, will re-align row
189 start slave;
190 
191 --connection master
192 --sync_slave_with_master slave
193 
194 --connection slave
195 --echo -- Check that Secondary is re-aligned
196 
197 select * from test.t1 order by a;
198 
199 
200 --echo -------------------------------
201 --echo Test 5 : Update-Delete conflict
202 --echo -------------------------------
203 
204 --connection slave
205 --echo -- Stop Secondary slave
206 stop slave;
207 
208 --connection master
209 --echo -- Update on Primary Master
210 
211 update test.t1 set b="Pear tree" where a = 2;
212 
213 --connection slave
214 --echo -- Delete on Secondary Master
215 
216 delete from test.t1 where a = 2;
217 
218 --sync_slave_with_master master
219 
220 --echo -- Examine data on Primary Master, should be unaffected
221 
222 select * from test.t1 order by a;
223 --source suite/ndb_rpl/t/ndb_conflict_info.inc
224 
225 --echo -- Examine data on Secondary Master before slave restart, still missing
226 --connection slave
227 select * from test.t1 order by a;
228 
229 --echo -- Restart Secondary Master slave
230 start slave;
231 
232 --connection master
233 --sync_slave_with_master slave
234 --connection slave
235 
236 --echo -- Examine data on Secondary Master after slave restart, aligned with Master
237 select * from test.t1 order by a;
238 
239 --echo -------------------------------
240 --echo Test 6 : Delete-Update conflict
241 --echo -------------------------------
242 
243 --connection slave
244 --echo -- Stop Secondary slave
245 stop slave;
246 
247 --connection master
248 --echo -- Delete on Primary Master
249 
250 delete from test.t1 where a=2;
251 
252 --connection slave
253 --echo -- Update on Secondary Master
254 
255 update test.t1 set b="Black pig" where a=2;
256 
257 --sync_slave_with_master master
258 
259 --echo -- Examine data on Primary Master, should be unaffected (no row)
260 
261 select * from test.t1 order by a;
262 --source suite/ndb_rpl/t/ndb_conflict_info.inc
263 
264 --echo -- Examine data on Secondary Master before slave restart, should be as inserted
265 --connection slave
266 select * from test.t1 order by a;
267 
268 --echo -- Restart Secondary Master slave
269 start slave;
270 
271 --connection master
272 --sync_slave_with_master slave
273 --connection slave
274 
275 --echo -- Examine data on Secondary Master after slave restart, aligned with Master (deleted)
276 select * from test.t1 order by a;
277 
278 --echo -------------------------------
279 --echo Test 7 : Delete-Delete conflict
280 --echo -------------------------------
281 
282 --connection slave
283 --echo -- Stop Secondary slave
284 stop slave;
285 
286 --connection master
287 --echo -- Delete on Primary Master
288 
289 delete from test.t1 where a=1;
290 
291 --connection slave
292 --echo -- Delete on Secondary Master
293 
294 delete from test.t1 where a=1;
295 
296 --sync_slave_with_master master
297 
298 --echo -- Examine data on Primary Master, no row
299 
300 select * from test.t1 order by a;
301 --source suite/ndb_rpl/t/ndb_conflict_info.inc
302 
303 --echo -- Examine data on Secondary Master before slave restart, no row
304 --connection slave
305 select * from test.t1 order by a;
306 
307 --echo -- Restart Secondary Master slave
308 start slave;
309 
310 --connection master
311 --sync_slave_with_master slave
312 --connection slave
313 
314 --echo -- Examine data on Secondary Master after slave restart, no row
315 select * from test.t1 order by a;
316 
317 
318 --echo ------------------------------------------------
319 --echo Test 8 : Delete-Delete, Insert conflict exposure
320 --echo ------------------------------------------------
321 # This occurs as the Primary Master's Delete is still
322 # in-flight when the Secondary Master's Insert arrives,
323 # but as there is no knowledge of this at the Primary
324 # Master, it accepts the Insert.
325 #
326 
327 --connection slave
328 --echo -- Insert a row on Secondary Master
329 insert into test.t1 values (3, "Espy");
330 --sync_slave_with_master master
331 
332 --connection master
333 --echo -- Check it's present on Primary Master
334 select * from test.t1 order by a;
335 
336 --echo -- Stop replication in both directions
337 stop slave;
338 
339 --connection slave
340 stop slave;
341 
342 --echo -- Delete row from both clusters
343 delete from test.t1 where a=3;
344 
345 --connection master
346 delete from test.t1 where a=3;
347 
348 --echo -- Follow up with Insert from Secondary master
349 --connection slave
350 
351 insert into test.t1 values (3, "Dalriada");
352 
353 --echo -- Restart replication in both directions
354 start slave;
355 
356 --connection master
357 start slave;
358 
359 --sync_slave_with_master slave
360 --connection slave
361 --sync_slave_with_master master
362 
363 --connection slave
364 --echo -- Check data on both sites - diverged
365 --echo -- Secondary master :
366 select * from test.t1 order by a;
367 --echo -- Primary master :
368 --connection master
369 select * from test.t1 order by a;
370 
371 --echo --Remove extra row
372 delete from test.t1 where a=3;
373 
374 --echo -- Note that Delete-Delete conflict detected below
375 --source suite/ndb_rpl/t/ndb_conflict_info.inc
376 
377 --echo ------------------------------------------------
378 --echo Test 9 : Insert, Insert-Update-Delete conflict
379 --echo ------------------------------------------------
380 
381 --connection slave
382 --echo -- Stop replication on Secondary Master
383 stop slave;
384 
385 --connection master
386 --echo -- Insert row on Primary Master
387 insert into test.t1 values (4, "Haymarket");
388 
389 --connection slave
390 --echo -- Insert row on Secondary Master
391 insert into test.t1 values (4, "Outhouse");
392 --echo -- Update row on Secondary Master
393 update test.t1 set b="Mathers" where a = 4;
394 --echo -- Delete row on Secondary Master
395 delete from test.t1 where a=4;
396 
397 --echo -- Examine data (none) on Secondary Master
398 select * from test.t1 order by a;
399 
400 --sync_slave_with_master master
401 --connection master
402 --echo -- Examine data on Primary Master, should be unaffected
403 
404 select * from test.t1 order by a;
405 --source suite/ndb_rpl/t/ndb_conflict_info.inc
406 
407 --connection slave
408 --echo -- Examine data on Secondary Master (none)
409 select * from test.t1 order by a;
410 
411 --echo -- Restart Secondary Master's slave
412 start slave;
413 
414 --connection master
415 --sync_slave_with_master slave
416 --connection slave
417 --echo -- Check data on Secondary Master, should be same as Primary Master
418 select * from test.t1;
419 
420 --echo ------------------------------------------------
421 --echo Test 10 : Update, Delete-Insert-Update conflict
422 --echo ------------------------------------------------
423 --connection slave
424 --echo -- Stop replication on Secondary Master
425 stop slave;
426 
427 --connection master
428 --echo -- Update row on Primary Master
429 update test.t1 set b="Blind poet" where a=4;
430 
431 --connection slave
432 --echo -- Delete row on Secondary Master
433 delete from test.t1 where a=4;
434 
435 --echo -- Insert row on Secondary Master
436 insert into test.t1 values (4, "Drouthy Neebors");
437 
438 --echo -- Update row on Secondary Master
439 update test.t1 set b="The Tankard" where a=4;
440 
441 --sync_slave_with_master master
442 
443 --connection master
444 
445 --echo -- Check data on Primary Master, should be unaffected
446 select * from test.t1 order by a;
447 --source suite/ndb_rpl/t/ndb_conflict_info.inc
448 
449 --connection slave
450 --echo -- Check data on Secondary Master, as set
451 
452 select * from test.t1 order by a;
453 
454 --echo -- Restart Secondary Master slave
455 start slave;
456 
457 --connection master
458 --sync_slave_with_master slave
459 --connection slave
460 
461 --echo -- Check data on Secondary Master - should be as Primary
462 select * from test.t1 order by a;
463 
464 --sync_slave_with_master master
465 
466 --echo ------------------------------------------------------------------------
467 --echo Test 11 : Test Secondary insert-update-delete accepted
468 --echo ------------------------------------------------------------------------
469 --connection slave
470 --echo Insert row on Secondary
471 insert into test.t1 values (5, "Minders");
472 --echo Update row on Secondary
473 update test.t1 set b="Southsider" where a=5;
474 --echo Delete row on Secondary
475 delete from test.t1 where a=5;
476 
477 --sync_slave_with_master master
478 
479 --connection master
480 --echo Check data on Primary, should be none. No new conflicts
481 select * from test.t1 order by a;
482 --source suite/ndb_rpl/t/ndb_conflict_info.inc
483 
484 --connection master
485 --source suite/ndb_rpl/t/ndb_conflict_info.inc
486 
487 drop table test.t1;
488 drop table test.t2;
489 drop table test.t1$EX;
490 
491 --sync_slave_with_master slave
492 
493 --connection master