@@ -265,13 +265,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
265
265
@param[in,out] sync sync state
266
266
@param[in] unlock_cache whether unlock cache lock when write node
267
267
@param[in] wait whether wait when a sync is in progress
268
+ @param[in] background whether sync in background
268
269
@return DB_SUCCESS if all OK */
269
270
static
270
271
dberr_t
271
272
fts_sync (
272
273
fts_sync_t * sync,
273
274
bool unlock_cache,
274
- bool wait);
275
+ bool wait,
276
+ bool background);
275
277
276
278
/* ***************************************************************/ /* *
277
279
Release all resources help by the words rb tree e.g., the node ilist. */
@@ -1075,13 +1077,12 @@ fts_words_free(
1075
1077
}
1076
1078
}
1077
1079
1078
- /* ******************************************************************* */ /* *
1079
- Clear cache. */
1080
+ /* * Clear cache.
1081
+ @param[in,out] cache fts cache */
1080
1082
UNIV_INTERN
1081
1083
void
1082
1084
fts_cache_clear (
1083
- /* ============*/
1084
- fts_cache_t * cache) /* !< in: cache */
1085
+ fts_cache_t * cache)
1085
1086
{
1086
1087
ulint i;
1087
1088
@@ -3567,7 +3568,7 @@ fts_add_doc_by_id(
3567
3568
3568
3569
DBUG_EXECUTE_IF (
3569
3570
" fts_instrument_sync_debug" ,
3570
- fts_sync (cache->sync , true , true );
3571
+ fts_sync (cache->sync , true , true , false );
3571
3572
);
3572
3573
3573
3574
DEBUG_SYNC_C (" fts_instrument_sync_request" );
@@ -4473,13 +4474,12 @@ fts_sync_commit(
4473
4474
return (error);
4474
4475
}
4475
4476
4476
- /* ******************************************************************* */ /* *
4477
- Rollback a sync operation */
4477
+ /* * Rollback a sync operation
4478
+ @param[in,out] sync sync state */
4478
4479
static
4479
4480
void
4480
4481
fts_sync_rollback (
4481
- /* ==============*/
4482
- fts_sync_t * sync) /* !< in: sync state */
4482
+ fts_sync_t * sync)
4483
4483
{
4484
4484
trx_t * trx = sync ->trx ;
4485
4485
fts_cache_t * cache = sync ->table ->fts ->cache ;
@@ -4524,18 +4524,23 @@ FTS auxiliary INDEX table and clear the cache at the end.
4524
4524
@param[in,out] sync sync state
4525
4525
@param[in] unlock_cache whether unlock cache lock when write node
4526
4526
@param[in] wait whether wait when a sync is in progress
4527
+ @param[in] has_dict whether has dict operation lock, if true,
4528
+ unlock it before return.
4527
4529
@return DB_SUCCESS if all OK */
4528
4530
static
4529
4531
dberr_t
4530
4532
fts_sync (
4531
4533
fts_sync_t * sync,
4532
4534
bool unlock_cache,
4533
- bool wait)
4535
+ bool wait,
4536
+ bool has_dict)
4534
4537
{
4535
4538
ulint i;
4536
4539
dberr_t error = DB_SUCCESS;
4537
4540
fts_cache_t * cache = sync ->table ->fts ->cache ;
4538
4541
4542
+ ut_ad (!(has_dict & wait ));
4543
+
4539
4544
rw_lock_x_lock (&cache->lock );
4540
4545
4541
4546
/* Check if cache is being synced.
@@ -4547,6 +4552,10 @@ fts_sync(
4547
4552
if (wait ) {
4548
4553
os_event_wait (sync ->event );
4549
4554
} else {
4555
+ if (has_dict) {
4556
+ rw_lock_s_unlock (&dict_operation_lock);
4557
+ }
4558
+
4550
4559
return (DB_SUCCESS);
4551
4560
}
4552
4561
@@ -4609,7 +4618,15 @@ fts_sync(
4609
4618
end_sync:
4610
4619
if (error == DB_SUCCESS && !sync ->interrupted ) {
4611
4620
error = fts_sync_commit (sync );
4621
+
4622
+ if (has_dict) {
4623
+ rw_lock_s_unlock (&dict_operation_lock);
4624
+ }
4612
4625
} else {
4626
+ if (has_dict) {
4627
+ rw_lock_s_unlock (&dict_operation_lock);
4628
+ }
4629
+
4613
4630
fts_sync_rollback (sync );
4614
4631
}
4615
4632
@@ -4637,20 +4654,23 @@ FTS auxiliary INDEX table and clear the cache at the end.
4637
4654
@param[in,out] table fts table
4638
4655
@param[in] unlock_cache whether unlock cache when write node
4639
4656
@param[in] wait whether wait for existing sync to finish
4657
+ @param[in] has_dict whether has dict operation lock, if true
4658
+ unlock it before return
4640
4659
@return DB_SUCCESS on success, error code on failure. */
4641
4660
UNIV_INTERN
4642
4661
dberr_t
4643
4662
fts_sync_table (
4644
4663
dict_table_t * table,
4645
4664
bool unlock_cache,
4646
- bool wait)
4665
+ bool wait,
4666
+ bool has_dict)
4647
4667
{
4648
4668
dberr_t err = DB_SUCCESS;
4649
4669
4650
4670
ut_ad (table->fts );
4651
4671
4652
4672
if (!dict_table_is_discarded (table) && table->fts ->cache ) {
4653
- err = fts_sync (table->fts ->cache ->sync , unlock_cache, wait );
4673
+ err = fts_sync (table->fts ->cache ->sync , unlock_cache, wait , has_dict );
4654
4674
}
4655
4675
4656
4676
return (err);
0 commit comments