Debian Codegraph @

mysql-test/suite/ndb_rpl/t/ndb_rpl_conflict_epoch_trans.inc

raw
1 #
2 # Test engine native conflict resolution for ndb
3 # NDB$EPOCH[2]_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 --disable_query_log
13 --disable_result_log
14 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
15 RESET MASTER;
16 STOP SLAVE;
17 select @secondary_server_id:=(variable_value+0)
18 from performance_schema.global_variables
19 where variable_name like 'server_id';
20 let $SECONDARY_SERVER_ID= query_get_value('select @secondary_server_id as v',v,1);
21 select @secondary_port:=(variable_value+0)
22 from performance_schema.global_variables
23 where variable_name like 'port';
24 let $SECONDARY_PORT= query_get_value('select @secondary_port as v',v,1);
25
26 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
27 RESET MASTER;
28 STOP SLAVE;
29 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1",SOURCE_PORT=$SECONDARY_PORT,SOURCE_USER="root"
30 START SLAVE;
31 select @primary_server_id:=(variable_value+0)
32 from performance_schema.global_variables
33 where variable_name like 'server_id';
34 let $PRIMARY_SERVER_ID= query_get_value('select @primary_server_id as v',v,1);
35 select @primary_port:=(variable_value+0)
36 from performance_schema.global_variables
37 where variable_name like 'port';
38 let $PRIMARY_PORT= query_get_value('select @primary_port as v',v,1);
39
40 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
41 --eval CHANGE REPLICATION SOURCE TO SOURCE_HOST="127.0.0.1",SOURCE_PORT=$PRIMARY_PORT,SOURCE_USER="root"
42 START SLAVE;
43
44 --enable_result_log
45 --enable_query_log
46
47 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
48
49 --echo Setup ndb_replication and t1$EX exceptions table
50
51 --disable_warnings
52 --disable_query_log
53 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
54 drop table if exists mysql.ndb_replication;
55 CREATE TABLE mysql.ndb_replication
56 (db VARBINARY(63),
57 table_name VARBINARY(63),
58 server_id INT UNSIGNED,
59 binlog_type INT UNSIGNED,
60 conflict_fn VARBINARY(128),
61 PRIMARY KEY USING HASH (db,table_name,server_id))
62 ENGINE=NDB PARTITION BY KEY(db,table_name);
63 --enable_warnings
64 --enable_query_log
65
66 if (!$PRIMARY_CONFLICT_ALG)
67 {
68 let $PRIMARY_CONFLICT_ALG=\"NDB\$EPOCH_TRANS()\";
69 }
70 if (!$SECONDARY_CONFLICT_ALG)
71 {
72 let $SECONDARY_CONFLICT_ALG=NULL;
73 }
74
75 --echo Populate ndb_replication table as necessary
76 eval replace into mysql.ndb_replication values
77 ("test", "t1", $SECONDARY_SERVER_ID, 7, $SECONDARY_CONFLICT_ALG),
78 ("test", "t1", $PRIMARY_SERVER_ID, 7, $PRIMARY_CONFLICT_ALG);
79 eval replace into mysql.ndb_replication values
80 ("test", "t2", $SECONDARY_SERVER_ID, 7, $SECONDARY_CONFLICT_ALG),
81 ("test", "t2", $PRIMARY_SERVER_ID, 7, $PRIMARY_CONFLICT_ALG);
82
83 create table test.t1 (
84 a int primary key,
85 b varchar(2000)) engine=ndb;
86
87 create table test.t2 (
88 a int primary key,
89 b varchar(2000)) engine=ndb;
90
91 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
92 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
93
94 --echo Add some data
95 insert into test.t1 values
96 (1, "Initial data 1"),
97 (2, "Initial data 2"),
98 (3, "Initial data 3"),
99 (4, "Initial data 4"),
100 (5, "Initial data 5"),
101 (6, "Initial data 6"),
102 (7, "Initial data 7"),
103 (8, "Initial data 8"),
104 (9, "Initial data 9"),
105 (10, "Initial data 10");
106
107 --echo Show basic row-level conflict detection
108 --echo ---------------------------------------
109 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
110 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
111
112 stop slave;
113
114 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
115
116 update t1 set b="Primary first change 2" where a=2;
117 select * from test.t1 order by a;
118
119 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
120
121 update t1 set b="Secondary first change 2" where a=2;
122 select * from test.t1 order by a;
123
124 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
125 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
126
127 --echo Primary should have rejected change from Secondary, keeping its value
128
129 select * from t1 order by a;
130
131 --source suite/ndb_rpl/t/ndb_trans_conflict_info.inc
132
133 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
134
135 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
136
137 start slave;
138
139 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
140 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
141 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
142
143 --echo Secondary should have been realigned to Primary
144
145 select * from t1 order by a;
146
147 --echo Show rollback of whole secondary transaction
148 --echo --------------------------------------------
149
150 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
151
152 stop slave;
153
154 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
155 update t1 set b="Primary second change 4" where a=4;
156
157 select * from test.t1 order by a;
158
159 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
160 begin;
161 update t1 set b="Secondary second change 4" where a=4;
162 update t1 set b="Secondary second change 5" where a=5;
163 commit;
164
165 select * from test.t1 order by a;
166
167 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
168 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
169
170 --echo Primary should have rejected secondary changes on both rows
171 select * from test.t1 order by a;
172
173 --source suite/ndb_rpl/t/ndb_trans_conflict_info.inc
174
175 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
176
177 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
178 start slave;
179
180 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
181 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
182 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
183
184 --echo Secondary should have been realigned to Primary
185 select * from test.t1 order by a;
186
187 --echo Show rollback of dependent transaction as well
188 --echo ----------------------------------------------
189
190 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
191 stop slave;
192
193 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
194 update t1 set b="Primary third change 1" where a=1;
195
196 select * from test.t1 order by a;
197
198 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
199
200 begin;
201 update t1 set b="Secondary third change 3" where a=3;
202 update t1 set b="Secondary third change 1" where a=1; # Conflict here
203 commit;
204 begin;
205 update t1 set b="Secondary fourth change 3" where a=3; # Dependency on conflict here
206 insert into t1 values (11,"Secondary fourth change 11");
207 commit;
208
209 select * from test.t1 order by a;
210
211 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
212 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
213
214 --echo Primary should have rejected all secondary changes
215 select * from test.t1 order by a;
216
217 --source suite/ndb_rpl/t/ndb_trans_conflict_info_stable.inc
218
219 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
220
221 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
222 start slave;
223
224 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
225 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
226 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
227
228 --echo Secondary should have been realigned to Primary
229
230 select * from test.t1 order by a;
231
232
233 --echo Show rollback of dependent transaction across different tables
234 --echo --------------------------------------------------------------
235
236 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
237 stop slave;
238
239 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
240
241 update t1 set b="Primary fifth change 6" where a=6;
242
243 select * from test.t1 order by a;
244
245 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
246
247 begin;
248 update t1 set b="Secondary fifth change 6" where a=6; # Conflict row
249 insert into t2 values (1, "Secondary fifth change 1");
250 insert into t2 values (2, "Secondary fifth change 2");
251 commit;
252 begin;
253 update t2 set b="Secondary sixth change 1" where a=2; # Dependent row
254 insert into t2 values (3, "Secondary sixth change 2");
255 commit;
256
257 select * from test.t1 order by a;
258 select * from test.t2 order by a;
259
260 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
261 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
262
263 --echo Primary should have rejected all secondary changes
264 select * from test.t1 order by a;
265 select * from test.t2 order by a;
266
267 --source suite/ndb_rpl/t/ndb_trans_conflict_info_stable.inc
268
269 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
270
271 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
272 start slave;
273 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
274 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
275 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
276
277 --echo Secondary should have been realigned to primary
278 select * from test.t1 order by a;
279 select * from test.t2 order by a;
280
281 --echo Show that whole epoch is not rolled back
282 --echo ----------------------------------------
283 # Whole epoch is rolled back when --ndb-serverid-transid-bits is 0!
284
285 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
286 stop slave;
287
288 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
289 update t1 set b="Primary is king" where a=10;
290
291 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
292 begin;
293 update t1 set b="Secondary is emperor" where a=10;
294 insert into t1 values (11, "Secondary is pleni-potentiary");
295 commit;
296
297 begin;
298 insert into t1 values (12, "Secondary ruled once");
299 insert into t1 values (13, "This history will not be lost");
300 insert into t1 values (14, "Look on my works ye mighty, and despair");
301 commit;
302
303 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
304 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
305
306 --echo Primary should have rejected conflicting trans (emperor, pleni-potentiary)
307 --echo but accepted unrelated trans (history)
308
309 select * from t1 order by a;
310
311 --source suite/ndb_rpl/t/ndb_trans_conflict_info.inc
312
313 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
314
315 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
316 start slave;
317
318 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
319 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
320 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
321
322 --echo Secondary should be aligned with Primary
323
324 select * from t1 order by a;
325
326
327 --echo Show that non-conflicting ancestors are not implicated
328 --echo ------------------------------------------------------
329
330 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
331 stop slave;
332
333 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
334 update t1 set b="7 : Primary is king" where a=7;
335
336 --echo Primary state
337 select * from test.t1 order by a;
338
339 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
340
341 # 'Innocent' secondary transaction
342 begin;
343 update t1 set b="8 : Secondary innocent" where a=8;
344 update t1 set b="9 : Secondary innocent" where a=9;
345 commit;
346
347 --echo Secondary with innocent
348 select * from test.t1 order by a;
349
350 # 'Guilty secondary transaction, affecting one of the same rows as innocent
351 begin;
352 update t1 set b="9 : Secondary guilty" where a=9; # Dependency on innocent
353 update t1 set b="7 : Secondary guilty" where a=7; # Conflict row
354 commit;
355
356 --echo Secondary with guilty overlaid
357 select * from test.t1 order by a;
358
359 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
360 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
361
362 --echo Primary cluster should have rejected 'guilty' secondary transaction, but
363 --echo accepted 'innocent' secondary transaction.
364
365 select * from test.t1 order by a;
366
367 --source suite/ndb_rpl/t/ndb_trans_conflict_info.inc
368
369 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
370
371 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
372 start slave;
373
374 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
375
376 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
377 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
378
379 --echo Secondary cluster should be realigned with Primary
380
381 select * from test.t1 order by a;
382
383 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
384
385 --echo Classic banking example
386 --echo -----------------------
387
388 eval replace into mysql.ndb_replication values
389 ("test", "balances", $SECONDARY_SERVER_ID, 7, $SECONDARY_CONFLICT_ALG),
390 ("test", "balances", $PRIMARY_SERVER_ID, 7, $PRIMARY_CONFLICT_ALG);
391
392 # Transactions table may not need conflict-detection?
393 eval replace into mysql.ndb_replication values
394 ("test", "transactions", $SECONDARY_SERVER_ID, 7, $SECONDARY_CONFLICT_ALG),
395 ("test", "transactions", $PRIMARY_SERVER_ID, 7, $PRIMARY_CONFLICT_ALG);
396
397 create table test.balances
398 (name varchar(100) primary key,
399 balance int) engine=ndb;
400
401 if (!$extended_exceptions_table)
402 {
403 create table test.transactions$EX
404 (server_id int unsigned,
405 master_server_id int unsigned,
406 master_epoch bigint unsigned,
407 count int unsigned,
408 auto_key int not null,
409 from_name varchar(100) not null,
410 to_name varchar(100) not null,
411 detail varchar(100) not null,
412 primary key(server_id, master_server_id, master_epoch, count))
413 engine=ndb;
414 }
415
416 if ($extended_exceptions_table)
417 {
418 create table test.transactions$EX
419 (ndb$server_id int unsigned,
420 ndb$master_server_id int unsigned,
421 ndb$master_epoch bigint unsigned,
422 ndb$count int unsigned,
423 auto_key int not null,
424 from_name varchar(100) not null,
425 to_name varchar(100) not null,
426 detail varchar(100) not null,
427 amount$old int,
428 amount$new int,
429 ndb$op_type enum('write_row','update_row', 'delete_row') not null,
430 ndb$cft_cause enum('row_does_not_exist','row_already_exists','data_in_conflict','trans_in_conflict') not null,
431 ndb$orig_transid bigint unsigned not null,
432 primary key(ndb$server_id, ndb$master_server_id, ndb$master_epoch, ndb$count))
433 engine=ndb;
434 }
435
436 create table test.transactions
437 (auto_key int auto_increment,
438 from_name varchar(100),
439 to_name varchar(100),
440 detail varchar(100),
441 amount int,
442 primary key(auto_key, from_name, to_name, detail)) engine=ndb;
443
444 --echo Initialise balances across both bank sites
445 insert into test.balances values
446 ("Larry", 100),
447 ("Employee-1", 0),
448 ("Employee-2", 0),
449 ("Yacht dealer", 0),
450 ("Newsagent", 0);
451
452 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
453 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
454 # Sync back to master, to ensure that what follows on slave,
455 # is in a separate epoch transaction.
456 # This is needed to get stable counts, not for correctness
457 #
458 FLUSH LOGS; # To give a position to sync
459 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
460 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
461
462
463 --echo Bank sites are disconnected
464 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
465 stop slave;
466 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
467
468 --echo Larry buys a yacht using Primary bank site
469
470 begin;
471 insert into test.transactions (from_name, to_name, detail, amount)
472 values ("Larry", "Yacht dealer", "Yacht purchase", 50);
473 update test.balances set balance = balance - 50 where name = "Larry";
474 update test.balances set balance = balance + 50 where name = "Yacht dealer";
475 commit;
476
477 --echo Show yacht transaction records
478
479 select * from test.transactions order by auto_key;
480 select * from test.balances order by name;
481
482 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
483 --echo Larry pays employees using Secondary bank site
484
485 begin;
486 insert into test.transactions (from_name, to_name, detail, amount)
487 values ("Larry", "Employee-1", "Payment to Employee-1", 1);
488 update test.balances set balance = balance - 1 where name = "Larry";
489 update test.balances set balance = balance + 1 where name = "Employee-1";
490 commit;
491 begin;
492 insert into test.transactions (from_name, to_name, detail, amount)
493 values ("Larry", "Employee-2", "Payment to Employee-2", 1);
494 update test.balances set balance = balance - 1 where name = "Larry";
495 update test.balances set balance = balance + 1 where name = "Employee-2";
496 commit;
497
498 --echo Employee-2 buys yacht magazine using Secondary bank site
499 begin;
500 insert into test.transactions (from_name, to_name, detail, amount)
501 values ("Employee-2", "Newsagent", "Buy yacht magazine", 1);
502 update test.balances set balance = balance - 1 where name = "Employee-2";
503 update test.balances set balance = balance + 1 where name = "Newsagent";
504 commit;
505
506 --echo Show employee transactions
507
508 select * from test.transactions order by auto_key;
509 select * from test.balances order by name;
510
511 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
512 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
513
514 --echo Bank sites re-connected
515 start slave;
516
517 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
518 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
519 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
520
521 --echo Records at Primary bank site
522
523 select * from test.transactions order by auto_key;
524 select * from test.balances order by name;
525
526 --echo Exceptions at Primary bank site
527 # Note count not included here as it's non-deterministic
528 # (CompletedOperations list order related to actual completion order related to
529 # universal randomness)
530
531 if (!$extended_exceptions_table)
532 {
533 select server_id, master_server_id, auto_key, from_name, to_name, detail
534 from test.transactions$EX order by auto_key, from_name, to_name, detail;
535 }
536
537 if ($extended_exceptions_table)
538 {
539 select ndb$server_id, ndb$master_server_id, auto_key, from_name, to_name, detail
540 amount$old, amount$new, ndb$op_type, ndb$cft_cause from test.transactions$EX order by ndb$orig_transid, ndb$count;
541 }
542
543 --echo Conflict handling activity at Primary bank site
544 --echo Expect :
545 --echo 1 conflict from slave T1 on Larry's balance
546 --echo 1 conflict from slave T2 on Larry's balance
547 --echo =2 row conflicts
548 --echo
549 --echo 3 (user) transactions rejected
550 --echo 9 rows rejected (3 per transaction)
551 --echo Variability : # epoch transactions, # row conflicts detected
552 --echo 1-3 2-3
553 --echo # detect_iter_count
554 --echo 1-3
555 --echo We only check stable values
556
557 --source suite/ndb_rpl/t/ndb_trans_conflict_info_stable.inc
558
559 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
560
561 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
562
563 --echo Records at Secondary bank site
564
565 select * from test.transactions order by auto_key;
566 select * from test.balances order by name;
567
568 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
569 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
570 drop table test.balances;
571 drop table test.transactions;
572 drop table test.transactions$EX;
573
574 --echo Test mixing transactional and non transactional
575 --echo -----------------------------------------------
576 --echo Remove old data from t1
577 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
578 delete from test.t1;
579 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
580 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
581
582 --echo Define table with row-based epoch detection
583 eval replace into mysql.ndb_replication values
584 ("test", "t3", $SECONDARY_SERVER_ID, 7, NULL),
585 ("test", "t3", $PRIMARY_SERVER_ID, 7, 'NDB\$EPOCH()');
586
587 create table t3 (a int primary key, b int) engine=ndb;
588 create table t4 (a int primary key, b int) engine=ndb;
589 create table t5 (a int primary key, b longtext) engine=ndb;
590
591 --echo Insert some data
592
593 insert into test.t1 values
594 (1,1),
595 (2,2),
596 (3,3),
597 (4,4),
598 (5,5),
599 (6,6);
600
601 insert into test.t3 values
602 (11,11),
603 (12,12),
604 (13,13),
605 (14,14),
606 (15,15),
607 (16,16);
608
609 insert into test.t4 values
610 (21,21),
611 (22,22),
612 (23,23),
613 (24,24),
614 (25,25),
615 (26,26);
616
617 insert into test.t5 values
618 (1, REPEAT("B", 10000)),
619 (2, REPEAT("E", 10000)),
620 (3, REPEAT("A", 10000));
621
622 --echo Allow to propagate
623 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
624 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
625 FLUSH LOGS; # Ensure Inserts are in previous epoch trans to what follows
626
627 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
628
629 --echo Case 1 : Transactional detection affects row - based entries in same trans
630 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
631 stop slave;
632 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
633 update test.t1 set b=100 where a=1;
634
635 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
636 # t3 is in a table without trans conflict detection (but with row based)
637 # t4 is in a table without any detection
638 # t1 is in a table with trans conflict detection
639 begin;
640 update test.t3 set b=1100 where a=11;
641 update test.t4 set b=2100 where a=21;
642 update test.t1 set b=1000 where a=1;
643 commit;
644
645 --echo Show slave transaction effect
646 select * from test.t1 order by a;
647 select * from test.t3 order by a;
648 select * from test.t4 order by a;
649
650 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
651 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
652
653 --echo Expect Primary to have rejected whole trans across 3 tables
654
655 select * from test.t1 order by a;
656 select * from test.t3 order by a;
657 select * from test.t4 order by a;
658
659 --echo Expect 1 transaction rejected, 3 rows rejected
660 --echo 1 conflict row, 1 epoch, 1 iteration
661
662 --source suite/ndb_rpl/t/ndb_trans_conflict_info.inc
663
664 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
665
666 --echo Now restart rep to Secondary, and check realignment
667 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
668 start slave;
669 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
670 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
671 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
672
673 select * from test.t1 order by a;
674 select * from test.t3 order by a;
675 select * from test.t4 order by a;
676
677 --echo Case 2 : Row based detection does not affect other transaction entries
678 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
679 stop slave;
680 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
681 update test.t3 set b=1200 where a=12;
682
683 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
684 # Transaction conflicts with master, on table without transactional
685 # conflict detection
686 # Conflict will be detected on row, but no other transaction state
687 # will be reverted
688 #
689 begin;
690 update test.t3 set b=1201 where a=12;
691 update test.t4 set b=2200 where a=22;
692 update test.t1 set b=2000 where a=2;
693 commit;
694
695 --echo Show effect of transaction on Secondary
696 select * from test.t1 order by a;
697 select * from test.t3 order by a;
698 select * from test.t4 order by a;
699
700 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
701 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
702
703 --echo Show effect of transaction on Primary
704 --echo Only t3 should have been reverted
705
706 select * from test.t1 order by a;
707 select * from test.t3 order by a;
708 select * from test.t4 order by a;
709
710 --echo Expect all counters to be zero
711
712 --source suite/ndb_rpl/t/ndb_trans_conflict_info.inc
713
714 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
715
716 --echo Show effect of transaction on Secondary
717 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
718 start slave;
719 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
720 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
721 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
722
723 select * from test.t1 order by a;
724 select * from test.t3 order by a;
725 select * from test.t4 order by a;
726
727 flush logs;
728 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
729 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
730
731 --echo Case 3 : Check behaviour where table with Blob is implicated
732 --echo in transactional conflict. Should result in Slave
733 --echo stopping with an error.
734
735 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
736 STOP SLAVE;
737
738 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
739
740 --echo Setup warning suppression
741 --disable_query_log
742 call mtr.add_suppression("Transaction conflict handling on table t5 failed as table has Blobs which cannot be refreshed");
743 call mtr.add_suppression("NDBCLUSTER Error_code: MY-001296");
744 --enable_query_log
745
746
747 begin;
748 update t1 set b= 11 where a=1;
749 commit;
750
751 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
752 begin;
753 update t1 set b= 111 where a=1; # Conflict
754 update t1 set b= 222 where a=2; # Implicated row
755 update t5 set b= REPEAT("T", 10000) where a=3; # ImplicatedBlob update
756 commit;
757
758 --echo Show effect of transaction on Secondary
759 select * from test.t1 order by a;
760 select left(b,1), length(b) from test.t5 order by a;
761
762 --echo Check that Primary Slave has stopped
763 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
764
765 --let $slave_sql_errno=1296
766 --source include/wait_for_slave_sql_error.inc
767 #SHOW SLAVE STATUS;
768
769 --echo Restart Primary Slave
770 set global sql_replica_skip_counter=1;
771
772 START SLAVE;
773
774 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
775
776 --echo Restart Secondary Slave
777 START SLAVE;
778
779 flush logs;
780 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
781 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
782
783 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
784 drop table test.t3;
785 drop table test.t4;
786 drop table test.t5;
787
788 --echo Fix misalignment caused above
789 --echo Makes following result sets look nicer
790
791 update test.t1 set b=2 where a=2;
792
793 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
794 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
795 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
796 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
797
798 --echo Show a simple row-level delete-delete conflict
799 --echo PRIMARY:
800
801 insert into test.t1 values (77, "A good year");
802
803 select * from test.t1 order by a;
804
805 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
806 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
807 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
808 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
809
810 --source suite/ndb_rpl/t/ndb_trans_conflict_info_init.inc
811
812 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
813 --echo SECONDARY:
814 stop slave;
815
816 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
817 --echo PRIMARY:
818 --echo Primary Delete
819 delete from test.t1 where a=77;
820
821 --echo Show Primary contents
822 select * from test.t1 order by a;
823
824 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
825 --echo SECONDARY:
826 select * from test.t1 order by a;
827
828 --echo Secondary Delete->Insert in separate transactions
829 --echo and potentially different epochs
830 --echo Delete part with related transaction op
831 begin;
832 delete from test.t1 where a=77;
833 insert into test.t1 values (73, "A superb year");
834 commit;
835
836 # Grab commit epoch
837 --disable_query_log
838 --disable_result_log
839 SELECT @s1_epoch:=(Variable_value + 0)
840 FROM performance_schema.global_status
841 WHERE variable_name like 'Ndb_last_commit_epoch_session';
842 let $S1_EPOCH= query_get_value('select @s1_epoch as v',v,1);
843 --enable_result_log
844 --enable_query_log
845
846
847 --echo Unrelated transaction from Secondary
848 begin;
849 insert into test.t1 values (84, "A good vintage");
850 commit;
851
852 # Optionally flush logs here to mix separate-epoch and
853 # same-epoch
854 --echo Optionally flush logs
855 let $do_flush=query_get_value(SELECT (RAND() * 10) > 5 AS y, y, 1);
856
857 if ($do_flush)
858 {
859 --disable_query_log
860 --disable_result_log
861 FLUSH LOGS;
862 --enable_query_log
863 --enable_result_log
864 }
865
866 --echo Following Insert from Secondary - potentially in different epoch
867 begin;
868 insert into test.t1 values (77, "Exceptional");
869 insert into test.t1 values (80, "Poor");
870 commit;
871
872 # Grab commit epoch
873 --disable_query_log
874 --disable_result_log
875 SELECT @s2_epoch:=(Variable_value + 0)
876 FROM performance_schema.global_status
877 WHERE variable_name like 'Ndb_last_commit_epoch_session';
878 let $S2_EPOCH= query_get_value('select @s2_epoch as v',v,1);
879 --enable_result_log
880 --enable_query_log
881
882 --echo Show Secondary contents
883 select * from test.t1 order by a;
884
885 --echo Allow propagation to Primary
886 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
887 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
888 --echo PRIMARY:
889 --echo Expect:
890 --echo - NDB\$EPOCH_TRANS :
891 --echo - Will not detect delete-delete conflict, so first
892 --echo Secondary transaction will apply row 73.
893 --echo - Unrelated transaction from Secondary (84) is present
894 --echo - Following insert on delete-delete conflict row (77) is not in conflict,
895 --echo so both it and the related row from the same transaction (80) are present
896 --echo This applies whether the following insert is in the same or a different
897 --echo epoch
898 --echo Divergence:
899 --echo - Primary will have 73,84,77,80
900 --echo - Secondary will have 73,84,80, no 77
901 --echo
902 --echo - NDB\$EPOCH_TRANS2 :
903 --echo - Will detect delete-delete conflict, so first
904 --echo Secondary transaction will not apply (no row 73)
905 --echo 77 and 73 will be refreshed (DEL)
906 --echo - Unrelated transaction from Secondary (84) is present and applied
907 --echo 84 will be reflected (INS)
908 --echo - Following insert on delete-delete conflict row (77) will be found in
909 --echo conflict iff this transaction is in the same epoch as the first
910 --echo conflicting transaction. If it is in a different epoch then it will
911 --echo not be found in conflict, as there will be no state available to
912 --echo use.
913 --echo - If it is in-conflict, then 77 and 80 will be refreshed (DEL)
914 --echo Result on both should be :
915 --echo 84
916 --echo - If it is not in-conflict, then 77 and 80 will be reflected (INS)
917 --echo Result on both should be :
918 --echo 84, 77, 80
919 --echo No divergence
920
921 --disable_query_log
922 --disable_result_log
923 eval select @epochs_equal:=$S1_EPOCH=$S2_EPOCH as epochs_equal;
924 let $EPOCHS_EQUAL= query_get_value('select @epochs_equal as v',v,1);
925
926 eval select @Epoch2:=$PRIMARY_CONFLICT_ALG LIKE "%EPOCH2%";
927 let $HAVE_EPOCH2= query_get_value('select @Epoch2 as v',v,1);
928
929 select @PrimaryRow77Present:=count(1) from test.t1 where a=77;
930 select @PrimaryRow73Present:=count(1) from test.t1 where a=73;
931 select @PrimaryRow80Present:=count(1) from test.t1 where a=80;
932 select @PrimaryRow84Present:=count(1) from test.t1 where a=84;
933
934 eval select @epoch_trans:=
935 !$HAVE_EPOCH2 and
936 @PrimaryRow77Present and
937 @PrimaryRow73Present and
938 @PrimaryRow80Present and
939 @PrimaryRow84Present;
940
941 eval select @epoch_trans2_same_epoch:=
942 $HAVE_EPOCH2 and
943 $EPOCHS_EQUAL and
944 !@PrimaryRow77Present and
945 !@PrimaryRow73Present and
946 !@PrimaryRow80Present and
947 @PrimaryRow84Present;
948
949 eval select @epoch_trans2_diff_epoch:=
950 $HAVE_EPOCH2 and
951 !$EPOCHS_EQUAL and
952 @PrimaryRow77Present and
953 !@PrimaryRow73Present and
954 @PrimaryRow80Present and
955 @PrimaryRow84Present;
956
957
958 --enable_result_log
959 --enable_query_log
960
961 set @primary_ok:=
962 ((@epoch_trans XOR
963 @epoch_trans2_same_epoch) XOR
964 @epoch_trans2_diff_epoch);
965
966 select @primary_ok;
967 let $primary_ok= query_get_value('select @primary_ok as v',v,1);
968
969 if (!$primary_ok)
970 {
971 echo Problem, dumping data;
972 select * from test.t1;
973 eval select $HAVE_EPOCH2 as have_epoch2;
974 eval select $EPOCHS_EQUAL as epochs_equal;
975 die Testcase problem;
976 }
977
978 if (!$HAVE_EPOCH2)
979 {
980 echo EPOCH_TRANS has stable results independent of;
981 echo epoch boundaries: ;
982
983 select * from test.t1 order by a;
984
985 source suite/ndb_rpl/t/ndb_trans_conflict_info_stable.inc;
986 }
987 if ($HAVE_EPOCH2)
988 {
989 echo EPOCH2_TRANS results are dependent on epoch boundaries;
990 }
991
992 --echo Now sync with Secondary to show outcomes
993 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
994 start slave;
995 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
996 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
997 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
998 --echo SECONDARY:
999 --echo
1000
1001 --disable_query_log
1002 --disable_result_log
1003
1004 select @SecondaryRow77Present:=count(1) from test.t1 where a=77;
1005 select @SecondaryRow73Present:=count(1) from test.t1 where a=73;
1006 select @SecondaryRow80Present:=count(1) from test.t1 where a=80;
1007 select @SecondaryRow84Present:=count(1) from test.t1 where a=84;
1008
1009
1010 eval select @epoch_trans:=
1011 !$HAVE_EPOCH2 and
1012 !@SecondaryRow77Present and
1013 @SecondaryRow73Present and
1014 @SecondaryRow80Present and
1015 @SecondaryRow84Present;
1016
1017 eval select @epoch_trans2_same_epoch:=
1018 $HAVE_EPOCH2 and
1019 $EPOCHS_EQUAL and
1020 !@SecondaryRow77Present and
1021 !@SecondaryRow73Present and
1022 !@SecondaryRow80Present and
1023 @SecondaryRow84Present;
1024
1025 eval select @epoch_trans2_diff_epoch:=
1026 $HAVE_EPOCH2 and
1027 !$EPOCHS_EQUAL and
1028 @SecondaryRow77Present and
1029 !@SecondaryRow73Present and
1030 @SecondaryRow80Present and
1031 @SecondaryRow84Present;
1032
1033 --enable_result_log
1034 --enable_query_log
1035
1036 set @secondary_ok:=
1037 ((@epoch_trans XOR
1038 @epoch_trans2_same_epoch) XOR
1039 @epoch_trans2_diff_epoch);
1040 select @secondary_ok;
1041
1042 let $secondary_ok= query_get_value('select @secondary_ok as v',v,1);
1043
1044 if (!$secondary_ok)
1045 {
1046 echo Problem, dumping data;
1047 select * from test.t1;
1048 eval select $HAVE_EPOCH2 as have_epoch2;
1049 eval select $EPOCHS_EQUAL as epochs_equal;
1050 die Testcase problem;
1051 }
1052
1053 if (!$HAVE_EPOCH2)
1054 {
1055 echo EPOCH_TRANS has stable results independent of;
1056 echo epoch boundaries: ;
1057 select * from test.t1 order by a;
1058 }
1059 if ($HAVE_EPOCH2)
1060 {
1061 echo EPOCH2_TRANS results are dependent on epoch boundaries;
1062 }
1063
1064 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
1065 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
1066
1067 --echo PRIMARY
1068 --echo Cleanup
1069 delete from test.t1 where a != 6;
1070 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
1071 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
1072 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
1073 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
1074
1075
1076
1077
1078
1079
1080
1081 --echo PRIMARY
1082 --echo Transactional Delete testcase
1083
1084 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
1085
1086 --echo STOP slave on SECONDARY
1087 stop slave;
1088
1089 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
1090
1091 --echo PRIMARY
1092 --echo Primary updates row with pk 6
1093
1094 update test.t1 set b="Pentland" where a=6;
1095
1096 --echo PRIMARY content
1097 --echo Row 6 updated
1098 select * from test.t1 order by a;
1099
1100 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
1101
1102 --echo SECONDARY
1103 --echo Transaction deleting pk 6, inserting pk 7
1104 begin;
1105 delete from test.t1 where a = 6;
1106 insert into test.t1 values (7, "Mendip");
1107 commit;
1108
1109 # Grab commit epoch
1110 --disable_query_log
1111 --disable_result_log
1112 SELECT @s1_epoch:=(Variable_value + 0)
1113 FROM performance_schema.global_status
1114 WHERE variable_name like 'Ndb_last_commit_epoch_session';
1115 let $S1_EPOCH= query_get_value('select @s1_epoch as v',v,1);
1116 --enable_result_log
1117 --enable_query_log
1118
1119
1120 # Optionally flush logs here to mix separate-epoch and
1121 # same-epoch
1122 --echo Optionally flush logs
1123 let $do_flush=query_get_value(SELECT (RAND() * 10) > 5 AS y, y, 1);
1124
1125 if ($do_flush)
1126 {
1127 --disable_query_log
1128 --disable_result_log
1129 FLUSH LOGS;
1130 --enable_query_log
1131 --enable_result_log
1132 }
1133
1134 #--echo Flushed? $do_flush
1135
1136 --echo Transaction deleting pk 7, inserting pk 8
1137 begin;
1138 delete from test.t1 where a = 7;
1139 insert into test.t1 values (8, "Ochil");
1140 commit;
1141
1142 # Grab commit epoch
1143 --disable_query_log
1144 --disable_result_log
1145 SELECT @s2_epoch:=(Variable_value + 0)
1146 FROM performance_schema.global_status
1147 WHERE variable_name like 'Ndb_last_commit_epoch_session';
1148 let $S2_EPOCH= query_get_value('select @s2_epoch as v',v,1);
1149 eval select @epochs_equal:=$S1_EPOCH=$S2_EPOCH as epochs_equal;
1150 let $EPOCHS_EQUAL= query_get_value('select @epochs_equal as v',v,1);
1151
1152 eval select @Epoch2:=$PRIMARY_CONFLICT_ALG LIKE "%EPOCH2%";
1153 let $HAVE_EPOCH2= query_get_value('select @Epoch2 as v',v,1);
1154 --enable_result_log
1155 --enable_query_log
1156
1157 --echo SECONDARY content
1158 --echo Rows 6 + 7 deleted. Row 8 present.
1159 select * from test.t1 order by a;
1160
1161 --echo Sync SECONDARY -> PRIMARY
1162 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
1163 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
1164
1165 --echo Expected Behaviour
1166 --echo EPOCH_TRANS
1167 --echo
1168 --echo 1. Conflict between Primary update to 6 + Secondary
1169 --echo [Delete of 6 + Insert of 7] is detected by Primary
1170 --echo and transaction is not applied at the Primary.
1171 --echo Rows 6 (INS) and 7 (DEL) are refreshed. Row 6 has its
1172 --echo epoch updated.
1173 --echo
1174 --echo 2. Following Secondary transaction, [delete of 7
1175 --echo + insert of 8] behaviour depends on whether it
1176 --echo arrives in the same or a different epoch.
1177 --echo Same epoch :
1178 --echo Will conflict with refreshed row 7, and so will
1179 --echo not be applied. Row 8 will be refreshed (DEL)
1180 --echo Different epoch :
1181 --echo Will not conflict with Not-present row 7, and so
1182 --echo will be applied.
1183 --echo
1184 --echo 3. On the Secondary, the observed sequence will be :
1185 --echo - Update 6 from PRIMARY : (Idempotent insert)
1186 --echo - Refresh (INS) 6 from PRIMARY
1187 --echo - Refresh (DEL) 7 from PRIMARY
1188 --echo Same epoch :
1189 --echo - Refresh (DEL) 8 from PRIMARY
1190 --echo Different epoch :
1191 --echo - Nothing
1192 --echo
1193 --echo Results (no divergence) :
1194 --echo Same epoch :
1195 --echo PRIMARY : 6
1196 --echo SECONDARY : 6
1197 --echo Diff epoch :
1198 --echo PRIMARY : 6,8
1199 --echo SECONDARY : 6,8
1200 --echo
1201 --echo
1202 --echo EPOCH_TRANS2
1203 --echo
1204 --echo 1. Conflict between Primary update to 6 + Secondary
1205 --echo [Delete of 6 + Insert of 7] is detected by Primary
1206 --echo and transaction is not applied at the Primary.
1207 --echo Rows 6 (INS) and 7 (DEL) are refreshed. Row 6 has its
1208 --echo epoch updated.
1209 --echo
1210 --echo 2. Following Secondary transaction [delete of 7 +
1211 --echo insert of 8] will conflict with the first
1212 --echo transaction as EPOCH_TRANS2 does not allow
1213 --echo a delete of an already deleted row.
1214 --echo Row 7 will be refreshed (DEL) and row 8 will be
1215 --echo refreshed (DEL)
1216 --echo
1217 --echo 3. On the Secondary, the observed sequence will be :
1218 --echo - Update 6 from PRIMARY : (Idempotent insert)
1219 --echo - Refresh (INS) 6 from PRIMARY
1220 --echo - Refresh (DEL) 7 from PRIMARY
1221 --echo - [Refresh (DEL) 7 from PRIMARY] - diff epoch
1222 --echo - Refresh (DEL) 8 from PRIMARY
1223 --echo
1224 --echo Results (no divergence) :
1225 --echo PRIMARY : 6
1226 --echo SECONDARY : 6
1227 --echo
1228
1229 #eval select $EPOCHS_EQUAL;
1230 #eval select $HAVE_EPOCH2;
1231
1232 --echo PRIMARY content
1233
1234 --disable_query_log
1235 --disable_result_log
1236 select @PrimaryRow6Present:=count(1) from test.t1 where a=6;
1237 select @PrimaryRow7Present:=count(1) from test.t1 where a=7;
1238 select @PrimaryRow8Present:=count(1) from test.t1 where a=8;
1239
1240 eval select @epoch_trans_same_epoch:=
1241 !$HAVE_EPOCH2 and
1242 $EPOCHS_EQUAL and
1243 @PrimaryRow6Present and
1244 !@PrimaryRow7Present and
1245 !@PrimaryRow8Present;
1246
1247 eval select @epoch_trans_diff_epoch:=
1248 !$HAVE_EPOCH2 and
1249 !$EPOCHS_EQUAL and
1250 @PrimaryRow6Present and
1251 !@PrimaryRow7Present and
1252 @PrimaryRow8Present;
1253
1254 eval select @epoch2_trans:=
1255 $HAVE_EPOCH2 and
1256 @PrimaryRow6Present and
1257 !@PrimaryRow7Present and
1258 !@PrimaryRow8Present;
1259 --enable_result_log
1260 --enable_query_log
1261
1262
1263 set @primary_ok:=
1264 ((@epoch_trans_same_epoch XOR
1265 @epoch_trans_diff_epoch) XOR
1266 @epoch2_trans);
1267
1268 select @primary_ok;
1269 let $primary_ok= query_get_value('select @primary_ok as v',v,1);
1270
1271 if (!$primary_ok)
1272 {
1273 echo Problem, dumping data;
1274 select * from test.t1;
1275 eval select $HAVE_EPOCH2 as have_epoch2;
1276 eval select $EPOCHS_EQUAL as epochs_equal;
1277 die Testcase problem;
1278 }
1279
1280 if ($HAVE_EPOCH2)
1281 {
1282 select * from test.t1 order by a;
1283 }
1284
1285 --echo Restart SECONDARY Slave
1286 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
1287 START SLAVE;
1288 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
1289
1290
1291 --echo Sync PRIMARY -> SECONDARY
1292
1293 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
1294 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
1295
1296 --echo SECONDARY content
1297
1298 --disable_query_log
1299 --disable_result_log
1300
1301 select @SecondaryRow6Present:=count(1) from test.t1 where a=6;
1302 select @SecondaryRow7Present:=count(1) from test.t1 where a=7;
1303 select @SecondaryRow8Present:=count(1) from test.t1 where a=8;
1304
1305 eval select @epoch_trans_same_epoch:=
1306 !$HAVE_EPOCH2 and
1307 $EPOCHS_EQUAL and
1308 @SecondaryRow6Present and
1309 !@SecondaryRow7Present and
1310 !@SecondaryRow8Present;
1311
1312 eval select @epoch_trans_diff_epoch:=
1313 !$HAVE_EPOCH2 and
1314 !$EPOCHS_EQUAL and
1315 @SecondaryRow6Present and
1316 !@SecondaryRow7Present and
1317 @SecondaryRow8Present;
1318
1319 eval select @epoch2_trans:=
1320 $HAVE_EPOCH2 and
1321 @SecondaryRow6Present and
1322 !@SecondaryRow7Present and
1323 !@SecondaryRow8Present;
1324
1325 --enable_result_log
1326 --enable_query_log
1327
1328 set @secondary_ok:=
1329 ((@epoch_trans_same_epoch XOR
1330 @epoch_trans_diff_epoch) XOR
1331 @epoch2_trans);
1332 select @secondary_ok;
1333
1334 let $secondary_ok= query_get_value('select @secondary_ok as v',v,1);
1335
1336 if (!$secondary_ok)
1337 {
1338 echo Problem, dumping data;
1339 select * from test.t1;
1340 eval select $HAVE_EPOCH2 as have_epoch2;
1341 eval select $EPOCHS_EQUAL as epochs_equal;
1342 die Testcase problem;
1343 }
1344
1345 if ($HAVE_EPOCH2)
1346 {
1347 select * from test.t1 order by a;
1348 }
1349
1350 --echo STABILISE
1351
1352 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
1353 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
1354 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
1355
1356
1357 # Cleanup
1358 --source suite/ndb_rpl/t/ndb_connect_to_primary.inc
1359 drop table mysql.ndb_replication;
1360 drop table test.t1;
1361 drop table test.t2;
1362
1363 --source suite/ndb_rpl/t/ndb_sync_primary_to_secondary.inc
1364 --source suite/ndb_rpl/t/ndb_connect_to_secondary.inc
1365 flush logs;
1366 --source suite/ndb_rpl/t/ndb_sync_secondary_to_primary.inc
1367
1368 --connection master
1369 stop slave;
1370 reset slave;
1371
1372 #change master to master_host='';
1373 --source include/rpl_end.inc
1374
1375 # TODO
1376 # More complex dependencies