| 1 |
--source include/not_group_replication_plugin.inc |
| 2 |
--source include/have_debug.inc |
| 3 |
--source include/master-slave.inc |
| 4 |
################################################################################ |
| 5 |
# Bug#18363515 MULTIPLE THREADED SLAVE MAY BE CRASHED BY STOP SLAVE SQL |
| 6 |
# |
| 7 |
# Worker error will crash MTS if coordinator is waiting for a free worker to |
| 8 |
# dispatch next event. The crash happens because the caller of |
| 9 |
# Mts_submode_logical_clock::get_least_occupied_worker() supposes it always |
| 10 |
# return a valid worker. But that is not true. It may turn NULL when |
| 11 |
# coordinator is aborted at the same time seeing a Worker has failed. |
| 12 |
################################################################################ |
| 13 |
CREATE TABLE t1(c1 INT PRIMARY KEY) ENGINE = InnoDB; |
| 14 |
CREATE TABLE t2(c1 INT PRIMARY KEY) ENGINE = InnoDB; |
| 15 |
--source include/sync_slave_sql_with_master.inc |
| 16 |
--source include/stop_slave_sql.inc |
| 17 |
|
| 18 |
--source include/rpl_connection_master.inc |
| 19 |
SET @save_debug = @@GLOBAL.debug; |
| 20 |
|
| 21 |
# make the following transactions to have a common commit parent |
| 22 |
# so be parallelizable on slave. |
| 23 |
SET GLOBAL debug = "+d,set_commit_parent_100"; |
| 24 |
|
| 25 |
INSERT INTO t2 VALUES(99); # just a warmup load |
| 26 |
BEGIN; |
| 27 |
INSERT INTO t1 VALUES(1); |
| 28 |
INSERT INTO t1 VALUES(2); |
| 29 |
COMMIT; |
| 30 |
|
| 31 |
BEGIN; |
| 32 |
INSERT INTO t1 VALUES(3); |
| 33 |
INSERT INTO t1 VALUES(4); |
| 34 |
COMMIT; |
| 35 |
# This one will force coordinator to wait for a free worker. |
| 36 |
INSERT INTO t1 VALUES(5); |
| 37 |
|
| 38 |
SET GLOBAL debug = @save_debug; |
| 39 |
--source include/save_master_pos.inc |
| 40 |
|
| 41 |
--source include/rpl_connection_slave.inc |
| 42 |
SET @save_replica_parallel_type = @@GLOBAL.replica_parallel_type; |
| 43 |
SET @save_replica_parallel_workers = @@GLOBAL.replica_parallel_workers; |
| 44 |
SET @save_replica_transaction_retries = @@GLOBAL.replica_transaction_retries; |
| 45 |
|
| 46 |
SET GLOBAL replica_parallel_type = LOGICAL_CLOCK; |
| 47 |
SET GLOBAL replica_parallel_workers = 2; |
| 48 |
SET GLOBAL replica_transaction_retries = 0; |
| 49 |
|
| 50 |
# Inserts an offending row into slave's db. A worker will fail with |
| 51 |
# the duplicate key error when applying master's transaction. |
| 52 |
INSERT INTO t1 VALUES(1); |
| 53 |
|
| 54 |
CALL mtr.add_suppression("Worker . Failed executing transaction.*"); |
| 55 |
CALL mtr.add_suppression(".*coordinator and worker threads are stopped.*"); |
| 56 |
|
| 57 |
# Block workers and make coordinator to wait for a free worker |
| 58 |
LOCK TABLE t1 WRITE; |
| 59 |
|
| 60 |
--let $rpl_connection_name= server_2 |
| 61 |
--source include/rpl_connection.inc |
| 62 |
--source include/sync_slave_io.inc |
| 63 |
--source include/start_slave_sql.inc |
| 64 |
|
| 65 |
# Wait until coordinator already dispatches events to both workers. |
| 66 |
--let $show_statement= SHOW PROCESSLIST |
| 67 |
--let $field= State |
| 68 |
--let $condition= = 'Waiting for table metadata lock' |
| 69 |
--source include/wait_show_condition.inc |
| 70 |
|
| 71 |
# Wait unti coordinator enters the wait status. |
| 72 |
--let $show_statement= SHOW PROCESSLIST |
| 73 |
--let $field= State |
| 74 |
--let $condition= = 'Waiting for replica workers to process their queues' |
| 75 |
--source include/wait_show_condition.inc |
| 76 |
|
| 77 |
# Release metadata lock on t1, so workers can go ahead. |
| 78 |
--source include/rpl_connection_slave.inc |
| 79 |
UNLOCK TABLES; |
| 80 |
|
| 81 |
# Workers encounter duplicate error(ER_DUP_ENTRY), rollback signalled |
| 82 |
# (ER_REPLICA_WORKER_STOPPED_PREVIOUS_THD_ERROR) and abort coordinator |
| 83 |
--let $slave_sql_errno=1062,3030 |
| 84 |
--source include/wait_for_slave_sql_to_stop.inc |
| 85 |
|
| 86 |
--disable_warnings |
| 87 |
SET GLOBAL replica_parallel_workers = @save_replica_parallel_workers; |
| 88 |
--enable_warnings |
| 89 |
SET GLOBAL replica_parallel_type = @save_replica_parallel_type; |
| 90 |
SET GLOBAL replica_transaction_retries = @save_replica_transaction_retries; |
| 91 |
# Remove the duplicate key from slave's db. |
| 92 |
TRUNCATE t1; |
| 93 |
--source include/start_slave_sql.inc |
| 94 |
|
| 95 |
--source include/rpl_connection_master.inc |
| 96 |
DROP TABLE t1; |
| 97 |
DROP TABLE t2; |
| 98 |
--source include/rpl_end.inc |