| 1 |
--source include/have_ndb.inc |
| 2 |
--source include/have_binlog_format_mixed_or_row.inc |
| 3 |
|
| 4 |
# Configure replication, don't start applier |
| 5 |
--let $rpl_skip_start_slave= 1 |
| 6 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 7 |
|
| 8 |
--echo # Generate epoch transactions without dependencies by using WRITESET |
| 9 |
--echo # dependency tracking |
| 10 |
show variables like 'binlog_transaction_dependency_tracking'; |
| 11 |
show variables like 'ndb_log_transaction_dependency'; |
| 12 |
|
| 13 |
create table t1 ( |
| 14 |
a int primary key, |
| 15 |
b varchar(100), |
| 16 |
c int) engine=ndb; |
| 17 |
|
| 18 |
# Initial row content |
| 19 |
insert into t1 values |
| 20 |
(1, "A", 0), |
| 21 |
(2, "A", 0), |
| 22 |
(3, "A", 0); |
| 23 |
|
| 24 |
--echo # Valid state after epoch 0 |
| 25 |
select * from t1 order by a; |
| 26 |
|
| 27 |
--source include/rpl_connection_slave.inc |
| 28 |
--echo # Relevant replica variables |
| 29 |
show variables like 'replica_parallel_workers'; |
| 30 |
show variables like 'log_bin'; |
| 31 |
show variables like 'log_replica_updates'; |
| 32 |
show variables like 'replica_preserve_commit_order'; |
| 33 |
|
| 34 |
--echo # Supress MTA errors generated by test |
| 35 |
call mtr.add_suppression(".*Could not execute Write_rows event.*"); |
| 36 |
call mtr.add_suppression(".*worker thread retried transaction 1 time.*"); |
| 37 |
call mtr.add_suppression(".*possibly leaving data in inconsistent state.*"); |
| 38 |
call mtr.add_suppression(".*worker has stopped after at least one previous worker encountered an error when replica-preserve-commit-order was enabled.*"); |
| 39 |
|
| 40 |
--source include/start_slave.inc |
| 41 |
|
| 42 |
--source include/rpl_connection_master.inc |
| 43 |
--source include/sync_slave_sql_with_master.inc |
| 44 |
|
| 45 |
--source include/stop_slave.inc |
| 46 |
|
| 47 |
# Both clusters have same initial 3 rows |
| 48 |
# Now define some independent transactions, allowing parallel apply |
| 49 |
# but still requiring commit order if specified. |
| 50 |
|
| 51 |
--source include/rpl_connection_master.inc |
| 52 |
|
| 53 |
--echo # Epoch 1 |
| 54 |
update t1 set b="B", c=1 where a=1; |
| 55 |
--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 56 |
|
| 57 |
--echo # Valid state after epoch 1 |
| 58 |
select * from t1 order by a; |
| 59 |
|
| 60 |
--echo # Epoch 2 |
| 61 |
begin; |
| 62 |
update t1 set b="C", c=2 where a=2; |
| 63 |
commit; |
| 64 |
|
| 65 |
--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 66 |
|
| 67 |
--echo # Valid state after epoch 2 |
| 68 |
select * from t1 order by a; |
| 69 |
|
| 70 |
--echo # Epoch 3 |
| 71 |
update t1 set b="D", c=3 where a=3; |
| 72 |
|
| 73 |
--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 74 |
|
| 75 |
--echo # Valid state after epoch 3 |
| 76 |
select * from t1 order by a; |
| 77 |
|
| 78 |
#show binlog events; |
| 79 |
|
| 80 |
--echo # Take a row lock on row 2 on one connection to the replica |
| 81 |
--echo # This stops epoch 2 from finishing its prepare, and |
| 82 |
--echo # therefore it will be unable to commit. |
| 83 |
--echo # With commit ordering on, epoch 3 will not be able to commit |
| 84 |
--echo # and will not become visible. |
| 85 |
|
| 86 |
--source include/rpl_connection_slave1.inc |
| 87 |
|
| 88 |
begin; |
| 89 |
select * from t1 where a=2 for update; |
| 90 |
|
| 91 |
|
| 92 |
--echo # Start the replica from the other replica connection |
| 93 |
--source include/rpl_connection_slave.inc |
| 94 |
--source include/start_slave.inc |
| 95 |
|
| 96 |
--echo # Row lock should stall epoch 2, and hence also |
| 97 |
--echo # the independent epoch 3. |
| 98 |
--echo # Check that no sign of epoch 3 can be seen while the |
| 99 |
--echo # row lock is held. |
| 100 |
--echo # This also stall the replica long enough to fail the transaction |
| 101 |
--echo # being applied and thus replication will stop. |
| 102 |
let $ct=20; |
| 103 |
while ($ct) |
| 104 |
{ |
| 105 |
if (`select count(1) as c from test.t1 where c=3`) |
| 106 |
{ |
| 107 |
--echo FAIL : Epoch 3 committed while Epoch 2 not applicable! |
| 108 |
select * from test.t1 order by a; |
| 109 |
# Will cause result-content mismatch |
| 110 |
} |
| 111 |
sleep 0.5; |
| 112 |
dec $ct; |
| 113 |
} |
| 114 |
|
| 115 |
--echo # Expect that only epoch 1 successfully applied. |
| 116 |
select * from test.t1 order by a; |
| 117 |
|
| 118 |
--echo # Now cleanup |
| 119 |
|
| 120 |
--source include/rpl_connection_slave1.inc |
| 121 |
--echo # Release lock |
| 122 |
commit; |
| 123 |
|
| 124 |
--source include/rpl_connection_slave.inc |
| 125 |
|
| 126 |
--echo # Wait for replication error |
| 127 |
let $slave_sql_errno= 3030; |
| 128 |
--source include/wait_for_slave_sql_error.inc |
| 129 |
|
| 130 |
--echo # Show the error number after failure |
| 131 |
query_vertical |
| 132 |
SELECT LAST_ERROR_NUMBER |
| 133 |
FROM performance_schema.replication_applier_status_by_worker |
| 134 |
WHERE LAST_ERROR_NUMBER != 0; |
| 135 |
--echo # Show the coordinator error number and message |
| 136 |
--replace_regex /end_log_pos [0-9]*/end_log_pos NNN/ /Worker [0-9]* failed/Worker NNN failed/ |
| 137 |
query_vertical |
| 138 |
SELECT LAST_ERROR_NUMBER, LAST_ERROR_MESSAGE |
| 139 |
FROM performance_schema.replication_applier_status_by_coordinator; |
| 140 |
|
| 141 |
--echo # Start replication again |
| 142 |
--source include/start_slave.inc |
| 143 |
|
| 144 |
--echo # Resync |
| 145 |
--source include/rpl_connection_master.inc |
| 146 |
--sync_slave_with_master |
| 147 |
|
| 148 |
--echo # Show resynced |
| 149 |
select * from test.t1 order by a; |
| 150 |
|
| 151 |
--source include/rpl_connection_master.inc |
| 152 |
--echo # Drop table |
| 153 |
drop table test.t1; |
| 154 |
|
| 155 |
--source include/rpl_end.inc |