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.
parent d6651864
......@@ -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)) {
......
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