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
|
--source include/not_group_replication_plugin.inc
--source include/have_debug.inc
--source include/master-slave.inc
################################################################################
# Bug#18363515 MULTIPLE THREADED SLAVE MAY BE CRASHED BY STOP SLAVE SQL
#
# Worker error will crash MTS if coordinator is waiting for a free worker to
# dispatch next event. The crash happens because the caller of
# Mts_submode_logical_clock::get_least_occupied_worker() supposes it always
# return a valid worker. But that is not true. It may turn NULL when
# coordinator is aborted at the same time seeing a Worker has failed.
################################################################################
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE = InnoDB;
CREATE TABLE t2(c1 INT PRIMARY KEY) ENGINE = InnoDB;
--source include/sync_slave_sql_with_master.inc
--source include/stop_slave_sql.inc
--source include/rpl_connection_master.inc
SET @save_debug = @@GLOBAL.debug;
# make the following transactions to have a common commit parent
# so be parallelizable on slave.
SET GLOBAL debug = "+d,set_commit_parent_100";
INSERT INTO t2 VALUES(99); # just a warmup load
BEGIN;
INSERT INTO t1 VALUES(1);
INSERT INTO t1 VALUES(2);
COMMIT;
BEGIN;
INSERT INTO t1 VALUES(3);
INSERT INTO t1 VALUES(4);
COMMIT;
# This one will force coordinator to wait for a free worker.
INSERT INTO t1 VALUES(5);
SET GLOBAL debug = @save_debug;
--source include/save_master_pos.inc
--source include/rpl_connection_slave.inc
SET @save_replica_parallel_type = @@GLOBAL.replica_parallel_type;
SET @save_replica_parallel_workers = @@GLOBAL.replica_parallel_workers;
SET @save_replica_transaction_retries = @@GLOBAL.replica_transaction_retries;
SET GLOBAL replica_parallel_type = LOGICAL_CLOCK;
SET GLOBAL replica_parallel_workers = 2;
SET GLOBAL replica_transaction_retries = 0;
# Inserts an offending row into slave's db. A worker will fail with
# the duplicate key error when applying master's transaction.
INSERT INTO t1 VALUES(1);
CALL mtr.add_suppression("Worker . Failed executing transaction.*");
CALL mtr.add_suppression(".*coordinator and worker threads are stopped.*");
# Block workers and make coordinator to wait for a free worker
LOCK TABLE t1 WRITE;
--let $rpl_connection_name= server_2
--source include/rpl_connection.inc
--source include/sync_slave_io.inc
--source include/start_slave_sql.inc
# Wait until coordinator already dispatches events to both workers.
--let $show_statement= SHOW PROCESSLIST
--let $field= State
--let $condition= = 'Waiting for table metadata lock'
--source include/wait_show_condition.inc
# Wait unti coordinator enters the wait status.
--let $show_statement= SHOW PROCESSLIST
--let $field= State
--let $condition= = 'Waiting for replica workers to process their queues'
--source include/wait_show_condition.inc
# Release metadata lock on t1, so workers can go ahead.
--source include/rpl_connection_slave.inc
UNLOCK TABLES;
# Workers encounter duplicate error(ER_DUP_ENTRY), rollback signalled
# (ER_REPLICA_WORKER_STOPPED_PREVIOUS_THD_ERROR) and abort coordinator
--let $slave_sql_errno=1062,3030
--source include/wait_for_slave_sql_to_stop.inc
--disable_warnings
SET GLOBAL replica_parallel_workers = @save_replica_parallel_workers;
--enable_warnings
SET GLOBAL replica_parallel_type = @save_replica_parallel_type;
SET GLOBAL replica_transaction_retries = @save_replica_transaction_retries;
# Remove the duplicate key from slave's db.
TRUNCATE t1;
--source include/start_slave_sql.inc
--source include/rpl_connection_master.inc
DROP TABLE t1;
DROP TABLE t2;
--source include/rpl_end.inc
|