From b19760b8436c91c9333cc2744f238d45b993d366 Mon Sep 17 00:00:00 2001 From: Vladislav Vaintroub Date: Thu, 23 Jan 2020 14:27:49 +0100 Subject: [PATCH] MDEV-21551 : Assertion `m_active_threads.size() >= m_long_tasks_count + m_waiting_task_count' failed" Happened when running innodb_fts.sync_ddl m_long_task_count could be wrongly reset to 0, if m_task_queue is empty. --- tpool/tpool_generic.cc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tpool/tpool_generic.cc b/tpool/tpool_generic.cc index 70325cf9e56..47c19e39baa 100644 --- a/tpool/tpool_generic.cc +++ b/tpool/tpool_generic.cc @@ -441,6 +441,7 @@ bool thread_pool_generic::wait_for_tasks(std::unique_lock &lk, } } + /** Workers "get next task" routine. @@ -489,6 +490,7 @@ bool thread_pool_generic::get_task(worker_data *thread_var, task **t) void thread_pool_generic::worker_end(worker_data* thread_data) { std::lock_guard lk(m_mtx); + DBUG_ASSERT(!thread_data->is_long_task()); m_active_threads.erase(thread_data); m_thread_data_cache.put(thread_data); @@ -549,14 +551,13 @@ void thread_pool_generic::maintainence() m_timestamp = std::chrono::system_clock::now(); - m_long_tasks_count = 0; - if (m_task_queue.empty()) { m_last_activity = m_tasks_dequeued + m_wakeups; return; } + m_long_tasks_count = 0; for (auto thread_data = m_active_threads.front(); thread_data; thread_data = thread_data->m_next)