mirror of
https://github.com/MariaDB/server.git
synced 2025-03-29 18:35:35 +01:00
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.
This commit is contained in:
parent
38c2c16cc4
commit
86407a59b3
1 changed files with 16 additions and 1 deletions
|
@ -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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue