| 1 |
include/master-slave.inc |
| 2 |
Warnings: |
| 3 |
Note #### Sending passwords in plain text without SSL/TLS is extremely insecure. |
| 4 |
Note #### Storing MySQL user name or password information in the connection metadata repository is not secure and is therefore not recommended. Please consider using the USER and PASSWORD connection options for START REPLICA; see the 'START REPLICA Syntax' in the MySQL Manual for more information. |
| 5 |
[connection master] |
| 6 |
# Generate epoch transactions without dependencies by using WRITESET |
| 7 |
# dependency tracking |
| 8 |
show variables like 'binlog_transaction_dependency_tracking'; |
| 9 |
Variable_name Value |
| 10 |
binlog_transaction_dependency_tracking WRITESET |
| 11 |
show variables like 'ndb_log_transaction_dependency'; |
| 12 |
Variable_name Value |
| 13 |
ndb_log_transaction_dependency ON |
| 14 |
create table t1 ( |
| 15 |
a int primary key, |
| 16 |
b varchar(100), |
| 17 |
c int) engine=ndb; |
| 18 |
insert into t1 values |
| 19 |
(1, "A", 0), |
| 20 |
(2, "A", 0), |
| 21 |
(3, "A", 0); |
| 22 |
# Valid state after epoch 0 |
| 23 |
select * from t1 order by a; |
| 24 |
a b c |
| 25 |
1 A 0 |
| 26 |
2 A 0 |
| 27 |
3 A 0 |
| 28 |
[connection slave] |
| 29 |
# Relevant replica variables |
| 30 |
show variables like 'replica_parallel_workers'; |
| 31 |
Variable_name Value |
| 32 |
replica_parallel_workers 10 |
| 33 |
show variables like 'log_bin'; |
| 34 |
Variable_name Value |
| 35 |
log_bin ON |
| 36 |
show variables like 'log_replica_updates'; |
| 37 |
Variable_name Value |
| 38 |
log_replica_updates ON |
| 39 |
show variables like 'replica_preserve_commit_order'; |
| 40 |
Variable_name Value |
| 41 |
replica_preserve_commit_order ON |
| 42 |
# Supress MTA errors generated by test |
| 43 |
call mtr.add_suppression(".*Could not execute Write_rows event.*"); |
| 44 |
call mtr.add_suppression(".*worker thread retried transaction 1 time.*"); |
| 45 |
call mtr.add_suppression(".*possibly leaving data in inconsistent state.*"); |
| 46 |
call mtr.add_suppression(".*worker has stopped after at least one previous worker encountered an error when replica-preserve-commit-order was enabled.*"); |
| 47 |
include/start_slave.inc |
| 48 |
[connection master] |
| 49 |
include/sync_slave_sql_with_master.inc |
| 50 |
include/stop_slave.inc |
| 51 |
[connection master] |
| 52 |
# Epoch 1 |
| 53 |
update t1 set b="B", c=1 where a=1; |
| 54 |
# Wait for ndb_binlog thread... |
| 55 |
# Valid state after epoch 1 |
| 56 |
select * from t1 order by a; |
| 57 |
a b c |
| 58 |
1 B 1 |
| 59 |
2 A 0 |
| 60 |
3 A 0 |
| 61 |
# Epoch 2 |
| 62 |
begin; |
| 63 |
update t1 set b="C", c=2 where a=2; |
| 64 |
commit; |
| 65 |
# Wait for ndb_binlog thread... |
| 66 |
# Valid state after epoch 2 |
| 67 |
select * from t1 order by a; |
| 68 |
a b c |
| 69 |
1 B 1 |
| 70 |
2 C 2 |
| 71 |
3 A 0 |
| 72 |
# Epoch 3 |
| 73 |
update t1 set b="D", c=3 where a=3; |
| 74 |
# Wait for ndb_binlog thread... |
| 75 |
# Valid state after epoch 3 |
| 76 |
select * from t1 order by a; |
| 77 |
a b c |
| 78 |
1 B 1 |
| 79 |
2 C 2 |
| 80 |
3 D 3 |
| 81 |
# Take a row lock on row 2 on one connection to the replica |
| 82 |
# This stops epoch 2 from finishing its prepare, and |
| 83 |
# therefore it will be unable to commit. |
| 84 |
# With commit ordering on, epoch 3 will not be able to commit |
| 85 |
# and will not become visible. |
| 86 |
[connection slave1] |
| 87 |
begin; |
| 88 |
select * from t1 where a=2 for update; |
| 89 |
a b c |
| 90 |
2 A 0 |
| 91 |
# Start the replica from the other replica connection |
| 92 |
[connection slave] |
| 93 |
include/start_slave.inc |
| 94 |
# Row lock should stall epoch 2, and hence also |
| 95 |
# the independent epoch 3. |
| 96 |
# Check that no sign of epoch 3 can be seen while the |
| 97 |
# row lock is held. |
| 98 |
# This also stall the replica long enough to fail the transaction |
| 99 |
# being applied and thus replication will stop. |
| 100 |
# Expect that only epoch 1 successfully applied. |
| 101 |
select * from test.t1 order by a; |
| 102 |
a b c |
| 103 |
1 B 1 |
| 104 |
2 A 0 |
| 105 |
3 A 0 |
| 106 |
# Now cleanup |
| 107 |
[connection slave1] |
| 108 |
# Release lock |
| 109 |
commit; |
| 110 |
[connection slave] |
| 111 |
# Wait for replication error |
| 112 |
include/wait_for_slave_sql_error.inc [errno=3030] |
| 113 |
# Show the error number after failure |
| 114 |
SELECT LAST_ERROR_NUMBER |
| 115 |
FROM performance_schema.replication_applier_status_by_worker |
| 116 |
WHERE LAST_ERROR_NUMBER != 0; |
| 117 |
LAST_ERROR_NUMBER 1205 |
| 118 |
LAST_ERROR_NUMBER 3030 |
| 119 |
# Show the coordinator error number and message |
| 120 |
SELECT LAST_ERROR_NUMBER, LAST_ERROR_MESSAGE |
| 121 |
FROM performance_schema.replication_applier_status_by_coordinator; |
| 122 |
LAST_ERROR_NUMBER 3030 |
| 123 |
LAST_ERROR_MESSAGE Coordinator stopped because there were error(s) in the worker(s). The most recent failure being: Worker NNN failed executing transaction 'ANONYMOUS' at source log master-bin.000001, end_log_pos NNN. See error log and/or performance_schema.replication_applier_status_by_worker table for more details about this failure or others, if any. |
| 124 |
# Start replication again |
| 125 |
include/start_slave.inc |
| 126 |
# Resync |
| 127 |
[connection master] |
| 128 |
# Show resynced |
| 129 |
select * from test.t1 order by a; |
| 130 |
a b c |
| 131 |
1 B 1 |
| 132 |
2 C 2 |
| 133 |
3 D 3 |
| 134 |
[connection master] |
| 135 |
# Drop table |
| 136 |
drop table test.t1; |
| 137 |
include/rpl_end.inc |