| 1 |
# In this test we make sure that the slave does a recovery when the it is |
| 2 |
# brought up after it has stopped due to error in one or more of its workers. |
| 3 |
--source include/not_group_replication_plugin.inc |
| 4 |
-- source include/have_debug.inc |
| 5 |
-- source include/not_valgrind.inc |
| 6 |
# This test needs at least 3 MTA workers |
| 7 |
--let $option_name = replica_parallel_workers |
| 8 |
--let $option_operator = > |
| 9 |
--let $option_value = 2 |
| 10 |
--source include/only_with_option.inc |
| 11 |
--source include/only_mts_replica_parallel_type_logical_clock.inc |
| 12 |
-- source include/master-slave.inc |
| 13 |
|
| 14 |
--let $debug_point=set_commit_parent_100 |
| 15 |
--source include/add_debug_point.inc |
| 16 |
|
| 17 |
# set up the tables and replicate it to the slave. |
| 18 |
CREATE TABLE t1 (a int primary key) engine=innodb; |
| 19 |
CREATE TABLE t2 (a int primary key) engine=innodb; |
| 20 |
CREATE TABLE t3 (a int primary key) engine=innodb; |
| 21 |
CREATE TABLE t4 (a int primary key) engine=innodb; |
| 22 |
-- source include/sync_slave_sql_with_master.inc |
| 23 |
-- source include/stop_slave_sql.inc |
| 24 |
--let $debug_point=crash_in_a_worker |
| 25 |
--source include/add_debug_point.inc |
| 26 |
|
| 27 |
-- connection master |
| 28 |
--let $debug_point=set_commit_parent_100 |
| 29 |
--source include/remove_debug_point.inc |
| 30 |
--let $debug_point=set_commit_parent_150 |
| 31 |
--source include/add_debug_point.inc |
| 32 |
|
| 33 |
# execute transactions |
| 34 |
|
| 35 |
# trx1 should be applied and its worker released for receiving more work. |
| 36 |
# trx2 to trx5 are prepared in a way that they will be scheduled on the slave |
| 37 |
# but will not be applied. In order to have all four transactions scheduled, |
| 38 |
# the coordinator will have to distribute work by all four workers. The test |
| 39 |
# case expects the slave to crash after some workload be distributed to the |
| 40 |
# worker #2. |
| 41 |
|
| 42 |
# trx1 |
| 43 |
INSERT INTO t1 values (0); |
| 44 |
|
| 45 |
# trx2 should not complete on the slave. |
| 46 |
BEGIN; |
| 47 |
INSERT INTO t2 values (1),(2),(3); |
| 48 |
UPDATE t2 SET a= a+1 WHERE a=3; |
| 49 |
COMMIT; |
| 50 |
|
| 51 |
# trx3 should not complete on the slave. |
| 52 |
BEGIN; |
| 53 |
INSERT INTO t3 values (1),(2),(3); |
| 54 |
UPDATE t3 SET a= a+1 WHERE a=3; |
| 55 |
COMMIT; |
| 56 |
|
| 57 |
# trx4 should not complete on the slave. |
| 58 |
BEGIN; |
| 59 |
INSERT INTO t4 values (1),(2),(3); |
| 60 |
UPDATE t4 SET a= a+1 WHERE a=3; |
| 61 |
COMMIT; |
| 62 |
|
| 63 |
# trx5 should not complete on the slave. |
| 64 |
BEGIN; |
| 65 |
INSERT INTO t1 values (1),(2),(3); |
| 66 |
UPDATE t1 SET a= a+1 WHERE a=3; |
| 67 |
COMMIT; |
| 68 |
|
| 69 |
--let $debug_point=set_commit_parent_150 |
| 70 |
--source include/remove_debug_point.inc |
| 71 |
|
| 72 |
# Make sure the workload is already on the relay log before starting the |
| 73 |
# applier to avoid issues with slow systems. |
| 74 |
--source include/sync_slave_io_with_master.inc |
| 75 |
|
| 76 |
# This should prevent trx2 to trx5 from committing and will make all |
| 77 |
# four MTS workers to be busy regardless of server speed. |
| 78 |
--source include/rpl_connection_slave1.inc |
| 79 |
BEGIN; |
| 80 |
INSERT INTO t1 (a) VALUES (4); |
| 81 |
INSERT INTO t2 (a) VALUES (4); |
| 82 |
INSERT INTO t3 (a) VALUES (4); |
| 83 |
INSERT INTO t4 (a) VALUES (4); |
| 84 |
|
| 85 |
--source include/rpl_connection_slave.inc |
| 86 |
# make sure mtr expects a crash & restarts |
| 87 |
-- exec echo "wait" > $MYSQLTEST_VARDIR/tmp/mysqld.2.expect |
| 88 |
START SLAVE; |
| 89 |
-- source include/wait_until_disconnected.inc |
| 90 |
-- let $rpl_server_number= 2 |
| 91 |
-- source include/rpl_start_server.inc |
| 92 |
-- enable_reconnect |
| 93 |
-- echo # Reconnecting to the slave server |
| 94 |
-- source include/wait_until_connected_again.inc |
| 95 |
-- connection slave |
| 96 |
--disable_warnings |
| 97 |
START SLAVE UNTIL SQL_AFTER_MTS_GAPS; |
| 98 |
--enable_warnings |
| 99 |
|
| 100 |
# we need to send an additional event since the UNTIL CONDITION |
| 101 |
# needs an aditional event after the failed group to stop the slave |
| 102 |
# due to buf in until conditions |
| 103 |
-- connection master |
| 104 |
CREATE TABLE t5 (a int); |
| 105 |
|
| 106 |
-- connection slave |
| 107 |
-- source include/wait_for_slave_sql_to_stop.inc |
| 108 |
-- source include/start_slave.inc |
| 109 |
|
| 110 |
# cleanup |
| 111 |
-- connection master |
| 112 |
DROP TABLES t1, t2, t3, t4, t5; |
| 113 |
-- connection master |
| 114 |
-- source include/sync_slave_sql_with_master.inc |
| 115 |
-- source include/rpl_end.inc |
| 116 |
|