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
where name like "wait/synch/sxlock/%" order by name;
name
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
select name from performance_schema.rwlock_instances
where name in
......
......@@ -1281,7 +1281,7 @@ dict_create_index_step(
&& node->table->fts) {
fts_index_cache_t* index_cache;
rw_lock_x_lock(
mysql_mutex_lock(
&node->table->fts->cache->init_lock);
index_cache = (fts_index_cache_t*)
......@@ -1298,7 +1298,7 @@ dict_create_index_step(
node->table->fts->cache->indexes,
*reinterpret_cast<void**>(index_cache));
rw_lock_x_unlock(
mysql_mutex_unlock(
&node->table->fts->cache->init_lock);
}
......
......@@ -2803,10 +2803,10 @@ dict_index_build_internal_fts(
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. */
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);
}
......
This diff is collapsed.
......@@ -1145,7 +1145,7 @@ fts_query_difference(
fts_cache_t* cache = table->fts->cache;
dberr_t error;
rw_lock_x_lock(&cache->lock);
mysql_mutex_lock(&cache->lock);
index_cache = fts_find_index_cache(cache, query->index);
......@@ -1171,7 +1171,7 @@ fts_query_difference(
}
}
rw_lock_x_unlock(&cache->lock);
mysql_mutex_unlock(&cache->lock);
/* error is passed by 'query->error' */
if (query->error != DB_SUCCESS) {
......@@ -1270,7 +1270,7 @@ fts_query_intersect(
/* 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. */
index_cache = fts_find_index_cache(cache, query->index);
......@@ -1295,7 +1295,7 @@ fts_query_intersect(
}
}
rw_lock_x_unlock(&cache->lock);
mysql_mutex_unlock(&cache->lock);
/* error is passed by 'query->error' */
if (query->error != DB_SUCCESS) {
......@@ -1349,7 +1349,7 @@ fts_query_cache(
fts_cache_t* cache = table->fts->cache;
/* 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. */
index_cache = fts_find_index_cache(cache, query->index);
......@@ -1379,7 +1379,7 @@ fts_query_cache(
}
}
rw_lock_x_unlock(&cache->lock);
mysql_mutex_unlock(&cache->lock);
return(query->error);
}
......@@ -2480,9 +2480,9 @@ fts_query_is_in_proximity_range(
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);
rw_lock_x_unlock(&cache->lock);
mysql_mutex_unlock(&cache->lock);
ut_a(get_doc.index_cache != NULL);
fts_phrase_t phrase(get_doc.index_cache->index->table);
......@@ -2540,14 +2540,14 @@ fts_query_search_phrase(
/* Setup the doc retrieval infrastructure. */
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);
/* Must find the index cache */
ut_a(get_doc.index_cache != NULL);
rw_lock_x_unlock(&cache->lock);
mysql_mutex_unlock(&cache->lock);
#ifdef FTS_INTERNAL_DIAG_PRINT
ib::info() << "Start phrase search";
......@@ -4255,9 +4255,9 @@ fts_expand_query(
/* Init "result_doc", to hold words from the first search pass */
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);
rw_lock_x_unlock(&index->table->fts->cache->lock);
mysql_mutex_unlock(&index->table->fts->cache->lock);
ut_a(index_cache);
......
......@@ -522,6 +522,8 @@ static PSI_mutex_info all_innodb_mutexes[] = {
PSI_KEY(recalc_pool_mutex),
PSI_KEY(fil_system_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_doc_id_mutex),
PSI_KEY(log_flush_order_mutex),
......@@ -566,8 +568,6 @@ static PSI_rwlock_info all_innodb_rwlocks[] = {
# endif
{ &dict_operation_lock_key, "dict_operation_lock", 0 },
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_purge_latch_key, "trx_purge_latch", 0 },
PSI_RWLOCK_KEY(index_tree_rw_lock),
......
......@@ -2817,7 +2817,7 @@ i_s_fts_index_cache_fill(
conv_str.f_len = sizeof 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++) {
fts_index_cache_t* index_cache;
......@@ -2829,7 +2829,7 @@ i_s_fts_index_cache_fill(
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_sys.unfreeze();
......
......@@ -887,13 +887,12 @@ fts_table_fetch_doc_ids(
This function brings FTS index in sync when FTS index is first
used. There are documents that have not yet sync-ed to auxiliary
tables from last server abnormally shutdown, we will need to bring
such document into FTS cache before any further operations
@return TRUE if all OK */
ibool
such document into FTS cache before any further operations */
void
fts_init_index(
/*===========*/
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 */
/*******************************************************************//**
Add a newly create index in FTS cache */
......
......@@ -123,13 +123,10 @@ struct fts_sync_t {
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. */
struct fts_cache_t {
rw_lock_t lock; /*!< lock protecting all access to the
memory buffer. FIXME: this needs to
be our new upgrade-capable rw-lock */
rw_lock_t init_lock; /*!< lock used for the cache
intialization, it has different
SYNC level as above cache lock */
mysql_mutex_t lock; /*!< lock protecting all access to the
memory buffer */
mysql_mutex_t init_lock; /*!< lock used for the cache
intialization */
ib_mutex_t deleted_lock; /*!< Lock covering deleted_doc_ids */
......
......@@ -308,7 +308,6 @@ log_free_check(void)
static const latch_level_t latches[] = {
SYNC_DICT, /* dict_sys.mutex during
commit_try_rebuild() */
SYNC_FTS_CACHE, /* fts_cache_t::lock */
SYNC_INDEX_TREE /* index->lock */
};
#endif /* UNIV_DEBUG */
......
......@@ -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 fil_system_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_doc_id_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;
performance schema */
extern mysql_pfs_key_t dict_operation_lock_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_purge_latch_key;
extern mysql_pfs_key_t index_tree_rw_lock_key;
......
......@@ -195,7 +195,6 @@ enum latch_level_t {
SYNC_FTS_TOKENIZE,
SYNC_FTS_OPTIMIZE,
SYNC_FTS_CACHE_INIT,
SYNC_RECV,
SYNC_PURGE_QUEUE,
SYNC_TRX_SYS_HEADER,
......@@ -234,7 +233,6 @@ enum latch_level_t {
SYNC_DICT_HEADER,
SYNC_STATS_AUTO_RECALC,
SYNC_DICT,
SYNC_FTS_CACHE,
/** Level is varying. Only used with buffer pool page locks, which
do not have a fixed level, but instead have their level set after
......@@ -290,8 +288,6 @@ enum latch_id_t {
LATCH_ID_BUF_BLOCK_LOCK,
LATCH_ID_BUF_BLOCK_DEBUG,
LATCH_ID_FIL_SPACE,
LATCH_ID_FTS_CACHE,
LATCH_ID_FTS_CACHE_INIT,
LATCH_ID_IBUF_INDEX_TREE,
LATCH_ID_INDEX_TREE,
LATCH_ID_DICT_TABLE_STATS,
......@@ -957,7 +953,6 @@ struct sync_checker : public sync_check_functor_t
switch (level) {
case SYNC_FSP:
case SYNC_DICT:
case SYNC_FTS_CACHE:
case SYNC_NO_ORDER_CHECK:
return(false);
default:
......
......@@ -458,7 +458,6 @@ LatchDebug::LatchDebug()
LEVEL_MAP_INSERT(SYNC_WORK_QUEUE);
LEVEL_MAP_INSERT(SYNC_FTS_TOKENIZE);
LEVEL_MAP_INSERT(SYNC_FTS_OPTIMIZE);
LEVEL_MAP_INSERT(SYNC_FTS_CACHE_INIT);
LEVEL_MAP_INSERT(SYNC_RECV);
LEVEL_MAP_INSERT(SYNC_PURGE_QUEUE);
LEVEL_MAP_INSERT(SYNC_TRX_SYS_HEADER);
......@@ -492,7 +491,6 @@ LatchDebug::LatchDebug()
LEVEL_MAP_INSERT(SYNC_DICT_HEADER);
LEVEL_MAP_INSERT(SYNC_STATS_AUTO_RECALC);
LEVEL_MAP_INSERT(SYNC_DICT);
LEVEL_MAP_INSERT(SYNC_FTS_CACHE);
LEVEL_MAP_INSERT(SYNC_LEVEL_VARYING);
LEVEL_MAP_INSERT(SYNC_NO_ORDER_CHECK);
......@@ -726,8 +724,6 @@ LatchDebug::check_order(
case SYNC_WORK_QUEUE:
case SYNC_FTS_TOKENIZE:
case SYNC_FTS_OPTIMIZE:
case SYNC_FTS_CACHE:
case SYNC_FTS_CACHE_INIT:
case SYNC_LOCK_SYS:
case SYNC_LOCK_WAIT_SYS:
case SYNC_RW_TRX_HASH_ELEMENT:
......@@ -1305,11 +1301,6 @@ sync_latch_meta_init()
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,
index_tree_rw_lock_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 fil_system_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_doc_id_mutex_key;
mysql_pfs_key_t fts_pll_tokenize_mutex_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_online_log_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_purge_latch_key;
#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