summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-04-10 11:57:39 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2023-04-19 17:11:14 +0530
commitb2bbc66a41a7b3b622fbcd477e777c45e3248886 (patch)
tree2b21c1189dfc6d5dda433711eef16f495ae46fef
parentd6651864773afc2b7534285ee0d50d4fd6b47e9c (diff)
downloadmariadb-git-b2bbc66a41a7b3b622fbcd477e777c45e3248886.tar.gz
MDEV-24011 InnoDB: Failing assertion: index_cache->words == NULL in fts0fts.cc line 551
This issue happens when race condition happens when DDL and fts optimize thread. DDL adds the new index to fts cache. At the same time, fts optimize thread clears the cache and reinitialize it. Take cache init lock before reinitializing the cache. fts_sync_commit() should take dict_sys mutex to avoid the deadlock with create index.
-rw-r--r--storage/innobase/fts/fts0fts.cc10
1 files changed, 9 insertions, 1 deletions
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 224fc9593b7..8ce6fee0b76 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -851,7 +851,7 @@ fts_drop_index(
dberr_t err = DB_SUCCESS;
ut_a(indexes);
-
+ ut_d(dict_sys.assert_locked());
if ((ib_vector_size(indexes) == 1
&& (index == static_cast<dict_index_t*>(
ib_vector_getp(table->fts->indexes, 0)))
@@ -873,7 +873,9 @@ fts_drop_index(
current_doc_id = table->fts->cache->next_doc_id;
first_doc_id = table->fts->cache->first_doc_id;
+ rw_lock_x_lock(&table->fts->cache->init_lock);
fts_cache_clear(table->fts->cache);
+ rw_lock_x_unlock(&table->fts->cache->init_lock);
fts_cache_destroy(table->fts->cache);
table->fts->cache = fts_cache_create(table);
table->fts->cache->next_doc_id = current_doc_id;
@@ -4192,9 +4194,15 @@ fts_sync_commit(
/* We need to do this within the deleted lock since fts_delete() can
attempt to add a deleted doc id to the cache deleted id array. */
+ mutex_enter(&dict_sys.mutex);
+ sync->table->fts->dict_locked = true;
+ rw_lock_x_lock(&cache->init_lock);
fts_cache_clear(cache);
DEBUG_SYNC_C("fts_deleted_doc_ids_clear");
fts_cache_init(cache);
+ rw_lock_x_unlock(&cache->init_lock);
+ sync->table->fts->dict_locked = false;
+ mutex_exit(&dict_sys.mutex);
rw_lock_x_unlock(&cache->lock);
if (UNIV_LIKELY(error == DB_SUCCESS)) {