From e607f3398c69147299884d3814cf063d2e7516ce Mon Sep 17 00:00:00 2001 From: Sachin Kumar Date: Wed, 14 Apr 2021 10:56:12 +0100 Subject: [PATCH] MDEV-25336 Parallel replication causes failed assert while restarting Problem:- When slave is shutdown, we will get this assertion failure sql/sql_list.h:642: void ilink::assert_linked(): Assertion `prev != 0 && next != 0' failed. Solution:- In close_connections when we call threads.get() it resets to prev and next to NULL. And in parallel worker thread(handle_rpl_parallel_thread) calls unlink_not_visible_thd() which assert on prev and next being not NULL. .unlink_not_visible_thd() should be always called first before threads.get() is called. To make sure worker calls unlink_not_visible_thd() in slave_prepare_for_shutdown() we are deactivating the worker thread pool which in turn will close all worker threads. Since this is already done in 10.4 and 10.5 I am backPorting MDEV-20821 and MDEV-22370 to 10.2. Mdev-22370 is improving the MDEV-20821 patch. --- mysql-test/suite/rpl/t/rpl_slave_shutdown_mdev20821.test | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/mysql-test/suite/rpl/t/rpl_slave_shutdown_mdev20821.test b/mysql-test/suite/rpl/t/rpl_slave_shutdown_mdev20821.test index 563533bb104..6f73de984d3 100644 --- a/mysql-test/suite/rpl/t/rpl_slave_shutdown_mdev20821.test +++ b/mysql-test/suite/rpl/t/rpl_slave_shutdown_mdev20821.test @@ -4,6 +4,10 @@ # hang when the parallel workers were idle. # The bug reported scenario is extented to cover the multi-sources case as well as # checking is done for both the idle and busy workers cases. +# +# MDEV-25336 Parallel replication causes failed assert while restarting +# Since this test case involves slave restart this will help in testing +# Mdev-25336 too. --source include/have_innodb.inc --source include/have_binlog_format_mixed.inc @@ -26,7 +30,7 @@ select @@global.slave_parallel_workers as two; # At this point worker threads have no assignement. # Shutdown must not hang. - +# In 10.2/10.3 there should not be any assert failure `prev != 0 && next != 0' --connection server_3 --write_file $MYSQLTEST_VARDIR/tmp/mysqld.3.expect wait @@ -75,6 +79,7 @@ insert into t1 values (1); --connection server_3 --sync_with_master 0,'' +# In 10.2/10.3 there should not be any assert failure `prev != 0 && next != 0' # At this point worker threads have no assignement. # Shutdown must not hang. @@ -117,6 +122,7 @@ insert into t1 values (2); insert into t2 values (2); +# In 10.2/10.3 there should not be any assert failure `prev != 0 && next != 0' # At this point there's a good chance the worker threads are busy. # SHUTDOWN must proceed without any delay as above. --connection server_3