|
| 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(".*possibly leaving data in inconsistent state.*"); |
| 37 | +call mtr.add_suppression(".*worker has stopped after at least one previous worker encountered an error when replica-preserve-commit-order was enabled.*"); |
| 38 | + |
| 39 | +--source include/start_slave.inc |
| 40 | + |
| 41 | +--source include/rpl_connection_master.inc |
| 42 | +--source include/sync_slave_sql_with_master.inc |
| 43 | + |
| 44 | +--source include/stop_slave.inc |
| 45 | + |
| 46 | +# Both clusters have same initial 3 rows |
| 47 | +# Now define some independent transactions, allowing parallel apply |
| 48 | +# but still requiring commit order if specified. |
| 49 | + |
| 50 | +--source include/rpl_connection_master.inc |
| 51 | + |
| 52 | +--echo # Epoch 1 |
| 53 | +update t1 set b="B", c=1 where a=1; |
| 54 | +--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 55 | + |
| 56 | +--echo # Valid state after epoch 1 |
| 57 | +select * from t1 order by a; |
| 58 | + |
| 59 | +--echo # Epoch 2 |
| 60 | +begin; |
| 61 | +update t1 set b="C", c=2 where a=2; |
| 62 | +commit; |
| 63 | + |
| 64 | +--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 65 | + |
| 66 | +--echo # Valid state after epoch 2 |
| 67 | +select * from t1 order by a; |
| 68 | + |
| 69 | +--echo # Epoch 3 |
| 70 | +update t1 set b="D", c=3 where a=3; |
| 71 | + |
| 72 | +--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 73 | + |
| 74 | +--echo # Valid state after epoch 3 |
| 75 | +select * from t1 order by a; |
| 76 | + |
| 77 | +#show binlog events; |
| 78 | + |
| 79 | +--echo # Take a row lock on row 2 on one connection to the replica |
| 80 | +--echo # This stops epoch 2 from finishing its prepare, and |
| 81 | +--echo # therefore it will be unable to commit. |
| 82 | +--echo # With commit ordering on, epoch 3 will not be able to commit |
| 83 | +--echo # and will not become visible. |
| 84 | + |
| 85 | +--source include/rpl_connection_slave1.inc |
| 86 | + |
| 87 | +begin; |
| 88 | +select * from t1 where a=2 for update; |
| 89 | + |
| 90 | + |
| 91 | +--echo # Start the replica from the other replica connection |
| 92 | +--source include/rpl_connection_slave.inc |
| 93 | +--source include/start_slave.inc |
| 94 | + |
| 95 | +--echo # Row lock should stall epoch 2, and hence also |
| 96 | +--echo # the independent epoch 3. |
| 97 | +--echo # Check that no sign of epoch 3 can be seen while the |
| 98 | +--echo # row lock is held. |
| 99 | +--echo # This also stall the replica long enough to fail the transaction |
| 100 | +--echo # being applied and thus replication will stop. |
| 101 | +let $ct=20; |
| 102 | +while ($ct) |
| 103 | +{ |
| 104 | + if (`select count(1) as c from test.t1 where c=3`) |
| 105 | + { |
| 106 | + --echo FAIL : Epoch 3 committed while Epoch 2 not applicable! |
| 107 | + select * from test.t1 order by a; |
| 108 | + # Will cause result-content mismatch |
| 109 | + } |
| 110 | + sleep 0.5; |
| 111 | + dec $ct; |
| 112 | +} |
| 113 | + |
| 114 | +--echo # Expect that only epoch 1 successfully applied. |
| 115 | +select * from test.t1 order by a; |
| 116 | + |
| 117 | +--echo # Now cleanup |
| 118 | + |
| 119 | +--source include/rpl_connection_slave1.inc |
| 120 | +--echo # Release lock |
| 121 | +commit; |
| 122 | + |
| 123 | +--source include/rpl_connection_slave.inc |
| 124 | + |
| 125 | +--echo # Wait for replication error |
| 126 | +let $slave_sql_errno= 3030; |
| 127 | +--source include/wait_for_slave_sql_error.inc |
| 128 | + |
| 129 | +--echo # Show the error number and message after failure |
| 130 | +--replace_regex /end_log_pos [0-9]*/end_log_pos NNN/ |
| 131 | +query_vertical |
| 132 | + SELECT WORKER_ID, LAST_ERROR_NUMBER, LAST_ERROR_MESSAGE |
| 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/ |
| 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 |
0 commit comments