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