diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-06-16 12:23:41 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-06-16 12:23:41 +0300 |
commit | da65cb4d97fbd55411dd08108ecc2cf72712851d (patch) | |
tree | 0e6397c0db0d950f8c129161c3343cd6b96ccf85 | |
parent | 71964c76fe0d7266103025c31d5b7f5d50854383 (diff) | |
download | mariadb-git-da65cb4d97fbd55411dd08108ecc2cf72712851d.tar.gz |
MDEV-25936 Crash during DDL that involves FULLTEXT INDEX
In commit 1bd681c8b3c5213ce1f7976940a7dc38b48a0d39 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.
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 4 |
1 files changed, 4 insertions, 0 deletions
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index d1b71f3e72e..be9a4cc25c3 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -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; } |