2 # Include file for testing ndb$epoch conflict function
7 (server_id
int unsigned,
8 master_server_id
int unsigned,
9 master_epoch bigint unsigned,
13 primary key(server_id, master_server_id, master_epoch, count)) engine ndb;
17 create
table test.t1(a
int primary key, b varchar(255)) engine = ndb;
19 --echo Create other
table
20 create
table test.t2(a
int primary key, b
int) engine = ndb;
22 --source suite/ndb_rpl/t/ndb_conflict_info_init.inc
24 --echo ----------------------------------
25 --echo
Test 1 : Basic two-way replication
26 --echo ----------------------------------
28 insert into
test.t1 values (1,
"Metropole");
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)
40 --echo -- Insert something
to ensure the
new epoch is noticed
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
47 --sync_slave_with_master slave
49 --echo -- Flushed
to slave
50 select * from
test.t1 order by a;
54 --sync_slave_with_master master
56 --echo -- Flushed back
to Master
57 select * from
test.t1 order by a;
60 --echo -- Now update data on slave
61 update
test.t1
set b=
"Favorit" where a=1;
63 --sync_slave_with_master master
66 --echo -- Now check data on master
67 select * from
test.t1 order by a;
69 --source suite/ndb_rpl/t/ndb_conflict_info.inc
72 --echo -- Now perform multiple consecutive updates on the slave
74 update
test.t1
set b=
"Elephant house" where a=1;
75 update
test.t1
set b=
"Beach house" where a=1;
77 select * from
test.t1 order by a;
79 --sync_slave_with_master master
81 --echo -- Now check they
've applied on the master
82 select * from test.t1 order by a;
84 --source suite/ndb_rpl/t/ndb_conflict_info.inc
86 --echo --------------------------------------------
87 --echo Test 2 : Normal Insert from Secondary Master
88 --echo --------------------------------------------
91 --echo -- Insert a new row on the Slave
92 insert into test.t1 values (2, "Forrest");
94 --sync_slave_with_master master
96 --echo -- Check it exists on the Master
97 select * from test.t1 order by a;
100 --echo -- Update from the slave
101 update test.t1 set b="Reds" where a=2;
103 --sync_slave_with_master master
105 select * from test.t1 order by a;
108 delete from test.t1 where a=2;
110 --sync_slave_with_master master
112 select * from test.t1 order by a;
114 --source suite/ndb_rpl/t/ndb_conflict_info.inc
116 --echo -------------------------------
117 --echo Test 3 : Insert-Insert conflict
118 --echo -------------------------------
124 --echo -- Insert a row on the Primary Master
125 insert into test.t1 values (2, "Loopy Lornas");
128 --echo -- Insert a row on the secondary Master
129 insert into test.t1 values (2, "Cloisters");
131 --sync_slave_with_master master
133 --echo -- Examine data on Primary Master (should be unaffected)
134 select * from test.t1 order by a;
136 --echo -- Examine conflict indicators on Primary Master
137 --source suite/ndb_rpl/t/ndb_conflict_info.inc
139 --echo -- Examine data on isolated secondary Master (should be as-set)
141 select * from test.t1 order by a;
143 --echo -- Restart secondary Masters slave
147 --sync_slave_with_master slave
150 --echo -- Reexamine secondary Master's data (should be same as Primary Masters)
151 select * from
test.t1 order by a;
153 --echo -------------------------------
154 --echo
Test 4 : Update-Update conflict
155 --echo -------------------------------
158 --echo -- Stop replication
to secondary master
162 --echo -- Update row on Primary Master
164 update
test.t1
set b=
"Peters Yard" where a=2;
166 --echo -- Show data on Primary Master
168 select * from
test.t1 order by a;
169 --source suite/ndb_rpl/t/ndb_conflict_info.inc
173 --echo -- Update row on Secondary Master
174 update
test.t1
set b=
"Toast" where a=2;
176 --sync_slave_with_master master
178 --echo -- Examine data on Primary Master - should be unaffected
180 select * from
test.t1 order by a;
181 --source suite/ndb_rpl/t/ndb_conflict_info.inc
184 --echo --
Check data on secondary - should be as
set
186 select * from
test.t1 order by a;
188 --echo -- Now restart slave, will re-align row
192 --sync_slave_with_master slave
195 --echo --
Check that Secondary is re-aligned
197 select * from
test.t1 order by a;
200 --echo -------------------------------
201 --echo
Test 5 : Update-Delete conflict
202 --echo -------------------------------
205 --echo -- Stop Secondary slave
209 --echo -- Update on Primary Master
211 update
test.t1
set b=
"Pear tree" where a = 2;
214 --echo -- Delete on Secondary Master
216 delete from
test.t1 where a = 2;
218 --sync_slave_with_master master
220 --echo -- Examine data on Primary Master, should be unaffected
222 select * from
test.t1 order by a;
223 --source suite/ndb_rpl/t/ndb_conflict_info.inc
225 --echo -- Examine data on Secondary Master before slave restart, still missing
227 select * from
test.t1 order by a;
229 --echo -- Restart Secondary Master slave
233 --sync_slave_with_master slave
236 --echo -- Examine data on Secondary Master after slave restart, aligned with Master
237 select * from
test.t1 order by a;
239 --echo -------------------------------
240 --echo
Test 6 : Delete-Update conflict
241 --echo -------------------------------
244 --echo -- Stop Secondary slave
248 --echo -- Delete on Primary Master
250 delete from
test.t1 where a=2;
253 --echo -- Update on Secondary Master
255 update
test.t1
set b=
"Black pig" where a=2;
257 --sync_slave_with_master master
259 --echo -- Examine data on Primary Master, should be unaffected (no row)
261 select * from
test.t1 order by a;
262 --source suite/ndb_rpl/t/ndb_conflict_info.inc
264 --echo -- Examine data on Secondary Master before slave restart, should be as inserted
266 select * from
test.t1 order by a;
268 --echo -- Restart Secondary Master slave
272 --sync_slave_with_master slave
275 --echo -- Examine data on Secondary Master after slave restart, aligned with Master (deleted)
276 select * from
test.t1 order by a;
278 --echo -------------------------------
279 --echo
Test 7 : Delete-Delete conflict
280 --echo -------------------------------
283 --echo -- Stop Secondary slave
287 --echo -- Delete on Primary Master
289 delete from
test.t1 where a=1;
292 --echo -- Delete on Secondary Master
294 delete from
test.t1 where a=1;
296 --sync_slave_with_master master
298 --echo -- Examine data on Primary Master, no row
300 select * from
test.t1 order by a;
301 --source suite/ndb_rpl/t/ndb_conflict_info.inc
303 --echo -- Examine data on Secondary Master before slave restart, no row
305 select * from
test.t1 order by a;
307 --echo -- Restart Secondary Master slave
311 --sync_slave_with_master slave
314 --echo -- Examine data on Secondary Master after slave restart, no row
315 select * from
test.t1 order by a;
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.
328 --echo -- Insert a row on Secondary Master
329 insert into
test.t1 values (3,
"Espy");
330 --sync_slave_with_master master
333 --echo --
Check it
's present on Primary Master
334 select * from test.t1 order by a;
336 --echo -- Stop replication in both directions
342 --echo -- Delete row from both clusters
343 delete from test.t1 where a=3;
346 delete from test.t1 where a=3;
348 --echo -- Follow up with Insert from Secondary master
351 insert into test.t1 values (3, "Dalriada");
353 --echo -- Restart replication in both directions
359 --sync_slave_with_master slave
361 --sync_slave_with_master master
364 --echo -- Check data on both sites - diverged
365 --echo -- Secondary master :
366 select * from test.t1 order by a;
367 --echo -- Primary master :
369 select * from test.t1 order by a;
371 --echo --Remove extra row
372 delete from test.t1 where a=3;
374 --echo -- Note that Delete-Delete conflict detected below
375 --source suite/ndb_rpl/t/ndb_conflict_info.inc
377 --echo ------------------------------------------------
378 --echo Test 9 : Insert, Insert-Update-Delete conflict
379 --echo ------------------------------------------------
382 --echo -- Stop replication on Secondary Master
386 --echo -- Insert row on Primary Master
387 insert into test.t1 values (4, "Haymarket");
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;
397 --echo -- Examine data (none) on Secondary Master
398 select * from test.t1 order by a;
400 --sync_slave_with_master master
402 --echo -- Examine data on Primary Master, should be unaffected
404 select * from test.t1 order by a;
405 --source suite/ndb_rpl/t/ndb_conflict_info.inc
408 --echo -- Examine data on Secondary Master (none)
409 select * from test.t1 order by a;
411 --echo -- Restart Secondary Master's slave
415 --sync_slave_with_master slave
417 --echo --
Check data on Secondary Master, should be same as Primary Master
418 select * from
test.t1;
420 --echo ------------------------------------------------
421 --echo
Test 10 : Update, Delete-Insert-Update conflict
422 --echo ------------------------------------------------
424 --echo -- Stop replication on Secondary Master
428 --echo -- Update row on Primary Master
429 update
test.t1
set b=
"Blind poet" where a=4;
432 --echo -- Delete row on Secondary Master
433 delete from
test.t1 where a=4;
435 --echo -- Insert row on Secondary Master
436 insert into
test.t1 values (4,
"Drouthy Neebors");
438 --echo -- Update row on Secondary Master
439 update
test.t1
set b=
"The Tankard" where a=4;
441 --sync_slave_with_master master
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
450 --echo --
Check data on Secondary Master, as
set
452 select * from
test.t1 order by a;
454 --echo -- Restart Secondary Master slave
458 --sync_slave_with_master slave
461 --echo --
Check data on Secondary Master - should be as Primary
462 select * from
test.t1 order by a;
464 --sync_slave_with_master master
466 --echo ------------------------------------------------------------------------
467 --echo
Test 11 :
Test Secondary insert-update-
delete accepted
468 --echo ------------------------------------------------------------------------
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;
477 --sync_slave_with_master 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
485 --source suite/ndb_rpl/t/ndb_conflict_info.inc
491 --sync_slave_with_master slave