Commit da65cb4d authored by Marko Mäkelä's avatar Marko Mäkelä

MDEV-25936 Crash during DDL that involves FULLTEXT INDEX

In commit 1bd681c8 we introduced
a work-around for the missing MDL protection when the internal
tables of FULLTEXT INDEX are dropped during DDL operations.
That work-around suffered from a race condition. A purge thread
could have narrowly passed purge_sys.check_stop_FTS() and then
(while holding dict_sys.mutex) acquire a table reference right
after fts_lock_table() determined that no references were being
held.

fts_lock_table(): Protect the reference check with dict_sys.mutex.

Thanks to Thirunarayanan Balathandayuthapani for repeating the
failure and testing the fix.
parent 71964c76
......@@ -1549,15 +1549,19 @@ static dberr_t fts_lock_table(trx_t *trx, const char *table_name)
{
dberr_t err= lock_table_for_trx(table, trx, LOCK_X);
/* Wait for purge threads to stop using the table. */
dict_sys.mutex_lock();
for (uint n= 15; table->get_ref_count() > 1; )
{
dict_sys.mutex_unlock();
if (!--n)
{
err= DB_LOCK_WAIT_TIMEOUT;
break;
}
std::this_thread::sleep_for(std::chrono::milliseconds(50));
dict_sys.mutex_lock();
}
dict_sys.mutex_unlock();
table->release();
return err;
}
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment