Skip to content

Commit

Permalink
Fix occasional test failure of rpl.rpl_parallel_stop_slave
Browse files Browse the repository at this point in the history
Signed-off-by: Kristian Nielsen <knielsen@knielsen-hq.org>
  • Loading branch information
knielsen committed Mar 15, 2024
1 parent 7f498fb commit fb774eb
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ connection con_temp1;
BEGIN;
INSERT INTO t2 VALUES (21);
connection server_2;
START SLAVE;
START SLAVE IO_THREAD;
include/wait_for_slave_param.inc [Read_Master_Log_Pos]
START SLAVE SQL_THREAD;
connection con_temp2;
SET @old_dbug= @@GLOBAL.debug_dbug;
SET GLOBAL debug_dbug="+d,rpl_parallel_wait_for_done_trigger";
Expand Down
4 changes: 3 additions & 1 deletion mysql-test/suite/rpl/r/rpl_parallel_stop_slave.result
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,9 @@ connection con_temp1;
BEGIN;
INSERT INTO t2 VALUES (21);
connection server_2;
START SLAVE;
START SLAVE IO_THREAD;
include/wait_for_slave_param.inc [Read_Master_Log_Pos]
START SLAVE SQL_THREAD;
connection con_temp2;
SET @old_dbug= @@GLOBAL.debug_dbug;
SET GLOBAL debug_dbug="+d,rpl_parallel_wait_for_done_trigger";
Expand Down
23 changes: 22 additions & 1 deletion mysql-test/suite/rpl/t/rpl_parallel_stop_slave.test
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,35 @@ COMMIT;
INSERT INTO t3 VALUES(21, 21);
INSERT INTO t3 VALUES(22, 22);
--save_master_pos
--let $master_pos= query_get_value(SHOW MASTER STATUS, Position, 1)

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

--connection server_2
START SLAVE;

#
# Parallel replication will complete any in-progress event group at STOP SLAVE,
# but only if the event group is already queued up for the worker thread. If
# the SQL driver thread is delayed in queueing up events, the parallel worker
# thread can abort the event group, leaving the non-transactional update to the
# MyISAM table that cannot be rolled back (MDEV-7432). If this happens the test
# would fail with duplicate key error after slave restart.
#
# To avoid this, we here wait for the IO thread to read all master events, and
# for the SQL driver thread to queue all the events for workers. This wait
# should be removed if/when MDEV-7432 is fixed.
#
START SLAVE IO_THREAD;
--let $slave_param= Read_Master_Log_Pos
--let $slave_param_value= $master_pos
--source include/wait_for_slave_param.inc
START SLAVE SQL_THREAD;
--let $wait_condition= SELECT COUNT(*)=1 FROM INFORMATION_SCHEMA.PROCESSLIST WHERE State LIKE '%Slave has read all relay log; waiting for more updates%'
--source include/wait_condition.inc

# Wait for the MyISAM change to be visible, after which replication will wait
# for con_temp1 to roll back.
--let $wait_condition= SELECT COUNT(*) = 1 FROM t1 WHERE a=20
Expand Down

0 comments on commit fb774eb

Please sign in to comment.