Skip to content

Commit 64161c9

Browse files
author
Aakanksha Verma
committed
Bug #25289359 DML/DDL ON LARGE FULLTEXT TABLES CAUSE SEMAPHORE TIMEOUTS
AND ASSERTION/SUICIDE BACKGROUND While data from fts cache is being synced in the background, we allow fts cache lock to be released while internal sql that handles insert to aux table is performed. PROBLEM When the data from the cache that needs to be synced becomes larger than the value of fts_max_cache_size(configurable) we don't allow cache lock to be released anymore by the sync as it would never finish otherwise. FIX A middlepath would be to basically 1) Extend the timeout and let sync go on with cache lock held avoiding monitor thread to crash after 600 seconds 2) If the sync takes longer then we allow cache lock to be released by sync. Reviewed by: bin su<[email protected]> RB: 21899
1 parent df4bd0f commit 64161c9

File tree

1 file changed

+50
-4
lines changed

1 file changed

+50
-4
lines changed

storage/innobase/fts/fts0fts.cc

+50-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved.
3+
Copyright (c) 2011, 2019, Oracle and/or its affiliates. All Rights Reserved.
44
55
This program is free software; you can redistribute it and/or modify it under
66
the terms of the GNU General Public License as published by the Free Software
@@ -3554,6 +3554,7 @@ fts_add_doc_by_id(
35543554
btr_pcur_store_position(doc_pcur, &mtr);
35553555
mtr_commit(&mtr);
35563556

3557+
DEBUG_SYNC_C("fts_instrument_sync_cache_wait");
35573558
rw_lock_x_lock(&table->fts->cache->lock);
35583559

35593560
if (table->fts->cache->stopword_info.status
@@ -3576,6 +3577,13 @@ fts_add_doc_by_id(
35763577

35773578
rw_lock_x_unlock(&table->fts->cache->lock);
35783579

3580+
DBUG_EXECUTE_IF(
3581+
"fts_instrument_sync_cache_wait",
3582+
srv_fatal_semaphore_wait_threshold = 25;
3583+
fts_max_cache_size = 100;
3584+
fts_sync(cache->sync, true, true, false);
3585+
);
3586+
35793587
DBUG_EXECUTE_IF(
35803588
"fts_instrument_sync",
35813589
fts_optimize_request_sync_table(table);
@@ -3969,13 +3977,16 @@ fts_sync_add_deleted_cache(
39693977
@param[in,out] trx transaction
39703978
@param[in] index_cache index cache
39713979
@param[in] unlock_cache whether unlock cache when write node
3980+
@param[in] sync_start_time Holds the timestamp of start of sync
3981+
for deducing the length of sync time
39723982
@return DB_SUCCESS if all went well else error code */
39733983
static MY_ATTRIBUTE((nonnull, warn_unused_result))
39743984
dberr_t
39753985
fts_sync_write_words(
39763986
trx_t* trx,
39773987
fts_index_cache_t* index_cache,
3978-
bool unlock_cache)
3988+
bool unlock_cache,
3989+
ib_time_t sync_start_time)
39793990
{
39803991
fts_table_t fts_table;
39813992
ulint n_nodes = 0;
@@ -3984,6 +3995,13 @@ fts_sync_write_words(
39843995
dberr_t error = DB_SUCCESS;
39853996
ibool print_error = FALSE;
39863997
dict_table_t* table = index_cache->index->table;
3998+
/* We use this to deduce threshold value of time
3999+
that we can let sync to go on holding cache lock */
4000+
const float cutoff = 0.98;
4001+
ulint lock_threshold =
4002+
(srv_fatal_semaphore_wait_threshold % SRV_SEMAPHORE_WAIT_EXTENSION)
4003+
* cutoff;
4004+
bool timeout_extended = false;
39874005
#ifdef FTS_DOC_STATS_DEBUG
39884006
ulint n_new_words = 0;
39894007
#endif /* FTS_DOC_STATS_DEBUG */
@@ -4044,6 +4062,30 @@ fts_sync_write_words(
40444062

40454063
/*FIXME: we need to handle the error properly. */
40464064
if (error == DB_SUCCESS) {
4065+
DBUG_EXECUTE_IF("fts_instrument_sync_write",
4066+
os_thread_sleep(10000000););
4067+
4068+
if (!unlock_cache) {
4069+
ulint cache_lock_time = ut_time() - sync_start_time;
4070+
if (cache_lock_time > lock_threshold) {
4071+
if (!timeout_extended) {
4072+
os_atomic_increment_ulint(
4073+
&srv_fatal_semaphore_wait_threshold,
4074+
SRV_SEMAPHORE_WAIT_EXTENSION);
4075+
timeout_extended = true;
4076+
lock_threshold +=
4077+
SRV_SEMAPHORE_WAIT_EXTENSION;
4078+
} else {
4079+
unlock_cache = true;
4080+
os_atomic_decrement_ulint(
4081+
&srv_fatal_semaphore_wait_threshold,
4082+
SRV_SEMAPHORE_WAIT_EXTENSION);
4083+
timeout_extended = false;
4084+
4085+
}
4086+
}
4087+
}
4088+
40474089
if (unlock_cache) {
40484090
rw_lock_x_unlock(
40494091
&table->fts->cache->lock);
@@ -4054,6 +4096,9 @@ fts_sync_write_words(
40544096
&index_cache->ins_graph[selected],
40554097
&fts_table, &word->text, fts_node);
40564098

4099+
DBUG_EXECUTE_IF("fts_instrument_sync_write",
4100+
os_thread_sleep(15000000););
4101+
40574102
DEBUG_SYNC_C("fts_write_node");
40584103
DBUG_EXECUTE_IF("fts_write_node_crash",
40594104
DBUG_SUICIDE(););
@@ -4379,7 +4424,8 @@ fts_sync_index(
43794424

43804425
ut_ad(rbt_validate(index_cache->words));
43814426

4382-
error = fts_sync_write_words(sync->trx, index_cache, sync->unlock_cache);
4427+
error = fts_sync_write_words(sync->trx, index_cache, sync->unlock_cache,
4428+
sync->start_time);
43834429

43844430
#ifdef FTS_DOC_STATS_DEBUG
43854431
/* FTS_RESOLVE: the word counter info in auxiliary table "DOC_ID"
@@ -4619,7 +4665,7 @@ fts_sync(
46194665
ut_ad(sync->unlock_cache);
46204666
sync->unlock_cache = false;
46214667
}
4622-
4668+
DEBUG_SYNC_C("fts_instrument_sync");
46234669
for (i = 0; i < ib_vector_size(cache->indexes); ++i) {
46244670
fts_index_cache_t* index_cache;
46254671

0 commit comments

Comments
 (0)