From 7fc25cfbca3cadc53bdcd44572ac2d29d17cff0d Mon Sep 17 00:00:00 2001 From: Monty Date: Wed, 24 Jan 2018 23:33:21 +0200 Subject: [PATCH] Fix for MDEV-12730 Assertion `count > 0' failed in rpl_parallel_thread_pool:: get_thread, rpl.rpl_parallel failed in buildbot The reason for this is that one thread can call rpl_parallel_resize_pool_if_no_slaves() while another thread calls at the same time rpl_parallel_activate_pool(). If rpl_parallel_active_pool() is called before rpl_parallel_resize_pool_if_no_slaves() has finished, pool->count will be set to 0 even if there exists active slave threads. Added a mutex lock in rpl_parallel_activate_pool() to protect against this scenario, which seams to fix this issue. --- sql/rpl_parallel.cc | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sql/rpl_parallel.cc b/sql/rpl_parallel.cc index 973b9d899c1..34f9113f7fe 100644 --- a/sql/rpl_parallel.cc +++ b/sql/rpl_parallel.cc @@ -1623,10 +1623,19 @@ int rpl_parallel_resize_pool_if_no_slaves(void) } +/** + Resize pool if not active or busy (in which case we may be in + resize to 0 +*/ + int rpl_parallel_activate_pool(rpl_parallel_thread_pool *pool) { - if (!pool->count) + bool resize; + mysql_mutex_lock(&pool->LOCK_rpl_thread_pool); + resize= !pool->count || pool->busy; + mysql_mutex_unlock(&pool->LOCK_rpl_thread_pool); + if (resize) return rpl_parallel_change_thread_count(pool, opt_slave_parallel_threads, 0); return 0;