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-10 11:58:46 +0530
commite21f1a50357a169938bc3e6beef6140352db0d9a (patch)
treed9a46b85e33368be280aeff0e773f86c91e8fba9
parented2adc8c6f986f7e9c81d7a99f85cad0e2d46d80 (diff)
downloadmariadb-git-bb-10.4-MDEV-24011.tar.gz
MDEV-24011 InnoDB: Failing assertion: index_cache->words == NULL in fts0fts.cc line 551bb-10.4-MDEV-24011
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)) {