summaryrefslogtreecommitdiff
path: root/sql/rpl_parallel.cc
diff options
context:
space:
mode:
authorMonty <monty@mariadb.org>2018-01-24 23:33:21 +0200
committerMonty <monty@mariadb.org>2018-01-24 23:33:21 +0200
commit7fc25cfbca3cadc53bdcd44572ac2d29d17cff0d (patch)
treed1b240e920071e365c151396cf2bab025a0afda5 /sql/rpl_parallel.cc
parent0dbe3dbe7929c209614ab5803084c101b433299c (diff)
downloadmariadb-git-7fc25cfbca3cadc53bdcd44572ac2d29d17cff0d.tar.gz
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.
Diffstat (limited to 'sql/rpl_parallel.cc')
-rw-r--r--sql/rpl_parallel.cc11
1 files changed, 10 insertions, 1 deletions
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;