@@ -213,13 +213,15 @@ FTS auxiliary INDEX table and clear the cache at the end.
213
213
@param[in,out] sync sync state
214
214
@param[in] unlock_cache whether unlock cache lock when write node
215
215
@param[in] wait whether wait when a sync is in progress
216
+ @param[in] background whether sync in background
216
217
@return DB_SUCCESS if all OK */
217
218
static
218
219
dberr_t
219
220
fts_sync (
220
221
fts_sync_t * sync,
221
222
bool unlock_cache,
222
- bool wait);
223
+ bool wait,
224
+ bool background);
223
225
224
226
/* ***************************************************************/ /* *
225
227
Release all resources help by the words rb tree e.g., the node ilist. */
@@ -1032,15 +1034,16 @@ fts_words_free(
1032
1034
}
1033
1035
}
1034
1036
1035
- /* ******************************************************************* */ /* *
1036
- Clear cache. */
1037
+ /* * Clear cache.
1038
+ @param[in,out] cache fts cache */
1037
1039
void
1038
1040
fts_cache_clear (
1039
- /* ============*/
1040
- fts_cache_t * cache) /* !< in: cache */
1041
+ fts_cache_t * cache)
1041
1042
{
1042
1043
ulint i;
1043
1044
1045
+ rw_lock_x_lock (&cache->init_lock );
1046
+
1044
1047
for (i = 0 ; i < ib_vector_size (cache->indexes ); ++i) {
1045
1048
ulint j;
1046
1049
fts_index_cache_t * index_cache;
@@ -1078,6 +1081,8 @@ fts_cache_clear(
1078
1081
index_cache->doc_stats = NULL ;
1079
1082
}
1080
1083
1084
+ rw_lock_x_unlock (&cache->init_lock );
1085
+
1081
1086
mem_heap_free (static_cast <mem_heap_t *>(cache->sync_heap ->arg ));
1082
1087
cache->sync_heap ->arg = NULL ;
1083
1088
@@ -3647,7 +3652,7 @@ fts_add_doc_by_id(
3647
3652
3648
3653
DBUG_EXECUTE_IF (
3649
3654
" fts_instrument_sync_debug" ,
3650
- fts_sync (cache->sync , true , true );
3655
+ fts_sync (cache->sync , true , true , false );
3651
3656
);
3652
3657
3653
3658
DEBUG_SYNC_C (" fts_instrument_sync_request" );
@@ -4567,6 +4572,8 @@ fts_sync_rollback(
4567
4572
trx_t * trx = sync ->trx ;
4568
4573
fts_cache_t * cache = sync ->table ->fts ->cache ;
4569
4574
4575
+ rw_lock_x_lock (&cache->init_lock );
4576
+
4570
4577
for (ulint i = 0 ; i < ib_vector_size (cache->indexes ); ++i) {
4571
4578
ulint j;
4572
4579
fts_index_cache_t * index_cache;
@@ -4596,6 +4603,7 @@ fts_sync_rollback(
4596
4603
}
4597
4604
}
4598
4605
4606
+ rw_lock_x_unlock (&cache->init_lock );
4599
4607
rw_lock_x_unlock (&cache->lock );
4600
4608
4601
4609
fts_sql_rollback (trx);
@@ -4607,18 +4615,23 @@ FTS auxiliary INDEX table and clear the cache at the end.
4607
4615
@param[in,out] sync sync state
4608
4616
@param[in] unlock_cache whether unlock cache lock when write node
4609
4617
@param[in] wait whether wait when a sync is in progress
4618
+ @param[in] has_dict whether has dict operation lock, if true,
4619
+ unlock it before return.
4610
4620
@return DB_SUCCESS if all OK */
4611
4621
static
4612
4622
dberr_t
4613
4623
fts_sync (
4614
4624
fts_sync_t * sync,
4615
4625
bool unlock_cache,
4616
- bool wait)
4626
+ bool wait,
4627
+ bool has_dict)
4617
4628
{
4618
4629
ulint i;
4619
4630
dberr_t error = DB_SUCCESS;
4620
4631
fts_cache_t * cache = sync ->table ->fts ->cache ;
4621
4632
4633
+ ut_ad (!(has_dict & wait ));
4634
+
4622
4635
rw_lock_x_lock (&cache->lock );
4623
4636
4624
4637
/* Check if cache is being synced.
@@ -4630,6 +4643,10 @@ fts_sync(
4630
4643
if (wait ) {
4631
4644
os_event_wait (sync ->event );
4632
4645
} else {
4646
+ if (has_dict) {
4647
+ rw_lock_s_unlock (dict_operation_lock);
4648
+ }
4649
+
4633
4650
return (DB_SUCCESS);
4634
4651
}
4635
4652
@@ -4688,7 +4705,15 @@ fts_sync(
4688
4705
end_sync:
4689
4706
if (error == DB_SUCCESS && !sync ->interrupted ) {
4690
4707
error = fts_sync_commit (sync );
4708
+
4709
+ if (has_dict) {
4710
+ rw_lock_s_unlock (dict_operation_lock);
4711
+ }
4691
4712
} else {
4713
+ if (has_dict) {
4714
+ rw_lock_s_unlock (dict_operation_lock);
4715
+ }
4716
+
4692
4717
fts_sync_rollback (sync );
4693
4718
}
4694
4719
@@ -4716,20 +4741,26 @@ FTS auxiliary INDEX table and clear the cache at the end.
4716
4741
@param[in,out] table fts table
4717
4742
@param[in] unlock_cache whether unlock cache when write node
4718
4743
@param[in] wait whether wait for existing sync to finish
4744
+ @param[in] has_dict whether has dict operation lock, if true
4745
+ unlock it before return
4719
4746
@return DB_SUCCESS on success, error code on failure. */
4720
4747
dberr_t
4721
4748
fts_sync_table (
4722
4749
dict_table_t * table,
4723
4750
bool unlock_cache,
4724
- bool wait)
4751
+ bool wait,
4752
+ bool has_dict)
4725
4753
{
4726
4754
dberr_t err = DB_SUCCESS;
4727
4755
4728
4756
ut_ad (table->fts );
4729
4757
4730
4758
if (!dict_table_is_discarded (table) && table->fts ->cache
4731
4759
&& !dict_table_is_corrupted (table)) {
4732
- err = fts_sync (table->fts ->cache ->sync , unlock_cache, wait );
4760
+ err = fts_sync (
4761
+ table->fts ->cache ->sync , unlock_cache, wait , has_dict);
4762
+ } else if (has_dict) {
4763
+ rw_lock_s_unlock (dict_operation_lock);
4733
4764
}
4734
4765
4735
4766
return (err);
0 commit comments