@@ -265,13 +265,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
265265@param[in,out] sync sync state
266266@param[in] unlock_cache whether unlock cache lock when write node
267267@param[in] wait whether wait when a sync is in progress
268+ @param[in] has_dict whether has dict operation lock
268269@return DB_SUCCESS if all OK */
269270static
270271dberr_t
271272fts_sync (
272273 fts_sync_t * sync,
273274 bool unlock_cache,
274- bool wait);
275+ bool wait,
276+ bool has_dict);
275277
276278/* ***************************************************************/ /* *
277279Release all resources help by the words rb tree e.g., the node ilist. */
@@ -3566,7 +3568,7 @@ fts_add_doc_by_id(
35663568
35673569 DBUG_EXECUTE_IF (
35683570 " fts_instrument_sync_debug" ,
3569- fts_sync (cache->sync , true , true );
3571+ fts_sync (cache->sync , true , true , false );
35703572 );
35713573
35723574 DEBUG_SYNC_C (" fts_instrument_sync_request" );
@@ -4467,6 +4469,8 @@ fts_sync_commit(
44674469 (double ) n_nodes/ (double ) elapsed_time);
44684470 }
44694471
4472+ /* Avoid assertion in trx_free(). */
4473+ trx->dict_operation_lock_mode = 0 ;
44704474 trx_free_for_background (trx);
44714475
44724476 return (error);
@@ -4514,6 +4518,9 @@ fts_sync_rollback(
45144518 rw_lock_x_unlock (&cache->lock );
45154519
45164520 fts_sql_rollback (trx);
4521+
4522+ /* Avoid assertion in trx_free(). */
4523+ trx->dict_operation_lock_mode = 0 ;
45174524 trx_free_for_background (trx);
45184525}
45194526
@@ -4522,13 +4529,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
45224529@param[in,out] sync sync state
45234530@param[in] unlock_cache whether unlock cache lock when write node
45244531@param[in] wait whether wait when a sync is in progress
4532+ @param[in] has_dict whether has dict operation lock
45254533@return DB_SUCCESS if all OK */
45264534static
45274535dberr_t
45284536fts_sync (
45294537 fts_sync_t * sync,
45304538 bool unlock_cache,
4531- bool wait)
4539+ bool wait,
4540+ bool has_dict)
45324541{
45334542 ulint i;
45344543 dberr_t error = DB_SUCCESS;
@@ -4557,6 +4566,12 @@ fts_sync(
45574566 DEBUG_SYNC_C (" fts_sync_begin" );
45584567 fts_sync_begin (sync);
45594568
4569+ /* When sync in background, we hold dict operation lock
4570+ to prevent DDL like DROP INDEX, etc. */
4571+ if (has_dict) {
4572+ sync->trx ->dict_operation_lock_mode = RW_S_LATCH;
4573+ }
4574+
45604575begin_sync:
45614576 if (cache->total_size > fts_max_cache_size) {
45624577 /* Avoid the case: sync never finish when
@@ -4635,20 +4650,23 @@ FTS auxiliary INDEX table and clear the cache at the end.
46354650@param[in,out] table fts table
46364651@param[in] unlock_cache whether unlock cache when write node
46374652@param[in] wait whether wait for existing sync to finish
4653+ @param[in] has_dict whether has dict operation lock
46384654@return DB_SUCCESS on success, error code on failure. */
46394655UNIV_INTERN
46404656dberr_t
46414657fts_sync_table (
46424658 dict_table_t * table,
46434659 bool unlock_cache,
4644- bool wait)
4660+ bool wait,
4661+ bool has_dict)
46454662{
46464663 dberr_t err = DB_SUCCESS;
46474664
46484665 ut_ad (table->fts );
46494666
46504667 if (!dict_table_is_discarded (table) && table->fts ->cache ) {
4651- err = fts_sync (table->fts ->cache ->sync , unlock_cache, wait);
4668+ err = fts_sync (table->fts ->cache ->sync ,
4669+ unlock_cache, wait, has_dict);
46524670 }
46534671
46544672 return (err);
0 commit comments