| 1 |
# |
| 2 |
# Test that in MSR+MTS setup, a worker retries a transaction |
| 3 |
# for a channel |
| 4 |
# Idea of the test: |
| 5 |
# 1. setup a named replication channel to a master |
| 6 |
# 2. Lock the tables on a slave |
| 7 |
# 3. Replicate the data to the same table |
| 8 |
# 4. See that the worker retries transaction and transaction retry count |
| 9 |
# is increased. |
| 10 |
# 5. Do Roll back on the slave. |
| 11 |
# 6. Check that data on the master and slave is same as retry of the |
| 12 |
# transaction this time will be succesful |
| 13 |
# |
| 14 |
|
| 15 |
--source include/not_group_replication_plugin.inc |
| 16 |
# Test requires master-info-repository=TABLE, relay-log-info-repository=TABLE |
| 17 |
--source include/have_slave_repository_type_table.inc |
| 18 |
--source include/only_mts_replica_parallel_workers.inc |
| 19 |
|
| 20 |
--echo # Create channel_1 to server_1 from server_2(slave) |
| 21 |
--let $rpl_topology= 1->2 |
| 22 |
--let $rpl_multi_source =1 |
| 23 |
--source include/rpl_init.inc |
| 24 |
|
| 25 |
--echo # |
| 26 |
--echo # Insert data on the master |
| 27 |
--echo # |
| 28 |
--let $rpl_connection_name= server_1 |
| 29 |
--source include/rpl_connection.inc |
| 30 |
CREATE TABLE t1( a int unique); |
| 31 |
|
| 32 |
--echo # sync data to the slave |
| 33 |
--let $rpl_connection_name= server_1 |
| 34 |
--source include/rpl_connection.inc |
| 35 |
--let $rpl_channel_name= 'channel_1' |
| 36 |
--let $sync_slave_connection= server_2 |
| 37 |
--source include/sync_slave_sql_with_master.inc |
| 38 |
|
| 39 |
--echo # stop slave |
| 40 |
--source include/rpl_stop_slaves.inc |
| 41 |
|
| 42 |
# Backup the original value of the variables |
| 43 |
SET @saved_innodb_lock_wait_timeout = @@GLOBAL.innodb_lock_wait_timeout; |
| 44 |
SET @saved_replica_transaction_retries = @@GLOBAL.replica_transaction_retries; |
| 45 |
|
| 46 |
--echo # |
| 47 |
--echo # Set the variables needed for this test |
| 48 |
--echo # |
| 49 |
SET GLOBAL replica_transaction_retries=10; |
| 50 |
SET GLOBAL innodb_lock_wait_timeout=2; |
| 51 |
|
| 52 |
--echo #start slave |
| 53 |
--source include/rpl_start_slaves.inc |
| 54 |
|
| 55 |
--echo # |
| 56 |
--echo # Lock the rows of the table t1 |
| 57 |
--echo # |
| 58 |
BEGIN; |
| 59 |
INSERT INTO t1 VALUES(1); |
| 60 |
|
| 61 |
|
| 62 |
--echo # |
| 63 |
--echo # Insert the rows on the same table on master |
| 64 |
--echo # |
| 65 |
--let $rpl_connection_name= server_1 |
| 66 |
--source include/rpl_connection.inc |
| 67 |
INSERT INTO t1 VALUES(1); |
| 68 |
|
| 69 |
--echo # |
| 70 |
--echo # On slave, check that this transaction from the master has been retried. |
| 71 |
--echo # |
| 72 |
--let $rpl_connection_name= server_2 |
| 73 |
--source include/rpl_connection.inc |
| 74 |
|
| 75 |
--let $wait_timeout=60 |
| 76 |
--let $wait_condition= SELECT COUNT_TRANSACTIONS_RETRIES>=2 FROM performance_schema.replication_applier_status WHERE channel_name="channel_1"; |
| 77 |
--source include/wait_condition.inc |
| 78 |
|
| 79 |
--echo # Release the lock. |
| 80 |
ROLLBACK; |
| 81 |
|
| 82 |
--echo # Now sync with master on channel_1 |
| 83 |
--let $rpl_connection_name= server_1 |
| 84 |
--source include/rpl_connection.inc |
| 85 |
--let $rpl_channel_name= 'channel_1' |
| 86 |
--let $sync_slave_connection= server_2 |
| 87 |
--source include/sync_slave_sql_with_master.inc |
| 88 |
|
| 89 |
--echo # check that data shows the value 1 |
| 90 |
SELECT * FROM t1; |
| 91 |
|
| 92 |
--echo #cleanup |
| 93 |
--let $rpl_connection_name= server_1 |
| 94 |
--source include/rpl_connection.inc |
| 95 |
DROP TABLE t1; |
| 96 |
--let $rpl_channel_name= 'channel_1' |
| 97 |
--let $sync_slave_connection= server_2 |
| 98 |
--source include/sync_slave_sql_with_master.inc |
| 99 |
|
| 100 |
# restore the old values |
| 101 |
|
| 102 |
SET GLOBAL innodb_lock_wait_timeout = @saved_innodb_lock_wait_timeout; |
| 103 |
SET GLOBAL replica_transaction_retries = @saved_replica_transaction_retries; |
| 104 |
|
| 105 |
--let $rpl_skip_sync=1 |
| 106 |
--source include/rpl_end.inc |