Skip to content

Commit fb774eb

Browse files
committed
Fix occasional test failure of rpl.rpl_parallel_stop_slave
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
1 parent 7f498fb commit fb774eb

File tree

3 files changed

+28
-3
lines changed

3 files changed

+28
-3
lines changed

mysql-test/suite/binlog_encryption/rpl_parallel_stop_slave.result

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ connection con_temp1;
3535
BEGIN;
3636
INSERT INTO t2 VALUES (21);
3737
connection server_2;
38-
START SLAVE;
38+
START SLAVE IO_THREAD;
39+
include/wait_for_slave_param.inc [Read_Master_Log_Pos]
40+
START SLAVE SQL_THREAD;
3941
connection con_temp2;
4042
SET @old_dbug= @@GLOBAL.debug_dbug;
4143
SET GLOBAL debug_dbug="+d,rpl_parallel_wait_for_done_trigger";

mysql-test/suite/rpl/r/rpl_parallel_stop_slave.result

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,9 @@ connection con_temp1;
3535
BEGIN;
3636
INSERT INTO t2 VALUES (21);
3737
connection server_2;
38-
START SLAVE;
38+
START SLAVE IO_THREAD;
39+
include/wait_for_slave_param.inc [Read_Master_Log_Pos]
40+
START SLAVE SQL_THREAD;
3941
connection con_temp2;
4042
SET @old_dbug= @@GLOBAL.debug_dbug;
4143
SET GLOBAL debug_dbug="+d,rpl_parallel_wait_for_done_trigger";

mysql-test/suite/rpl/t/rpl_parallel_stop_slave.test

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,14 +53,35 @@ COMMIT;
5353
INSERT INTO t3 VALUES(21, 21);
5454
INSERT INTO t3 VALUES(22, 22);
5555
--save_master_pos
56+
--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)
5657

5758
# Start a connection that will block the replicated transaction halfway.
5859
--connection con_temp1
5960
BEGIN;
6061
INSERT INTO t2 VALUES (21);
6162

6263
--connection server_2
63-
START SLAVE;
64+
65+
#
66+
# Parallel replication will complete any in-progress event group at STOP SLAVE,
67+
# but only if the event group is already queued up for the worker thread. If
68+
# the SQL driver thread is delayed in queueing up events, the parallel worker
69+
# thread can abort the event group, leaving the non-transactional update to the
70+
# MyISAM table that cannot be rolled back (MDEV-7432). If this happens the test
71+
# would fail with duplicate key error after slave restart.
72+
#
73+
# To avoid this, we here wait for the IO thread to read all master events, and
74+
# for the SQL driver thread to queue all the events for workers. This wait
75+
# should be removed if/when MDEV-7432 is fixed.
76+
#
77+
START SLAVE IO_THREAD;
78+
--let $slave_param= Read_Master_Log_Pos
79+
--let $slave_param_value= $master_pos
80+
--source include/wait_for_slave_param.inc
81+
START SLAVE SQL_THREAD;
82+
--let $wait_condition= SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State LIKE '%Slave has read all relay log; waiting for more updates%'
83+
--source include/wait_condition.inc
84+
6485
# Wait for the MyISAM change to be visible, after which replication will wait
6586
# for con_temp1 to roll back.
6687
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1 WHERE a=20

0 commit comments

Comments
 (0)