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

MDEV-24167: Replace fts_cache_rw_lock, fts_cache_init_rw_lock with mutex

fts_cache_t::init_lock: Replace with mutex. This was only acquired
in exclusive mode.

fts_cache_t::lock: Replace with mutex. The only read-lock user was
i_s_fts_index_cache_fill() for producing content for the view
INFORMATION_SCHEMA.INNODB_FT_INDEX_CACHE.
parent 1a1b7a6f
...@@ -8,8 +8,6 @@ select name from performance_schema.setup_instruments ...@@ -8,8 +8,6 @@ select name from performance_schema.setup_instruments
where name like "wait/synch/sxlock/%" order by name; where name like "wait/synch/sxlock/%" order by name;
name name
wait/synch/sxlock/innodb/fil_space_latch wait/synch/sxlock/innodb/fil_space_latch
wait/synch/sxlock/innodb/fts_cache_init_rw_lock
wait/synch/sxlock/innodb/fts_cache_rw_lock
wait/synch/sxlock/innodb/index_tree_rw_lock wait/synch/sxlock/innodb/index_tree_rw_lock
select name from performance_schema.rwlock_instances select name from performance_schema.rwlock_instances
where name in where name in
......
...@@ -1281,7 +1281,7 @@ dict_create_index_step( ...@@ -1281,7 +1281,7 @@ dict_create_index_step(
&& node->table->fts) { && node->table->fts) {
fts_index_cache_t* index_cache; fts_index_cache_t* index_cache;
rw_lock_x_lock( mysql_mutex_lock(
&node->table->fts->cache->init_lock); &node->table->fts->cache->init_lock);
index_cache = (fts_index_cache_t*) index_cache = (fts_index_cache_t*)
...@@ -1298,7 +1298,7 @@ dict_create_index_step( ...@@ -1298,7 +1298,7 @@ dict_create_index_step(
node->table->fts->cache->indexes, node->table->fts->cache->indexes,
*reinterpret_cast<void**>(index_cache)); *reinterpret_cast<void**>(index_cache));
rw_lock_x_unlock( mysql_mutex_unlock(
&node->table->fts->cache->init_lock); &node->table->fts->cache->init_lock);
} }
......
...@@ -2803,10 +2803,10 @@ dict_index_build_internal_fts( ...@@ -2803,10 +2803,10 @@ dict_index_build_internal_fts(
table->fts->cache = fts_cache_create(table); table->fts->cache = fts_cache_create(table);
} }
rw_lock_x_lock(&table->fts->cache->init_lock); mysql_mutex_lock(&table->fts->cache->init_lock);
/* Notify the FTS cache about this index. */ /* Notify the FTS cache about this index. */
fts_cache_index_cache_create(table, new_index); fts_cache_index_cache_create(table, new_index);
rw_lock_x_unlock(&table->fts->cache->init_lock); mysql_mutex_unlock(&table->fts->cache->init_lock);
return(new_index); return(new_index);
} }
......
...@@ -284,8 +284,8 @@ static ...@@ -284,8 +284,8 @@ static
void void
fts_cache_destroy(fts_cache_t* cache) fts_cache_destroy(fts_cache_t* cache)
{ {
rw_lock_free(&cache->lock); mysql_mutex_destroy(&cache->lock);
rw_lock_free(&cache->init_lock); mysql_mutex_destroy(&cache->init_lock);
mutex_free(&cache->deleted_lock); mutex_free(&cache->deleted_lock);
mutex_free(&cache->doc_id_lock); mutex_free(&cache->doc_id_lock);
os_event_destroy(cache->sync->event); os_event_destroy(cache->sync->event);
...@@ -613,11 +613,8 @@ fts_cache_create( ...@@ -613,11 +613,8 @@ fts_cache_create(
cache->cache_heap = heap; cache->cache_heap = heap;
rw_lock_create(fts_cache_rw_lock_key, &cache->lock, SYNC_FTS_CACHE); mysql_mutex_init(fts_cache_mutex_key, &cache->lock, nullptr);
mysql_mutex_init(fts_cache_init_mutex_key, &cache->init_lock, nullptr);
rw_lock_create(
fts_cache_init_rw_lock_key, &cache->init_lock,
SYNC_FTS_CACHE_INIT);
mutex_create(LATCH_ID_FTS_DELETE, &cache->deleted_lock); mutex_create(LATCH_ID_FTS_DELETE, &cache->deleted_lock);
...@@ -667,7 +664,7 @@ fts_add_index( ...@@ -667,7 +664,7 @@ fts_add_index(
ut_ad(fts); ut_ad(fts);
cache = table->fts->cache; cache = table->fts->cache;
rw_lock_x_lock(&cache->init_lock); mysql_mutex_lock(&cache->init_lock);
ib_vector_push(fts->indexes, &index); ib_vector_push(fts->indexes, &index);
...@@ -678,7 +675,7 @@ fts_add_index( ...@@ -678,7 +675,7 @@ fts_add_index(
index_cache = fts_cache_index_cache_create(table, index); index_cache = fts_cache_index_cache_create(table, index);
} }
rw_lock_x_unlock(&cache->init_lock); mysql_mutex_unlock(&cache->init_lock);
} }
/*******************************************************************//** /*******************************************************************//**
...@@ -692,7 +689,7 @@ fts_reset_get_doc( ...@@ -692,7 +689,7 @@ fts_reset_get_doc(
fts_get_doc_t* get_doc; fts_get_doc_t* get_doc;
ulint i; ulint i;
ut_ad(rw_lock_own(&cache->init_lock, RW_LOCK_X)); mysql_mutex_assert_owner(&cache->init_lock);
ib_vector_reset(cache->get_docs); ib_vector_reset(cache->get_docs);
...@@ -860,7 +857,7 @@ fts_drop_index( ...@@ -860,7 +857,7 @@ fts_drop_index(
fts_cache_t* cache = table->fts->cache; fts_cache_t* cache = table->fts->cache;
fts_index_cache_t* index_cache; fts_index_cache_t* index_cache;
rw_lock_x_lock(&cache->init_lock); mysql_mutex_lock(&cache->init_lock);
index_cache = fts_find_index_cache(cache, index); index_cache = fts_find_index_cache(cache, index);
...@@ -877,7 +874,7 @@ fts_drop_index( ...@@ -877,7 +874,7 @@ fts_drop_index(
fts_reset_get_doc(cache); fts_reset_get_doc(cache);
} }
rw_lock_x_unlock(&cache->init_lock); mysql_mutex_unlock(&cache->init_lock);
} }
err = fts_drop_index_tables(trx, index); err = fts_drop_index_tables(trx, index);
...@@ -976,7 +973,7 @@ fts_cache_index_cache_create( ...@@ -976,7 +973,7 @@ fts_cache_index_cache_create(
ut_a(cache != NULL); ut_a(cache != NULL);
ut_ad(rw_lock_own(&cache->init_lock, RW_LOCK_X)); mysql_mutex_assert_owner(&cache->init_lock);
/* Must not already exist in the cache vector. */ /* Must not already exist in the cache vector. */
ut_a(fts_find_index_cache(cache, index) == NULL); ut_a(fts_find_index_cache(cache, index) == NULL);
...@@ -1111,12 +1108,12 @@ fts_get_index_cache( ...@@ -1111,12 +1108,12 @@ fts_get_index_cache(
fts_cache_t* cache, /*!< in: cache to search */ fts_cache_t* cache, /*!< in: cache to search */
const dict_index_t* index) /*!< in: index to search for */ const dict_index_t* index) /*!< in: index to search for */
{ {
ulint i; #ifdef SAFE_MUTEX
ut_ad(mysql_mutex_is_owner(&cache->lock)
ut_ad(rw_lock_own((rw_lock_t*) &cache->lock, RW_LOCK_X) || mysql_mutex_is_owner(&cache->init_lock));
|| rw_lock_own((rw_lock_t*) &cache->init_lock, RW_LOCK_X)); #endif /* SAFE_MUTEX */
for (i = 0; i < ib_vector_size(cache->indexes); ++i) { for (ulint i = 0; i < ib_vector_size(cache->indexes); ++i) {
fts_index_cache_t* index_cache; fts_index_cache_t* index_cache;
index_cache = static_cast<fts_index_cache_t*>( index_cache = static_cast<fts_index_cache_t*>(
...@@ -1144,7 +1141,7 @@ fts_get_index_get_doc( ...@@ -1144,7 +1141,7 @@ fts_get_index_get_doc(
{ {
ulint i; ulint i;
ut_ad(rw_lock_own((rw_lock_t*) &cache->init_lock, RW_LOCK_X)); mysql_mutex_assert_owner(&cache->init_lock);
for (i = 0; i < ib_vector_size(cache->get_docs); ++i) { for (i = 0; i < ib_vector_size(cache->get_docs); ++i) {
fts_get_doc_t* get_doc; fts_get_doc_t* get_doc;
...@@ -1177,7 +1174,7 @@ fts_tokenizer_word_get( ...@@ -1177,7 +1174,7 @@ fts_tokenizer_word_get(
fts_tokenizer_word_t* word; fts_tokenizer_word_t* word;
ib_rbt_bound_t parent; ib_rbt_bound_t parent;
ut_ad(rw_lock_own(&cache->lock, RW_LOCK_X)); mysql_mutex_assert_owner(&cache->lock);
/* If it is a stopword, do not index it */ /* If it is a stopword, do not index it */
if (!fts_check_token(text, if (!fts_check_token(text,
...@@ -1237,7 +1234,7 @@ fts_cache_node_add_positions( ...@@ -1237,7 +1234,7 @@ fts_cache_node_add_positions(
#ifdef UNIV_DEBUG #ifdef UNIV_DEBUG
if (cache) { if (cache) {
ut_ad(rw_lock_own(&cache->lock, RW_LOCK_X)); mysql_mutex_assert_owner(&cache->lock);
} }
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
...@@ -1350,7 +1347,7 @@ fts_cache_add_doc( ...@@ -1350,7 +1347,7 @@ fts_cache_add_doc(
return; return;
} }
ut_ad(rw_lock_own(&cache->lock, RW_LOCK_X)); mysql_mutex_assert_owner(&cache->lock);
n_words = rbt_size(tokens); n_words = rbt_size(tokens);
...@@ -2959,11 +2956,11 @@ fts_commit_table( ...@@ -2959,11 +2956,11 @@ fts_commit_table(
ftt->fts_trx->trx = trx; ftt->fts_trx->trx = trx;
if (cache->get_docs == NULL) { if (cache->get_docs == NULL) {
rw_lock_x_lock(&cache->init_lock); mysql_mutex_lock(&cache->init_lock);
if (cache->get_docs == NULL) { if (cache->get_docs == NULL) {
cache->get_docs = fts_get_docs_create(cache); cache->get_docs = fts_get_docs_create(cache);
} }
rw_lock_x_unlock(&cache->init_lock); mysql_mutex_unlock(&cache->init_lock);
} }
for (node = rbt_first(rows); for (node = rbt_first(rows);
...@@ -3328,7 +3325,7 @@ fts_add_doc_from_tuple( ...@@ -3328,7 +3325,7 @@ fts_add_doc_from_tuple(
if (doc.found) { if (doc.found) {
mtr_commit(&mtr); mtr_commit(&mtr);
rw_lock_x_lock(&table->fts->cache->lock); mysql_mutex_lock(&table->fts->cache->lock);
if (table->fts->cache->stopword_info.status if (table->fts->cache->stopword_info.status
& STOPWORD_NOT_INIT) { & STOPWORD_NOT_INIT) {
...@@ -3341,7 +3338,7 @@ fts_add_doc_from_tuple( ...@@ -3341,7 +3338,7 @@ fts_add_doc_from_tuple(
get_doc->index_cache, get_doc->index_cache,
doc_id, doc.tokens); doc_id, doc.tokens);
rw_lock_x_unlock(&table->fts->cache->lock); mysql_mutex_unlock(&table->fts->cache->lock);
if (cache->total_size > fts_max_cache_size / 5 if (cache->total_size > fts_max_cache_size / 5
|| fts_need_sync) { || fts_need_sync) {
...@@ -3493,7 +3490,7 @@ fts_add_doc_by_id( ...@@ -3493,7 +3490,7 @@ fts_add_doc_by_id(
btr_pcur_store_position(doc_pcur, &mtr); btr_pcur_store_position(doc_pcur, &mtr);
mtr_commit(&mtr); mtr_commit(&mtr);
rw_lock_x_lock(&table->fts->cache->lock); mysql_mutex_lock(&table->fts->cache->lock);
if (table->fts->cache->stopword_info.status if (table->fts->cache->stopword_info.status
& STOPWORD_NOT_INIT) { & STOPWORD_NOT_INIT) {
...@@ -3513,7 +3510,7 @@ fts_add_doc_by_id( ...@@ -3513,7 +3510,7 @@ fts_add_doc_by_id(
need_sync = true; need_sync = true;
} }
rw_lock_x_unlock(&table->fts->cache->lock); mysql_mutex_unlock(&table->fts->cache->lock);
DBUG_EXECUTE_IF( DBUG_EXECUTE_IF(
"fts_instrument_sync", "fts_instrument_sync",
...@@ -3955,7 +3952,7 @@ fts_sync_write_words( ...@@ -3955,7 +3952,7 @@ fts_sync_write_words(
/*FIXME: we need to handle the error properly. */ /*FIXME: we need to handle the error properly. */
if (error == DB_SUCCESS) { if (error == DB_SUCCESS) {
if (unlock_cache) { if (unlock_cache) {
rw_lock_x_unlock( mysql_mutex_unlock(
&table->fts->cache->lock); &table->fts->cache->lock);
} }
...@@ -3973,7 +3970,7 @@ fts_sync_write_words( ...@@ -3973,7 +3970,7 @@ fts_sync_write_words(
); );
if (unlock_cache) { if (unlock_cache) {
rw_lock_x_lock( mysql_mutex_lock(
&table->fts->cache->lock); &table->fts->cache->lock);
} }
} }
...@@ -4132,7 +4129,7 @@ fts_sync_commit( ...@@ -4132,7 +4129,7 @@ fts_sync_commit(
fts_cache_clear(cache); fts_cache_clear(cache);
DEBUG_SYNC_C("fts_deleted_doc_ids_clear"); DEBUG_SYNC_C("fts_deleted_doc_ids_clear");
fts_cache_init(cache); fts_cache_init(cache);
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
if (UNIV_LIKELY(error == DB_SUCCESS)) { if (UNIV_LIKELY(error == DB_SUCCESS)) {
fts_sql_commit(trx); fts_sql_commit(trx);
...@@ -4201,7 +4198,7 @@ fts_sync_rollback( ...@@ -4201,7 +4198,7 @@ fts_sync_rollback(
} }
} }
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
fts_sql_rollback(trx); fts_sql_rollback(trx);
...@@ -4231,13 +4228,13 @@ fts_sync( ...@@ -4231,13 +4228,13 @@ fts_sync(
dberr_t error = DB_SUCCESS; dberr_t error = DB_SUCCESS;
fts_cache_t* cache = sync->table->fts->cache; fts_cache_t* cache = sync->table->fts->cache;
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
/* Check if cache is being synced. /* Check if cache is being synced.
Note: we release cache lock in fts_sync_write_words() to Note: we release cache lock in fts_sync_write_words() to
avoid long wait for the lock by other threads. */ avoid long wait for the lock by other threads. */
while (sync->in_progress) { while (sync->in_progress) {
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
if (wait) { if (wait) {
os_event_wait(sync->event); os_event_wait(sync->event);
...@@ -4245,7 +4242,7 @@ fts_sync( ...@@ -4245,7 +4242,7 @@ fts_sync(
return(DB_SUCCESS); return(DB_SUCCESS);
} }
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
} }
sync->unlock_cache = unlock_cache; sync->unlock_cache = unlock_cache;
...@@ -4311,12 +4308,12 @@ fts_sync( ...@@ -4311,12 +4308,12 @@ fts_sync(
fts_sync_rollback(sync); fts_sync_rollback(sync);
} }
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
sync->interrupted = false; sync->interrupted = false;
sync->in_progress = false; sync->in_progress = false;
os_event_set(sync->event); os_event_set(sync->event);
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
/* We need to check whether an optimize is required, for that /* We need to check whether an optimize is required, for that
we make copies of the two variables that control the trigger. These we make copies of the two variables that control the trigger. These
...@@ -4711,7 +4708,7 @@ fts_get_docs_create( ...@@ -4711,7 +4708,7 @@ fts_get_docs_create(
{ {
ib_vector_t* get_docs; ib_vector_t* get_docs;
ut_ad(rw_lock_own(&cache->init_lock, RW_LOCK_X)); mysql_mutex_assert_owner(&cache->init_lock);
/* We need one instance of fts_get_doc_t per index. */ /* We need one instance of fts_get_doc_t per index. */
get_docs = ib_vector_create(cache->self_heap, sizeof(fts_get_doc_t), 4); get_docs = ib_vector_create(cache->self_heap, sizeof(fts_get_doc_t), 4);
...@@ -4777,11 +4774,11 @@ fts_init_doc_id( ...@@ -4777,11 +4774,11 @@ fts_init_doc_id(
{ {
doc_id_t max_doc_id = 0; doc_id_t max_doc_id = 0;
rw_lock_x_lock(&table->fts->cache->lock); mysql_mutex_lock(&table->fts->cache->lock);
/* Return if the table is already initialized for DOC ID */ /* Return if the table is already initialized for DOC ID */
if (table->fts->cache->first_doc_id != FTS_NULL_DOC_ID) { if (table->fts->cache->first_doc_id != FTS_NULL_DOC_ID) {
rw_lock_x_unlock(&table->fts->cache->lock); mysql_mutex_unlock(&table->fts->cache->lock);
return(0); return(0);
} }
...@@ -4802,7 +4799,7 @@ fts_init_doc_id( ...@@ -4802,7 +4799,7 @@ fts_init_doc_id(
table->fts->cache->first_doc_id = max_doc_id; table->fts->cache->first_doc_id = max_doc_id;
rw_lock_x_unlock(&table->fts->cache->lock); mysql_mutex_unlock(&table->fts->cache->lock);
ut_ad(max_doc_id > 0); ut_ad(max_doc_id > 0);
...@@ -5134,12 +5131,8 @@ fts_cache_find_word( ...@@ -5134,12 +5131,8 @@ fts_cache_find_word(
{ {
ib_rbt_bound_t parent; ib_rbt_bound_t parent;
const ib_vector_t* nodes = NULL; const ib_vector_t* nodes = NULL;
#ifdef UNIV_DEBUG
dict_table_t* table = index_cache->index->table;
fts_cache_t* cache = table->fts->cache;
ut_ad(rw_lock_own(&cache->lock, RW_LOCK_X)); mysql_mutex_assert_owner(&index_cache->index->table->fts->cache->lock);
#endif /* UNIV_DEBUG */
/* Lookup the word in the rb tree */ /* Lookup the word in the rb tree */
if (rbt_search(index_cache->words, &parent, text) == 0) { if (rbt_search(index_cache->words, &parent, text) == 0) {
...@@ -6206,13 +6199,12 @@ fts_init_recover_doc( ...@@ -6206,13 +6199,12 @@ fts_init_recover_doc(
This function brings FTS index in sync when FTS index is first This function brings FTS index in sync when FTS index is first
used. There are documents that have not yet sync-ed to auxiliary used. There are documents that have not yet sync-ed to auxiliary
tables from last server abnormally shutdown, we will need to bring tables from last server abnormally shutdown, we will need to bring
such document into FTS cache before any further operations such document into FTS cache before any further operations */
@return TRUE if all OK */ void
ibool
fts_init_index( fts_init_index(
/*===========*/ /*===========*/
dict_table_t* table, /*!< in: Table with FTS */ dict_table_t* table, /*!< in: Table with FTS */
ibool has_cache_lock) /*!< in: Whether we already have bool has_cache_lock) /*!< in: Whether we already have
cache lock */ cache lock */
{ {
dict_index_t* index; dict_index_t* index;
...@@ -6225,14 +6217,14 @@ fts_init_index( ...@@ -6225,14 +6217,14 @@ fts_init_index(
/* First check cache->get_docs is initialized */ /* First check cache->get_docs is initialized */
if (!has_cache_lock) { if (!has_cache_lock) {
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
} }
rw_lock_x_lock(&cache->init_lock); mysql_mutex_lock(&cache->init_lock);
if (cache->get_docs == NULL) { if (cache->get_docs == NULL) {
cache->get_docs = fts_get_docs_create(cache); cache->get_docs = fts_get_docs_create(cache);
} }
rw_lock_x_unlock(&cache->init_lock); mysql_mutex_unlock(&cache->init_lock);
if (table->fts->added_synced) { if (table->fts->added_synced) {
goto func_exit; goto func_exit;
...@@ -6282,7 +6274,7 @@ fts_init_index( ...@@ -6282,7 +6274,7 @@ fts_init_index(
func_exit: func_exit:
if (!has_cache_lock) { if (!has_cache_lock) {
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
} }
if (need_init) { if (need_init) {
...@@ -6291,8 +6283,6 @@ fts_init_index( ...@@ -6291,8 +6283,6 @@ fts_init_index(
fts_optimize_add_table(table); fts_optimize_add_table(table);
mutex_exit(&dict_sys.mutex); mutex_exit(&dict_sys.mutex);
} }
return(TRUE);
} }
/** Check if the all the auxillary tables associated with FTS index are in /** Check if the all the auxillary tables associated with FTS index are in
......
...@@ -1145,7 +1145,7 @@ fts_query_difference( ...@@ -1145,7 +1145,7 @@ fts_query_difference(
fts_cache_t* cache = table->fts->cache; fts_cache_t* cache = table->fts->cache;
dberr_t error; dberr_t error;
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
index_cache = fts_find_index_cache(cache, query->index); index_cache = fts_find_index_cache(cache, query->index);
...@@ -1171,7 +1171,7 @@ fts_query_difference( ...@@ -1171,7 +1171,7 @@ fts_query_difference(
} }
} }
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
/* error is passed by 'query->error' */ /* error is passed by 'query->error' */
if (query->error != DB_SUCCESS) { if (query->error != DB_SUCCESS) {
...@@ -1270,7 +1270,7 @@ fts_query_intersect( ...@@ -1270,7 +1270,7 @@ fts_query_intersect(
/* Search the cache for a matching word first. */ /* Search the cache for a matching word first. */
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
/* Search for the index specific cache. */ /* Search for the index specific cache. */
index_cache = fts_find_index_cache(cache, query->index); index_cache = fts_find_index_cache(cache, query->index);
...@@ -1295,7 +1295,7 @@ fts_query_intersect( ...@@ -1295,7 +1295,7 @@ fts_query_intersect(
} }
} }
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
/* error is passed by 'query->error' */ /* error is passed by 'query->error' */
if (query->error != DB_SUCCESS) { if (query->error != DB_SUCCESS) {
...@@ -1349,7 +1349,7 @@ fts_query_cache( ...@@ -1349,7 +1349,7 @@ fts_query_cache(
fts_cache_t* cache = table->fts->cache; fts_cache_t* cache = table->fts->cache;
/* Search the cache for a matching word first. */ /* Search the cache for a matching word first. */
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
/* Search for the index specific cache. */ /* Search for the index specific cache. */
index_cache = fts_find_index_cache(cache, query->index); index_cache = fts_find_index_cache(cache, query->index);
...@@ -1379,7 +1379,7 @@ fts_query_cache( ...@@ -1379,7 +1379,7 @@ fts_query_cache(
} }
} }
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
return(query->error); return(query->error);
} }
...@@ -2480,9 +2480,9 @@ fts_query_is_in_proximity_range( ...@@ -2480,9 +2480,9 @@ fts_query_is_in_proximity_range(
memset(&get_doc, 0x0, sizeof(get_doc)); memset(&get_doc, 0x0, sizeof(get_doc));
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
get_doc.index_cache = fts_find_index_cache(cache, query->index); get_doc.index_cache = fts_find_index_cache(cache, query->index);
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
ut_a(get_doc.index_cache != NULL); ut_a(get_doc.index_cache != NULL);
fts_phrase_t phrase(get_doc.index_cache->index->table); fts_phrase_t phrase(get_doc.index_cache->index->table);
...@@ -2540,14 +2540,14 @@ fts_query_search_phrase( ...@@ -2540,14 +2540,14 @@ fts_query_search_phrase(
/* Setup the doc retrieval infrastructure. */ /* Setup the doc retrieval infrastructure. */
memset(&get_doc, 0x0, sizeof(get_doc)); memset(&get_doc, 0x0, sizeof(get_doc));
rw_lock_x_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
get_doc.index_cache = fts_find_index_cache(cache, query->index); get_doc.index_cache = fts_find_index_cache(cache, query->index);
/* Must find the index cache */ /* Must find the index cache */
ut_a(get_doc.index_cache != NULL); ut_a(get_doc.index_cache != NULL);
rw_lock_x_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
#ifdef FTS_INTERNAL_DIAG_PRINT #ifdef FTS_INTERNAL_DIAG_PRINT
ib::info() << "Start phrase search"; ib::info() << "Start phrase search";
...@@ -4255,9 +4255,9 @@ fts_expand_query( ...@@ -4255,9 +4255,9 @@ fts_expand_query(
/* Init "result_doc", to hold words from the first search pass */ /* Init "result_doc", to hold words from the first search pass */
fts_doc_init(&result_doc); fts_doc_init(&result_doc);
rw_lock_x_lock(&index->table->fts->cache->lock); mysql_mutex_lock(&index->table->fts->cache->lock);
index_cache = fts_find_index_cache(index->table->fts->cache, index); index_cache = fts_find_index_cache(index->table->fts->cache, index);
rw_lock_x_unlock(&index->table->fts->cache->lock); mysql_mutex_unlock(&index->table->fts->cache->lock);
ut_a(index_cache); ut_a(index_cache);
......
...@@ -522,6 +522,8 @@ static PSI_mutex_info all_innodb_mutexes[] = { ...@@ -522,6 +522,8 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(recalc_pool_mutex), PSI_KEY(recalc_pool_mutex),
PSI_KEY(fil_system_mutex), PSI_KEY(fil_system_mutex),
PSI_KEY(flush_list_mutex), PSI_KEY(flush_list_mutex),
PSI_KEY(fts_cache_mutex),
PSI_KEY(fts_cache_init_mutex),
PSI_KEY(fts_delete_mutex), PSI_KEY(fts_delete_mutex),
PSI_KEY(fts_doc_id_mutex), PSI_KEY(fts_doc_id_mutex),
PSI_KEY(log_flush_order_mutex), PSI_KEY(log_flush_order_mutex),
...@@ -566,8 +568,6 @@ static PSI_rwlock_info all_innodb_rwlocks[] = { ...@@ -566,8 +568,6 @@ static PSI_rwlock_info all_innodb_rwlocks[] = {
# endif # endif
{ &dict_operation_lock_key, "dict_operation_lock", 0 }, { &dict_operation_lock_key, "dict_operation_lock", 0 },
PSI_RWLOCK_KEY(fil_space_latch), PSI_RWLOCK_KEY(fil_space_latch),
PSI_RWLOCK_KEY(fts_cache_rw_lock),
PSI_RWLOCK_KEY(fts_cache_init_rw_lock),
{ &trx_i_s_cache_lock_key, "trx_i_s_cache_lock", 0 }, { &trx_i_s_cache_lock_key, "trx_i_s_cache_lock", 0 },
{ &trx_purge_latch_key, "trx_purge_latch", 0 }, { &trx_purge_latch_key, "trx_purge_latch", 0 },
PSI_RWLOCK_KEY(index_tree_rw_lock), PSI_RWLOCK_KEY(index_tree_rw_lock),
......
...@@ -2817,7 +2817,7 @@ i_s_fts_index_cache_fill( ...@@ -2817,7 +2817,7 @@ i_s_fts_index_cache_fill(
conv_str.f_len = sizeof word; conv_str.f_len = sizeof word;
conv_str.f_str = word; conv_str.f_str = word;
rw_lock_s_lock(&cache->lock); mysql_mutex_lock(&cache->lock);
for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) { for (ulint i = 0; i < ib_vector_size(cache->indexes); i++) {
fts_index_cache_t* index_cache; fts_index_cache_t* index_cache;
...@@ -2829,7 +2829,7 @@ i_s_fts_index_cache_fill( ...@@ -2829,7 +2829,7 @@ i_s_fts_index_cache_fill(
index_cache, thd, &conv_str, tables)); index_cache, thd, &conv_str, tables));
} }
rw_lock_s_unlock(&cache->lock); mysql_mutex_unlock(&cache->lock);
dict_table_close(user_table, FALSE, FALSE); dict_table_close(user_table, FALSE, FALSE);
dict_sys.unfreeze(); dict_sys.unfreeze();
......
...@@ -887,13 +887,12 @@ fts_table_fetch_doc_ids( ...@@ -887,13 +887,12 @@ fts_table_fetch_doc_ids(
This function brings FTS index in sync when FTS index is first This function brings FTS index in sync when FTS index is first
used. There are documents that have not yet sync-ed to auxiliary used. There are documents that have not yet sync-ed to auxiliary
tables from last server abnormally shutdown, we will need to bring tables from last server abnormally shutdown, we will need to bring
such document into FTS cache before any further operations such document into FTS cache before any further operations */
@return TRUE if all OK */ void
ibool
fts_init_index( fts_init_index(
/*===========*/ /*===========*/
dict_table_t* table, /*!< in: Table with FTS */ dict_table_t* table, /*!< in: Table with FTS */
ibool has_cache_lock); /*!< in: Whether we already bool has_cache_lock); /*!< in: Whether we already
have cache lock */ have cache lock */
/*******************************************************************//** /*******************************************************************//**
Add a newly create index in FTS cache */ Add a newly create index in FTS cache */
......
...@@ -123,13 +123,10 @@ struct fts_sync_t { ...@@ -123,13 +123,10 @@ struct fts_sync_t {
that new entries are added to, until it grows over the configured maximum that new entries are added to, until it grows over the configured maximum
size, at which time its contents are written to the INDEX table. */ size, at which time its contents are written to the INDEX table. */
struct fts_cache_t { struct fts_cache_t {
rw_lock_t lock; /*!< lock protecting all access to the mysql_mutex_t lock; /*!< lock protecting all access to the
memory buffer. FIXME: this needs to memory buffer */
be our new upgrade-capable rw-lock */ mysql_mutex_t init_lock; /*!< lock used for the cache
intialization */
rw_lock_t init_lock; /*!< lock used for the cache
intialization, it has different
SYNC level as above cache lock */
ib_mutex_t deleted_lock; /*!< Lock covering deleted_doc_ids */ ib_mutex_t deleted_lock; /*!< Lock covering deleted_doc_ids */
......
...@@ -308,7 +308,6 @@ log_free_check(void) ...@@ -308,7 +308,6 @@ log_free_check(void)
static const latch_level_t latches[] = { static const latch_level_t latches[] = {
SYNC_DICT, /* dict_sys.mutex during SYNC_DICT, /* dict_sys.mutex during
commit_try_rebuild() */ commit_try_rebuild() */
SYNC_FTS_CACHE, /* fts_cache_t::lock */
SYNC_INDEX_TREE /* index->lock */ SYNC_INDEX_TREE /* index->lock */
}; };
#endif /* UNIV_DEBUG */ #endif /* UNIV_DEBUG */
......
...@@ -44,6 +44,8 @@ extern mysql_pfs_key_t dict_foreign_err_mutex_key; ...@@ -44,6 +44,8 @@ extern mysql_pfs_key_t dict_foreign_err_mutex_key;
extern mysql_pfs_key_t dict_sys_mutex_key; extern mysql_pfs_key_t dict_sys_mutex_key;
extern mysql_pfs_key_t fil_system_mutex_key; extern mysql_pfs_key_t fil_system_mutex_key;
extern mysql_pfs_key_t flush_list_mutex_key; extern mysql_pfs_key_t flush_list_mutex_key;
extern mysql_pfs_key_t fts_cache_mutex_key;
extern mysql_pfs_key_t fts_cache_init_mutex_key;
extern mysql_pfs_key_t fts_delete_mutex_key; extern mysql_pfs_key_t fts_delete_mutex_key;
extern mysql_pfs_key_t fts_doc_id_mutex_key; extern mysql_pfs_key_t fts_doc_id_mutex_key;
extern mysql_pfs_key_t fts_pll_tokenize_mutex_key; extern mysql_pfs_key_t fts_pll_tokenize_mutex_key;
...@@ -89,8 +91,6 @@ extern mysql_pfs_key_t read_view_mutex_key; ...@@ -89,8 +91,6 @@ extern mysql_pfs_key_t read_view_mutex_key;
performance schema */ performance schema */
extern mysql_pfs_key_t dict_operation_lock_key; extern mysql_pfs_key_t dict_operation_lock_key;
extern mysql_pfs_key_t fil_space_latch_key; extern mysql_pfs_key_t fil_space_latch_key;
extern mysql_pfs_key_t fts_cache_rw_lock_key;
extern mysql_pfs_key_t fts_cache_init_rw_lock_key;
extern mysql_pfs_key_t trx_i_s_cache_lock_key; extern mysql_pfs_key_t trx_i_s_cache_lock_key;
extern mysql_pfs_key_t trx_purge_latch_key; extern mysql_pfs_key_t trx_purge_latch_key;
extern mysql_pfs_key_t index_tree_rw_lock_key; extern mysql_pfs_key_t index_tree_rw_lock_key;
......
...@@ -195,7 +195,6 @@ enum latch_level_t { ...@@ -195,7 +195,6 @@ enum latch_level_t {
SYNC_FTS_TOKENIZE, SYNC_FTS_TOKENIZE,
SYNC_FTS_OPTIMIZE, SYNC_FTS_OPTIMIZE,
SYNC_FTS_CACHE_INIT,
SYNC_RECV, SYNC_RECV,
SYNC_PURGE_QUEUE, SYNC_PURGE_QUEUE,
SYNC_TRX_SYS_HEADER, SYNC_TRX_SYS_HEADER,
...@@ -234,7 +233,6 @@ enum latch_level_t { ...@@ -234,7 +233,6 @@ enum latch_level_t {
SYNC_DICT_HEADER, SYNC_DICT_HEADER,
SYNC_STATS_AUTO_RECALC, SYNC_STATS_AUTO_RECALC,
SYNC_DICT, SYNC_DICT,
SYNC_FTS_CACHE,
/** Level is varying. Only used with buffer pool page locks, which /** Level is varying. Only used with buffer pool page locks, which
do not have a fixed level, but instead have their level set after do not have a fixed level, but instead have their level set after
...@@ -290,8 +288,6 @@ enum latch_id_t { ...@@ -290,8 +288,6 @@ enum latch_id_t {
LATCH_ID_BUF_BLOCK_LOCK, LATCH_ID_BUF_BLOCK_LOCK,
LATCH_ID_BUF_BLOCK_DEBUG, LATCH_ID_BUF_BLOCK_DEBUG,
LATCH_ID_FIL_SPACE, LATCH_ID_FIL_SPACE,
LATCH_ID_FTS_CACHE,
LATCH_ID_FTS_CACHE_INIT,
LATCH_ID_IBUF_INDEX_TREE, LATCH_ID_IBUF_INDEX_TREE,
LATCH_ID_INDEX_TREE, LATCH_ID_INDEX_TREE,
LATCH_ID_DICT_TABLE_STATS, LATCH_ID_DICT_TABLE_STATS,
...@@ -957,7 +953,6 @@ struct sync_checker : public sync_check_functor_t ...@@ -957,7 +953,6 @@ struct sync_checker : public sync_check_functor_t
switch (level) { switch (level) {
case SYNC_FSP: case SYNC_FSP:
case SYNC_DICT: case SYNC_DICT:
case SYNC_FTS_CACHE:
case SYNC_NO_ORDER_CHECK: case SYNC_NO_ORDER_CHECK:
return(false); return(false);
default: default:
......
...@@ -458,7 +458,6 @@ LatchDebug::LatchDebug() ...@@ -458,7 +458,6 @@ LatchDebug::LatchDebug()
LEVEL_MAP_INSERT(SYNC_WORK_QUEUE); LEVEL_MAP_INSERT(SYNC_WORK_QUEUE);
LEVEL_MAP_INSERT(SYNC_FTS_TOKENIZE); LEVEL_MAP_INSERT(SYNC_FTS_TOKENIZE);
LEVEL_MAP_INSERT(SYNC_FTS_OPTIMIZE); LEVEL_MAP_INSERT(SYNC_FTS_OPTIMIZE);
LEVEL_MAP_INSERT(SYNC_FTS_CACHE_INIT);
LEVEL_MAP_INSERT(SYNC_RECV); LEVEL_MAP_INSERT(SYNC_RECV);
LEVEL_MAP_INSERT(SYNC_PURGE_QUEUE); LEVEL_MAP_INSERT(SYNC_PURGE_QUEUE);
LEVEL_MAP_INSERT(SYNC_TRX_SYS_HEADER); LEVEL_MAP_INSERT(SYNC_TRX_SYS_HEADER);
...@@ -492,7 +491,6 @@ LatchDebug::LatchDebug() ...@@ -492,7 +491,6 @@ LatchDebug::LatchDebug()
LEVEL_MAP_INSERT(SYNC_DICT_HEADER); LEVEL_MAP_INSERT(SYNC_DICT_HEADER);
LEVEL_MAP_INSERT(SYNC_STATS_AUTO_RECALC); LEVEL_MAP_INSERT(SYNC_STATS_AUTO_RECALC);
LEVEL_MAP_INSERT(SYNC_DICT); LEVEL_MAP_INSERT(SYNC_DICT);
LEVEL_MAP_INSERT(SYNC_FTS_CACHE);
LEVEL_MAP_INSERT(SYNC_LEVEL_VARYING); LEVEL_MAP_INSERT(SYNC_LEVEL_VARYING);
LEVEL_MAP_INSERT(SYNC_NO_ORDER_CHECK); LEVEL_MAP_INSERT(SYNC_NO_ORDER_CHECK);
...@@ -726,8 +724,6 @@ LatchDebug::check_order( ...@@ -726,8 +724,6 @@ LatchDebug::check_order(
case SYNC_WORK_QUEUE: case SYNC_WORK_QUEUE:
case SYNC_FTS_TOKENIZE: case SYNC_FTS_TOKENIZE:
case SYNC_FTS_OPTIMIZE: case SYNC_FTS_OPTIMIZE:
case SYNC_FTS_CACHE:
case SYNC_FTS_CACHE_INIT:
case SYNC_LOCK_SYS: case SYNC_LOCK_SYS:
case SYNC_LOCK_WAIT_SYS: case SYNC_LOCK_WAIT_SYS:
case SYNC_RW_TRX_HASH_ELEMENT: case SYNC_RW_TRX_HASH_ELEMENT:
...@@ -1305,11 +1301,6 @@ sync_latch_meta_init() ...@@ -1305,11 +1301,6 @@ sync_latch_meta_init()
LATCH_ADD_RWLOCK(FIL_SPACE, SYNC_FSP, fil_space_latch_key); LATCH_ADD_RWLOCK(FIL_SPACE, SYNC_FSP, fil_space_latch_key);
LATCH_ADD_RWLOCK(FTS_CACHE, SYNC_FTS_CACHE, fts_cache_rw_lock_key);
LATCH_ADD_RWLOCK(FTS_CACHE_INIT, SYNC_FTS_CACHE_INIT,
fts_cache_init_rw_lock_key);
LATCH_ADD_RWLOCK(IBUF_INDEX_TREE, SYNC_IBUF_INDEX_TREE, LATCH_ADD_RWLOCK(IBUF_INDEX_TREE, SYNC_IBUF_INDEX_TREE,
index_tree_rw_lock_key); index_tree_rw_lock_key);
......
...@@ -41,6 +41,8 @@ mysql_pfs_key_t dict_foreign_err_mutex_key; ...@@ -41,6 +41,8 @@ mysql_pfs_key_t dict_foreign_err_mutex_key;
mysql_pfs_key_t dict_sys_mutex_key; mysql_pfs_key_t dict_sys_mutex_key;
mysql_pfs_key_t fil_system_mutex_key; mysql_pfs_key_t fil_system_mutex_key;
mysql_pfs_key_t flush_list_mutex_key; mysql_pfs_key_t flush_list_mutex_key;
mysql_pfs_key_t fts_cache_mutex_key;
mysql_pfs_key_t fts_cache_init_mutex_key;
mysql_pfs_key_t fts_delete_mutex_key; mysql_pfs_key_t fts_delete_mutex_key;
mysql_pfs_key_t fts_doc_id_mutex_key; mysql_pfs_key_t fts_doc_id_mutex_key;
mysql_pfs_key_t fts_pll_tokenize_mutex_key; mysql_pfs_key_t fts_pll_tokenize_mutex_key;
...@@ -85,8 +87,6 @@ mysql_pfs_key_t dict_operation_lock_key; ...@@ -85,8 +87,6 @@ mysql_pfs_key_t dict_operation_lock_key;
mysql_pfs_key_t index_tree_rw_lock_key; mysql_pfs_key_t index_tree_rw_lock_key;
mysql_pfs_key_t index_online_log_key; mysql_pfs_key_t index_online_log_key;
mysql_pfs_key_t fil_space_latch_key; mysql_pfs_key_t fil_space_latch_key;
mysql_pfs_key_t fts_cache_rw_lock_key;
mysql_pfs_key_t fts_cache_init_rw_lock_key;
mysql_pfs_key_t trx_i_s_cache_lock_key; mysql_pfs_key_t trx_i_s_cache_lock_key;
mysql_pfs_key_t trx_purge_latch_key; mysql_pfs_key_t trx_purge_latch_key;
#endif /* UNIV_PFS_RWLOCK */ #endif /* UNIV_PFS_RWLOCK */
......
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