| 1 |
--source include/have_debug.inc |
| 2 |
--source include/have_ndb.inc |
| 3 |
--source include/have_binlog_format_mixed_or_row.inc |
| 4 |
|
| 5 |
--echo # |
| 6 |
--echo # Test replicas ability to retry when failure occurs to open |
| 7 |
--echo # table due to "table definition changed". |
| 8 |
--echo # This is done by introducing an artifical error every second time the |
| 9 |
--echo # replica attempts to open a table while applying a row change, the |
| 10 |
--echo # replica will then back off and retry according to its transaction |
| 11 |
--echo # retry settings. |
| 12 |
--echo # |
| 13 |
|
| 14 |
# Configure replication and start replicating |
| 15 |
--source suite/ndb_rpl/ndb_master-slave.inc |
| 16 |
|
| 17 |
CREATE TABLE t1 ( |
| 18 |
a INT PRIMARY KEY, |
| 19 |
b VARCHAR(32) |
| 20 |
) engine=ndb; |
| 21 |
|
| 22 |
--source include/sync_slave_sql_with_master.inc |
| 23 |
|
| 24 |
# Suppress warnings generated by the failures to open |
| 25 |
--disable_query_log ONCE |
| 26 |
call mtr.add_suppression("Table definition has changed, please retry transaction"); |
| 27 |
|
| 28 |
# Setup replica to fail open table every second time when |
| 29 |
# in a transaction (which it is when applying row changes) |
| 30 |
--let $debug_point= ndb_replica_change_t1_version |
| 31 |
--let $debug_type= GLOBAL |
| 32 |
--source include/add_debug_point.inc |
| 33 |
|
| 34 |
# Add changes to replicate one by one and restart replica between each in |
| 35 |
# order to get new failure. In total there should be at least 8 lines |
| 36 |
# saying "Table definition has changed..." in the replica server log file. |
| 37 |
|
| 38 |
--echo # Case 1. insert |
| 39 |
--source include/rpl_connection_master.inc |
| 40 |
INSERT INTO t1 VALUES (1, "row 1"), (2, "row 2"), |
| 41 |
(3, "row 3"), (4, "row 4"), (5, "row 5"); |
| 42 |
--source include/sync_slave_sql_with_master.inc |
| 43 |
|
| 44 |
# Sync, stop and start replica again |
| 45 |
--source include/rpl_stop_slaves.inc |
| 46 |
--source include/rpl_start_slaves.inc |
| 47 |
|
| 48 |
--echo # Case 2. 2 update transactions |
| 49 |
--source include/rpl_connection_master.inc |
| 50 |
UPDATE t1 SET b = "row 2 updated" WHERE a = 2; |
| 51 |
--source suite/ndb/include/ndb_binlog_wait_own_changes.inc |
| 52 |
UPDATE t1 SET b = "row 4 updated" WHERE a = 4; |
| 53 |
--source include/sync_slave_sql_with_master.inc |
| 54 |
|
| 55 |
# Sync, stop and start replica again |
| 56 |
--source include/rpl_stop_slaves.inc |
| 57 |
--source include/rpl_start_slaves.inc |
| 58 |
|
| 59 |
--echo # Case 3. delete |
| 60 |
--source include/rpl_connection_master.inc |
| 61 |
DELETE FROM t1 WHERE a = 5; |
| 62 |
--source include/sync_slave_sql_with_master.inc |
| 63 |
|
| 64 |
# Sync, stop and start replica again |
| 65 |
--source include/rpl_stop_slaves.inc |
| 66 |
--source include/rpl_start_slaves.inc |
| 67 |
|
| 68 |
--echo # Case 4. transaction with more than one change |
| 69 |
--source include/rpl_connection_master.inc |
| 70 |
BEGIN; |
| 71 |
UPDATE t1 SET b = "row 3 updated in trans" WHERE a = 3; |
| 72 |
INSERT INTO t1 VALUES (6, "row 6 inserted in trans"); |
| 73 |
COMMIT; |
| 74 |
--source include/sync_slave_sql_with_master.inc |
| 75 |
|
| 76 |
# Sync, stop and start replica again |
| 77 |
--source include/rpl_stop_slaves.inc |
| 78 |
--source include/rpl_start_slaves.inc |
| 79 |
|
| 80 |
--echo # Case 5. alter, not in trans and thus unaffected |
| 81 |
--source include/rpl_connection_master.inc |
| 82 |
ALTER TABLE t1 ADD c INT; |
| 83 |
|
| 84 |
--source include/sync_slave_sql_with_master.inc |
| 85 |
SELECT * FROM t1 ORDER BY a; |
| 86 |
|
| 87 |
--source include/remove_debug_point.inc |
| 88 |
|
| 89 |
# Cleanup |
| 90 |
--source include/rpl_connection_master.inc |
| 91 |
DROP TABLE t1; |
| 92 |
--source include/sync_slave_sql_with_master.inc |
| 93 |
|
| 94 |
--source include/rpl_end.inc |