diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-31 13:54:06 +0300 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2021-08-31 13:54:06 +0300 |
commit | 6a2cd6f4b406cc3167799f589af1b96c4cd6943c (patch) | |
tree | 214cb5141d28f0061e564a1e137b8137b0364776 | |
parent | 82b7c561b7919fa24e3d24b3f04a16046e24374f (diff) | |
download | mariadb-git-6a2cd6f4b406cc3167799f589af1b96c4cd6943c.tar.gz |
MDEV-19505 Do not hold mutex while calling que_graph_free()
sym_tab_free_private(): Do not call dict_table_close(), but
simply invoke dict_table_t::release(), which we can do without
locking the whole dictionary cache. (Note: On user tables it
may still be necessary to invoke dict_table_close(), so that
InnoDB persistent statistics will be deinitialized as expected.)
fts_check_corrupt(), row_fts_merge_insert(): Invoke
aux_table->release() to simplify the code. This is never a user table.
fts_que_graph_free(), fts_que_graph_free_check_lock(): Replaced with
que_graph_free().
Reviewed by: Thirunarayanan Balathandayuthapani
-rw-r--r-- | storage/innobase/fts/fts0config.cc | 6 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 75 | ||||
-rw-r--r-- | storage/innobase/fts/fts0opt.cc | 18 | ||||
-rw-r--r-- | storage/innobase/fts/fts0que.cc | 18 | ||||
-rw-r--r-- | storage/innobase/handler/i_s.cc | 2 | ||||
-rw-r--r-- | storage/innobase/include/fts0fts.h | 13 | ||||
-rw-r--r-- | storage/innobase/pars/pars0sym.cc | 5 | ||||
-rw-r--r-- | storage/innobase/row/row0ftsort.cc | 2 |
8 files changed, 36 insertions, 103 deletions
diff --git a/storage/innobase/fts/fts0config.cc b/storage/innobase/fts/fts0config.cc index 09cce53f8db..4566224e171 100644 --- a/storage/innobase/fts/fts0config.cc +++ b/storage/innobase/fts/fts0config.cc @@ -119,7 +119,7 @@ fts_config_get_value( trx->op_info = "getting FTS config value"; error = fts_eval_sql(trx, graph); - fts_que_graph_free(graph); + que_graph_free(graph); return(error); } @@ -226,7 +226,7 @@ fts_config_set_value( error = fts_eval_sql(trx, graph); - fts_que_graph_free_check_lock(fts_table, NULL, graph); + que_graph_free(graph); n_rows_updated = trx->undo_no - undo_no; @@ -252,7 +252,7 @@ fts_config_set_value( error = fts_eval_sql(trx, graph); - fts_que_graph_free_check_lock(fts_table, NULL, graph); + que_graph_free(graph); } return(error); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 40a8c270a25..fd2f689825a 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -184,14 +184,6 @@ struct fts_tokenize_param_t { ulint add_pos; /*!< Added position for tokens */ }; -/** Free a query graph */ -void fts_que_graph_free(que_t *graph) -{ - dict_sys.lock(SRW_LOCK_CALL); - que_graph_free(graph); - dict_sys.unlock(); -} - /** Run SYNC on the table, i.e., write out data from the cache to the FTS auxiliary INDEX table and clear the cache at the end. @param[in,out] sync sync state @@ -886,41 +878,6 @@ fts_drop_index( } /****************************************************************//** -Free the query graph but check whether dict_sys.latch is already -held */ -void -fts_que_graph_free_check_lock( -/*==========================*/ - fts_table_t* fts_table, /*!< in: FTS table */ - const fts_index_cache_t*index_cache, /*!< in: FTS index cache */ - que_t* graph) /*!< in: query graph */ -{ - bool has_dict = FALSE; - - if (fts_table && fts_table->table) { - ut_ad(fts_table->table->fts); - - has_dict = fts_table->table->fts->dict_locked; - } else if (index_cache) { - ut_ad(index_cache->index->table->fts); - - has_dict = index_cache->index->table->fts->dict_locked; - } - - if (!has_dict) { - dict_sys.lock(SRW_LOCK_CALL); - } - - ut_ad(dict_sys.locked()); - - que_graph_free(graph); - - if (!has_dict) { - dict_sys.unlock(); - } -} - -/****************************************************************//** Create an FTS index cache. */ CHARSET_INFO* fts_index_get_charset( @@ -1067,18 +1024,14 @@ fts_cache_clear( if (index_cache->ins_graph[j] != NULL) { - fts_que_graph_free_check_lock( - NULL, index_cache, - index_cache->ins_graph[j]); + que_graph_free(index_cache->ins_graph[j]); index_cache->ins_graph[j] = NULL; } if (index_cache->sel_graph[j] != NULL) { - fts_que_graph_free_check_lock( - NULL, index_cache, - index_cache->sel_graph[j]); + que_graph_free(index_cache->sel_graph[j]); index_cache->sel_graph[j] = NULL; } @@ -2608,7 +2561,7 @@ retry: error = fts_eval_sql(trx, graph); - fts_que_graph_free_check_lock(&fts_table, NULL, graph); + que_graph_free(graph); // FIXME: We need to retry deadlock errors if (error != DB_SUCCESS) { @@ -2724,7 +2677,7 @@ fts_update_sync_doc_id( error = fts_eval_sql(trx, graph); - fts_que_graph_free_check_lock(&fts_table, NULL, graph); + que_graph_free(graph); if (local_trx) { if (UNIV_LIKELY(error == DB_SUCCESS)) { @@ -2866,7 +2819,7 @@ fts_delete( error = fts_eval_sql(trx, graph); - fts_que_graph_free(graph); + que_graph_free(graph); } else { pars_info_free(info); } @@ -3741,7 +3694,7 @@ fts_doc_fetch_by_doc_id( trx->free(); if (!get_doc) { - fts_que_graph_free(graph); + que_graph_free(graph); } return(error); @@ -3870,7 +3823,7 @@ fts_sync_add_deleted_cache( error = fts_eval_sql(sync->trx, graph); } - fts_que_graph_free(graph); + que_graph_free(graph); return(error); } @@ -4169,18 +4122,14 @@ fts_sync_rollback( if (index_cache->ins_graph[j] != NULL) { - fts_que_graph_free_check_lock( - NULL, index_cache, - index_cache->ins_graph[j]); + que_graph_free(index_cache->ins_graph[j]); index_cache->ins_graph[j] = NULL; } if (index_cache->sel_graph[j] != NULL) { - fts_que_graph_free_check_lock( - NULL, index_cache, - index_cache->sel_graph[j]); + que_graph_free(index_cache->sel_graph[j]); index_cache->sel_graph[j] = NULL; } @@ -4744,7 +4693,7 @@ fts_get_docs_clear( ut_a(get_doc->index_cache); - fts_que_graph_free(get_doc->get_document_graph); + que_graph_free(get_doc->get_document_graph); get_doc->get_document_graph = NULL; } } @@ -4892,7 +4841,7 @@ fts_get_rows_count( } } - fts_que_graph_free(graph); + que_graph_free(graph); trx->free(); @@ -4992,7 +4941,7 @@ fts_savepoint_free( /* The default savepoint name must be NULL. */ if (ftt->docs_added_graph) { - fts_que_graph_free(ftt->docs_added_graph); + que_graph_free(ftt->docs_added_graph); } /* NOTE: We are responsible for free'ing the node */ diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index 2fcbf9b28e3..7f7c23aee8f 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -892,7 +892,7 @@ fts_index_fetch_words( } } - fts_que_graph_free(graph); + que_graph_free(graph); /* Check if max word to fetch is exceeded */ if (optim->zip->n_words >= n_words) { @@ -1005,7 +1005,7 @@ fts_table_fetch_doc_ids( error = fts_eval_sql(trx, graph); fts_sql_commit(trx); - fts_que_graph_free(graph); + que_graph_free(graph); if (error == DB_SUCCESS) { ib_vector_sort(doc_ids->doc_ids, fts_doc_id_cmp); @@ -1459,7 +1459,7 @@ fts_optimize_write_word( " when deleting a word from the FTS index."; } - fts_que_graph_free(graph); + que_graph_free(graph); graph = NULL; /* Even if the operation needs to be rolled back and redone, @@ -1491,7 +1491,7 @@ fts_optimize_write_word( } if (graph != NULL) { - fts_que_graph_free(graph); + que_graph_free(graph); } return(error); @@ -1829,7 +1829,7 @@ fts_optimize_words( charset, word->f_str, word->f_len) && graph) { - fts_que_graph_free(graph); + que_graph_free(graph); graph = NULL; } } @@ -1848,7 +1848,7 @@ fts_optimize_words( } if (graph != NULL) { - fts_que_graph_free(graph); + que_graph_free(graph); } } @@ -2081,7 +2081,7 @@ fts_optimize_purge_deleted_doc_ids( } } - fts_que_graph_free(graph); + que_graph_free(graph); return(error); } @@ -2118,7 +2118,7 @@ fts_optimize_purge_deleted_doc_id_snapshot( graph = fts_parse_sql(NULL, info, fts_end_delete_sql); error = fts_eval_sql(optim->trx, graph); - fts_que_graph_free(graph); + que_graph_free(graph); return(error); } @@ -2186,7 +2186,7 @@ fts_optimize_create_deleted_doc_id_snapshot( error = fts_eval_sql(optim->trx, graph); - fts_que_graph_free(graph); + que_graph_free(graph); if (error != DB_SUCCESS) { fts_sql_rollback(optim->trx); diff --git a/storage/innobase/fts/fts0que.cc b/storage/innobase/fts/fts0que.cc index 594faf971ad..ee9c291b02a 100644 --- a/storage/innobase/fts/fts0que.cc +++ b/storage/innobase/fts/fts0que.cc @@ -1193,7 +1193,7 @@ fts_query_difference( query->error = error; } - fts_que_graph_free(graph); + que_graph_free(graph); } /* The size can't increase. */ @@ -1317,7 +1317,7 @@ fts_query_intersect( query->error = error; } - fts_que_graph_free(graph); + que_graph_free(graph); if (query->error == DB_SUCCESS) { /* Make the intesection (rb tree) the current doc id @@ -1437,7 +1437,7 @@ fts_query_union( query->error = error; } - fts_que_graph_free(graph); + que_graph_free(graph); if (query->error == DB_SUCCESS) { @@ -2331,7 +2331,7 @@ fts_query_total_docs_containing_term( } } - fts_que_graph_free(graph); + que_graph_free(graph); return(error); } @@ -2413,7 +2413,7 @@ fts_query_terms_in_document( } } - fts_que_graph_free(graph); + que_graph_free(graph); return(error); } @@ -2504,7 +2504,7 @@ fts_query_is_in_proximity_range( /* Free the prepared statement. */ if (get_doc.get_document_graph) { - fts_que_graph_free(get_doc.get_document_graph); + que_graph_free(get_doc.get_document_graph); get_doc.get_document_graph = NULL; } @@ -2594,7 +2594,7 @@ fts_query_search_phrase( func_exit: /* Free the prepared statement. */ if (get_doc.get_document_graph) { - fts_que_graph_free(get_doc.get_document_graph); + que_graph_free(get_doc.get_document_graph); get_doc.get_document_graph = NULL; } @@ -2809,7 +2809,7 @@ fts_query_phrase_search( query->error = error; } - fts_que_graph_free(graph); + que_graph_free(graph); graph = NULL; fts_query_cache(query, token); @@ -3786,7 +3786,7 @@ fts_query_free( { if (query->read_nodes_graph) { - fts_que_graph_free(query->read_nodes_graph); + que_graph_free(query->read_nodes_graph); } if (query->root) { diff --git a/storage/innobase/handler/i_s.cc b/storage/innobase/handler/i_s.cc index ae9aa95339e..9e84e944381 100644 --- a/storage/innobase/handler/i_s.cc +++ b/storage/innobase/handler/i_s.cc @@ -2964,7 +2964,7 @@ i_s_fts_index_table_fill_selected( } } - fts_que_graph_free(graph); + que_graph_free(graph); trx->free(); diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h index 0fb01dd850e..4918b3d5747 100644 --- a/storage/innobase/include/fts0fts.h +++ b/storage/innobase/include/fts0fts.h @@ -377,9 +377,6 @@ extern ulong fts_min_token_size; need a sync to free some memory */ extern bool fts_need_sync; -/** Free a query graph */ -void fts_que_graph_free(que_t *graph); - /******************************************************************//** Create a FTS cache. */ fts_cache_t* @@ -741,16 +738,6 @@ FTS auxiliary INDEX table and clear the cache at the end. dberr_t fts_sync_table(dict_table_t* table, bool wait = true); /****************************************************************//** -Free the query graph but check whether dict_sys.latch is already -held */ -void -fts_que_graph_free_check_lock( -/*==========================*/ - fts_table_t* fts_table, /*!< in: FTS table */ - const fts_index_cache_t*index_cache, /*!< in: FTS index cache */ - que_t* graph); /*!< in: query graph */ - -/****************************************************************//** Create an FTS index cache. */ CHARSET_INFO* fts_index_get_charset( diff --git a/storage/innobase/pars/pars0sym.cc b/storage/innobase/pars/pars0sym.cc index d68e352e795..035415849a7 100644 --- a/storage/innobase/pars/pars0sym.cc +++ b/storage/innobase/pars/pars0sym.cc @@ -67,8 +67,6 @@ sym_tab_free_private( sym_node_t* sym; func_node_t* func; - ut_ad(dict_sys.locked()); - for (sym = UT_LIST_GET_FIRST(sym_tab->sym_list); sym != NULL; sym = UT_LIST_GET_NEXT(sym_list, sym)) { @@ -76,8 +74,7 @@ sym_tab_free_private( /* Close the tables opened in pars_retrieve_table_def(). */ if (sym->token_type == SYM_TABLE_REF_COUNTED) { - - dict_table_close(sym->table, TRUE, FALSE); + sym->table->release(); sym->table = NULL; sym->resolved = FALSE; diff --git a/storage/innobase/row/row0ftsort.cc b/storage/innobase/row/row0ftsort.cc index 1cae41c8987..e22b08346cc 100644 --- a/storage/innobase/row/row0ftsort.cc +++ b/storage/innobase/row/row0ftsort.cc @@ -1637,7 +1637,7 @@ row_fts_merge_insert( aux_table = dict_table_open_on_name(aux_table_name, FALSE, FALSE, DICT_ERR_IGNORE_NONE); ut_ad(aux_table != NULL); - dict_table_close(aux_table, FALSE, FALSE); + aux_table->release(); aux_index = dict_table_get_first_index(aux_table); ut_ad(!aux_index->is_instant()); |