@@ -190,6 +190,8 @@ cycle for a table. */
190190struct fts_slot_t {
191191 dict_table_t * table; /* !< Table to optimize */
192192
193+ table_id_t table_id; /* !< Table id */
194+
193195 fts_state_t state; /* !< State of this slot */
194196
195197 ulint added; /* !< Number of doc ids added since the
@@ -2575,6 +2577,8 @@ fts_optimize_add_table(
25752577 return ;
25762578 }
25772579
2580+ ut_ad (table->cached && table->fts != NULL );
2581+
25782582 /* Make sure table with FTS index cannot be evicted */
25792583 if (table->can_be_evicted ) {
25802584 dict_table_move_from_lru_to_non_lru (table);
@@ -2741,6 +2745,7 @@ fts_optimize_new_table(
27412745 memset (slot, 0x0 , sizeof (*slot));
27422746
27432747 slot->table = table;
2748+ slot->table_id = table->id ;
27442749 slot->state = FTS_STATE_LOADED;
27452750 slot->interval_time = FTS_OPTIMIZE_INTERVAL_IN_SECS;
27462751
@@ -2865,7 +2870,8 @@ fts_is_sync_needed(
28652870 slot = static_cast <const fts_slot_t *>(
28662871 ib_vector_get_const (tables, i));
28672872
2868- if (slot->table && slot->table ->fts ) {
2873+ if (slot->state != FTS_STATE_EMPTY && slot->table
2874+ && slot->table ->fts ) {
28692875 total_memory += slot->table ->fts ->cache ->total_size ;
28702876 }
28712877
@@ -3077,9 +3083,11 @@ fts_optimize_thread(
30773083 if (slot->state != FTS_STATE_EMPTY) {
30783084 dict_table_t * table = NULL ;
30793085
3080- table = dict_table_open_on_name (
3081- slot->table ->name , FALSE , FALSE ,
3082- DICT_ERR_IGNORE_INDEX_ROOT);
3086+ /* slot->table may be freed, so we try to open
3087+ table by slot->table_id.*/
3088+ table = dict_table_open_on_id (
3089+ slot->table_id , FALSE ,
3090+ DICT_TABLE_OP_NORMAL);
30833091
30843092 if (table) {
30853093
0 commit comments