diff options
author | Vladislav Vaintroub <wlad@mariadb.com> | 2019-11-25 17:09:26 +0100 |
---|---|---|
committer | Vladislav Vaintroub <wlad@mariadb.com> | 2019-11-25 17:10:01 +0100 |
commit | 86407a59b36473b078a96979adc5a619a5f1ac80 (patch) | |
tree | aa68de6626fcf6c856e696ff48ace2d4c7ec7155 /tpool | |
parent | 38c2c16cc4aae4c09910537a53a924f7768726dd (diff) | |
download | mariadb-git-86407a59b36473b078a96979adc5a619a5f1ac80.tar.gz |
MDEV-16264 - Fix assertion `m_queue.empty() && !m_tasks_running' in tpool::task_group destructor
This particular assertion happened when shutting down Innodb IO.IO shutdown properly waits for all IOs to finish
However there is a race condition -
right after releasing last IO slot and before decrementing task count
in group, pending_io_count will be 0, but tasks_running will be 1,
leading to assertion.
The fix is to make task_group destructor to wait for last running task
to finish.
Diffstat (limited to 'tpool')
-rw-r--r-- | tpool/task_group.cc | 17 |
1 files changed, 16 insertions, 1 deletions
diff --git a/tpool/task_group.cc b/tpool/task_group.cc index ec9988ded6e..b52fe7c0f67 100644 --- a/tpool/task_group.cc +++ b/tpool/task_group.cc @@ -20,6 +20,9 @@ Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02111 - 1301 USA*/ #include <tpool_structs.h> #include <thread> #include <assert.h> +#ifndef _WIN32 +#include <unistd.h> // usleep +#endif namespace tpool { task_group::task_group(unsigned int max_concurrency) : @@ -79,6 +82,18 @@ namespace tpool task_group::~task_group() { - assert(m_queue.empty() && !m_tasks_running); + std::unique_lock<std::mutex> lk(m_mtx); + assert(m_queue.empty()); + + while (m_tasks_running) + { + lk.unlock(); +#ifndef _WIN32 + usleep(1000); +#else + Sleep(1); +#endif + lk.lock(); + } } } |