diff --git a/mysql-test/suite/innodb_fts/r/misc_debug2.result b/mysql-test/suite/innodb_fts/r/misc_debug2.result index f1ebef6175f..2587b1c74b0 100644 --- a/mysql-test/suite/innodb_fts/r/misc_debug2.result +++ b/mysql-test/suite/innodb_fts/r/misc_debug2.result @@ -11,12 +11,12 @@ DROP TABLE mdev21563; # CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; INSERT INTO t1 VALUES('mysql'), ('innodb'); -set debug_dbug="+d,fts_instrument_sync_debug"; +set debug_dbug="+d,fts_instrument_sync_request"; INSERT INTO t1 VALUES('test'); -set debug_dbug="-d,fts_instrument_sync_debug"; +set debug_dbug="-d,fts_instrument_sync_request"; INSERT INTO t1 VALUES('This is a fts issue'); # restart -set debug_dbug="+d,fts_instrument_sync_debug"; +set debug_dbug="+d,fts_instrument_sync_request"; UPDATE t1 SET f1="mariadb"; -set debug_dbug="-d,fts_instrument_sync_debug"; +set debug_dbug="-d,fts_instrument_sync_request"; DROP TABLE t1; diff --git a/mysql-test/suite/innodb_fts/t/misc_debug2.test b/mysql-test/suite/innodb_fts/t/misc_debug2.test index 1ba77f2481e..eb2f80ed24a 100644 --- a/mysql-test/suite/innodb_fts/t/misc_debug2.test +++ b/mysql-test/suite/innodb_fts/t/misc_debug2.test @@ -16,12 +16,12 @@ DROP TABLE mdev21563; --echo # CREATE TABLE t1(f1 CHAR(100), FULLTEXT idx(f1))ENGINE=InnoDB; INSERT INTO t1 VALUES('mysql'), ('innodb'); -set debug_dbug="+d,fts_instrument_sync_debug"; +set debug_dbug="+d,fts_instrument_sync_request"; INSERT INTO t1 VALUES('test'); -set debug_dbug="-d,fts_instrument_sync_debug"; +set debug_dbug="-d,fts_instrument_sync_request"; INSERT INTO t1 VALUES('This is a fts issue'); --source include/restart_mysqld.inc -set debug_dbug="+d,fts_instrument_sync_debug"; +set debug_dbug="+d,fts_instrument_sync_request"; UPDATE t1 SET f1="mariadb"; -set debug_dbug="-d,fts_instrument_sync_debug"; +set debug_dbug="-d,fts_instrument_sync_request"; DROP TABLE t1; diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index ae270bf72b2..faf598ddd72 100644 --- a/storage/innobase/fts/fts0fts.cc +++ b/storage/innobase/fts/fts0fts.cc @@ -3314,7 +3314,7 @@ fts_add_doc_by_id( dict_index_t* fts_id_index; ibool is_id_cluster; fts_cache_t* cache = ftt->table->fts->cache; - + bool need_sync= false; ut_ad(cache->get_docs); /* If Doc ID has been supplied by the user, then the table @@ -3443,7 +3443,7 @@ fts_add_doc_by_id( shouldn't hold the cache lock for longer time. So cache should sync whenever cache size exceeds 512 KB */ - bool need_sync = + need_sync = cache->total_size > 512*1024; mysql_mutex_unlock(&table->fts->cache->lock); @@ -3464,10 +3464,6 @@ fts_add_doc_by_id( need_sync= true; ); - if (need_sync) { - fts_sync_table(table); - } - mtr_start(&mtr); if (i < num_idx - 1) { @@ -3493,6 +3489,10 @@ func_exit: ut_free(pcur.old_rec_buf); mem_heap_free(heap); + + if (need_sync) { + fts_sync_table(table); + } } @@ -3898,6 +3898,7 @@ err_exit: ib::error() << "(" << error << ") writing" " word node to FTS auxiliary index table " << table->name; + break; } } @@ -3999,6 +4000,7 @@ fts_sync_commit( mysql_mutex_unlock(&cache->lock); fts_sql_commit(trx); } else { + mysql_mutex_unlock(&cache->lock); fts_sql_rollback(trx); ib::error() << "(" << error << ") during SYNC of " "table " << sync->table->name;