diff options
Diffstat (limited to 'storage/innobase/fts')
-rw-r--r-- | storage/innobase/fts/fts0config.cc | 3 | ||||
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 123 | ||||
-rw-r--r-- | storage/innobase/fts/fts0opt.cc | 31 | ||||
-rw-r--r-- | storage/innobase/fts/fts0sql.cc | 3 |
4 files changed, 45 insertions, 115 deletions
diff --git a/storage/innobase/fts/fts0config.cc b/storage/innobase/fts/fts0config.cc index e6dc414d9f8..88ce21c75aa 100644 --- a/storage/innobase/fts/fts0config.cc +++ b/storage/innobase/fts/fts0config.cc @@ -215,8 +215,7 @@ fts_config_set_value( pars_info_bind_varchar_literal(info, "value", value->f_str, value->f_len); - const bool dict_locked = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + const bool dict_locked = fts_table->table->fts->dict_locked; fts_table->suffix = "CONFIG"; fts_get_table_name(fts_table, table_name, dict_locked); diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index ba29c65145e..9366cb34304 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -459,7 +459,7 @@ fts_load_user_stopword( dberr_t error = DB_SUCCESS; ibool ret = TRUE; trx_t* trx; - ibool has_lock = fts->fts_status & TABLE_DICT_LOCKED; + ibool has_lock = fts->dict_locked; trx = trx_create(); trx->op_info = "Load user stopword table into FTS cache"; @@ -917,18 +917,16 @@ fts_que_graph_free_check_lock( const fts_index_cache_t*index_cache, /*!< in: FTS index cache */ que_t* graph) /*!< in: query graph */ { - ibool has_dict = FALSE; + bool has_dict = FALSE; if (fts_table && fts_table->table) { ut_ad(fts_table->table->fts); - has_dict = fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED; + 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->fts_status - & TABLE_DICT_LOCKED; + has_dict = index_cache->index->table->fts->dict_locked; } if (!has_dict) { @@ -2780,7 +2778,7 @@ fts_update_sync_doc_id( pars_info_bind_varchar_literal(info, "doc_id", id, id_len); fts_get_table_name(&fts_table, fts_name, - table->fts->fts_status & TABLE_DICT_LOCKED); + table->fts->dict_locked); pars_info_bind_id(info, true, "table_name", fts_name); graph = fts_parse_sql( @@ -2894,7 +2892,7 @@ fts_delete( into cache from last crash (delete Doc will not initialize the sync). Avoid any added counter accounting until the FTS cache is re-established and sync-ed */ - if (table->fts->fts_status & ADDED_TABLE_SYNCED + if (table->fts->added_synced && doc_id > cache->synced_doc_id) { mutex_enter(&table->fts->cache->deleted_lock); @@ -3357,7 +3355,7 @@ fts_add_doc_from_tuple( ut_ad(cache->get_docs); - if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!ftt->table->fts->added_synced) { fts_init_index(ftt->table, FALSE); } @@ -3442,7 +3440,7 @@ fts_add_doc_by_id( /* If Doc ID has been supplied by the user, then the table might not yet be sync-ed */ - if (!(ftt->table->fts->fts_status & ADDED_TABLE_SYNCED)) { + if (!ftt->table->fts->added_synced) { fts_init_index(ftt->table, FALSE); } @@ -4877,7 +4875,7 @@ fts_init_doc_id( fts_init_index((dict_table_t*) table, TRUE); } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; table->fts->cache->first_doc_id = max_doc_id; @@ -5287,67 +5285,6 @@ fts_cache_append_deleted_doc_ids( } /*********************************************************************//** -Wait for the background thread to start. We poll to detect change -of state, which is acceptable, since the wait should happen only -once during startup. -@return true if the thread started else FALSE (i.e timed out) */ -ibool -fts_wait_for_background_thread_to_start( -/*====================================*/ - dict_table_t* table, /*!< in: table to which the thread - is attached */ - ulint max_wait) /*!< in: time in microseconds, if - set to 0 then it disables - timeout checking */ -{ - ulint count = 0; - ibool done = FALSE; - - ut_a(max_wait == 0 || max_wait >= FTS_MAX_BACKGROUND_THREAD_WAIT); - - for (;;) { - fts_t* fts = table->fts; - - mutex_enter(&fts->bg_threads_mutex); - - if (fts->fts_status & BG_THREAD_READY) { - - done = TRUE; - } - - mutex_exit(&fts->bg_threads_mutex); - - if (!done) { - os_thread_sleep(FTS_MAX_BACKGROUND_THREAD_WAIT); - - if (max_wait > 0) { - - max_wait -= FTS_MAX_BACKGROUND_THREAD_WAIT; - - /* We ignore the residual value. */ - if (max_wait < FTS_MAX_BACKGROUND_THREAD_WAIT) { - break; - } - } - - ++count; - } else { - break; - } - - if (count >= FTS_BACKGROUND_THREAD_WAIT_COUNT) { - ib::error() << "The background thread for the FTS" - " table " << table->name - << " refuses to start"; - - count = 0; - } - } - - return(done); -} - -/*********************************************************************//** Add the FTS document id hidden column. */ void fts_add_doc_id_column( @@ -5429,8 +5366,8 @@ fts_t::fts_t( const dict_table_t* table, mem_heap_t* heap) : + in_queue(0), added_synced(0), dict_locked(0), bg_threads(0), - fts_status(0), add_wq(NULL), cache(NULL), doc_col(ULINT_UNDEFINED), @@ -5500,42 +5437,6 @@ fts_free( table->fts = NULL; } -#if 0 // TODO: Enable this in WL#6608 -/*********************************************************************//** -Signal FTS threads to initiate shutdown. */ -void -fts_start_shutdown( -/*===============*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance that needs - to be informed about shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - fts->fts_status |= BG_THREAD_STOP; - - mutex_exit(&fts->bg_threads_mutex); - -} - -/*********************************************************************//** -Wait for FTS threads to shutdown. */ -void -fts_shutdown( -/*=========*/ - dict_table_t* table, /*!< in: table with FTS indexes */ - fts_t* fts) /*!< in: fts instance to shutdown */ -{ - mutex_enter(&fts->bg_threads_mutex); - - ut_a(fts->fts_status & BG_THREAD_STOP); - - dict_table_wait_for_bg_threads_to_exit(table, 20000); - - mutex_exit(&fts->bg_threads_mutex); -} -#endif - /*********************************************************************//** Take a FTS savepoint. */ UNIV_INLINE @@ -7517,7 +7418,7 @@ fts_init_index( } rw_lock_x_unlock(&cache->init_lock); - if (table->fts->fts_status & ADDED_TABLE_SYNCED) { + if (table->fts->added_synced) { goto func_exit; } @@ -7559,7 +7460,7 @@ fts_init_index( } } - table->fts->fts_status |= ADDED_TABLE_SYNCED; + table->fts->added_synced = true; fts_get_docs_clear(cache->get_docs); diff --git a/storage/innobase/fts/fts0opt.cc b/storage/innobase/fts/fts0opt.cc index fa1e4ceb44b..8b72bac6589 100644 --- a/storage/innobase/fts/fts0opt.cc +++ b/storage/innobase/fts/fts0opt.cc @@ -2553,12 +2553,22 @@ void fts_optimize_add_table(dict_table_t* table) return; } + /* If there is no fts index present then don't add to + optimize queue. */ + if (!ib_vector_size(table->fts->indexes)) { + return; + } + /* Make sure table with FTS index cannot be evicted */ dict_table_prevent_eviction(table); msg = fts_optimize_create_msg(FTS_MSG_ADD_TABLE, table); ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + + mutex_enter(&table->fts->bg_threads_mutex); + table->fts->in_queue = true; + mutex_exit(&table->fts->bg_threads_mutex); } /**********************************************************************//** @@ -2585,6 +2595,15 @@ fts_optimize_remove_table( return; } + fts_t* fts = table->fts; + mutex_enter(&fts->bg_threads_mutex); + bool is_in_optimize_queue = fts->in_queue; + mutex_exit(&fts->bg_threads_mutex); + + if (!is_in_optimize_queue) { + return; + } + msg = fts_optimize_create_msg(FTS_MSG_DEL_TABLE, NULL); /* We will wait on this event until signalled by the consumer. */ @@ -2602,6 +2621,10 @@ fts_optimize_remove_table( os_event_wait(event); os_event_destroy(event); + + mutex_enter(&fts->bg_threads_mutex); + fts->in_queue = false; + mutex_exit(&fts->bg_threads_mutex); } /** Send sync fts cache for the table. @@ -2633,6 +2656,10 @@ fts_optimize_request_sync_table( msg->ptr = table_id; ib_wqueue_add(fts_optimize_wq, msg, msg->heap); + + mutex_enter(&table->fts->bg_threads_mutex); + table->fts->in_queue = true; + mutex_exit(&table->fts->bg_threads_mutex); } /** Add a table to fts_slots if it doesn't already exist. */ @@ -2776,6 +2803,10 @@ static void fts_optimize_sync_table(table_id_t table_id) fts_sync_table(table, false); } + DBUG_EXECUTE_IF( + "ib_optimize_wq_hang", + os_thread_sleep(6000000);); + dict_table_close(table, FALSE, FALSE); } } diff --git a/storage/innobase/fts/fts0sql.cc b/storage/innobase/fts/fts0sql.cc index f9b7a59d675..e3736f3277d 100644 --- a/storage/innobase/fts/fts0sql.cc +++ b/storage/innobase/fts/fts0sql.cc @@ -154,8 +154,7 @@ fts_parse_sql( str = ut_str3cat(fts_sql_begin, sql, fts_sql_end); dict_locked = (fts_table && fts_table->table->fts - && (fts_table->table->fts->fts_status - & TABLE_DICT_LOCKED)); + && fts_table->table->fts->dict_locked); if (!dict_locked) { ut_ad(!mutex_own(&dict_sys->mutex)); |