summaryrefslogtreecommitdiff
path: root/storage/innobase/fts/fts0fts.cc
diff options
context:
space:
mode:
authorThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-02-24 19:42:43 +0530
committerThirunarayanan Balathandayuthapani <thiru@mariadb.com>2022-02-24 22:41:23 +0530
commita76731e1a13933548ad4eaf6ee8b599cbc1260b6 (patch)
tree56bb78feb4f9df3d38f67852502793fd031fdc1e /storage/innobase/fts/fts0fts.cc
parenta6f258e47f425a3ebecf6aaba87bdfcc241dc416 (diff)
downloadmariadb-git-a76731e1a13933548ad4eaf6ee8b599cbc1260b6.tar.gz
MDEV-27913 innodb_ft_cache_size max possible value (80000000) is too small for practical purposes
- Make innodb_ft_cache_size & innodb_ft_total_cache_size are dynamic variable and increase the maximum value of innodb_ft_cache_size to 512MB for 32-bit system and 1 TB for 64-bit system and set innodb_ft_total_cache_size maximum value to 1 TB for 64-bit system. - Print warning if the fts cache exceeds the innodb_ft_cache_size and also unlock the cache if fts cache memory reduces less than innodb_ft_cache_size.
Diffstat (limited to 'storage/innobase/fts/fts0fts.cc')
-rw-r--r--storage/innobase/fts/fts0fts.cc37
1 files changed, 31 insertions, 6 deletions
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 32982256302..acab4791d8b 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -53,14 +53,26 @@ by looking up the key word in the obsolete table names */
/** This is maximum FTS cache for each table and would be
a configurable variable */
-ulong fts_max_cache_size;
+size_t fts_max_cache_size;
+
+static size_t fts_get_max_cache()
+{
+#if UNIV_WORD_SIZE == 4
+ return my_atomic_load32_explicit(&fts_max_cache_size,
+ MY_MEMORY_ORDER_RELAXED);
+#else
+ return my_atomic_load64_explicit(
+ reinterpret_cast<int64*>(&fts_max_cache_size),
+ MY_MEMORY_ORDER_RELAXED);
+#endif
+}
/** Whether the total memory used for FTS cache is exhausted, and we will
need a sync to free some memory */
bool fts_need_sync = false;
/** Variable specifying the total memory allocated for FTS cache */
-ulong fts_max_total_cache_size;
+size_t fts_max_total_cache_size;
/** This is FTS result cache limit for each query and would be
a configurable variable */
@@ -3381,7 +3393,7 @@ fts_add_doc_from_tuple(
rw_lock_x_unlock(&table->fts->cache->lock);
- if (cache->total_size > fts_max_cache_size / 5
+ if (cache->total_size > fts_get_max_cache() / 5
|| fts_need_sync) {
fts_sync(cache->sync, true, false);
}
@@ -3546,7 +3558,7 @@ fts_add_doc_by_id(
&& (fts_need_sync
|| (cache->total_size
- cache->total_size_at_sync)
- > fts_max_cache_size / 10);
+ > fts_get_max_cache() / 10);
if (need_sync) {
cache->total_size_at_sync =
cache->total_size;
@@ -4284,7 +4296,7 @@ fts_sync(
ulint i;
dberr_t error = DB_SUCCESS;
fts_cache_t* cache = sync->table->fts->cache;
-
+ size_t fts_cache_size= 0;
rw_lock_x_lock(&cache->lock);
/* Check if cache is being synced.
@@ -4309,11 +4321,17 @@ fts_sync(
fts_sync_begin(sync);
begin_sync:
- if (cache->total_size > fts_max_cache_size) {
+ fts_cache_size= fts_get_max_cache();
+ if (cache->total_size > fts_cache_size) {
/* Avoid the case: sync never finish when
insert/update keeps comming. */
ut_ad(sync->unlock_cache);
sync->unlock_cache = false;
+ ib::warn() << "Total InnoDB FTS size "
+ << cache->total_size << " for the table "
+ << cache->sync->table->name
+ << " exceeds the innodb_ft_cache_size "
+ << fts_cache_size;
}
for (i = 0; i < ib_vector_size(cache->indexes); ++i) {
@@ -4336,6 +4354,13 @@ begin_sync:
if (error != DB_SUCCESS) {
goto end_sync;
}
+
+ if (!sync->unlock_cache
+ && cache->total_size < fts_get_max_cache()) {
+ /* Reset the unlock cache if the value
+ is less than innodb_ft_cache_size */
+ sync->unlock_cache = true;
+ }
}
DBUG_EXECUTE_IF("fts_instrument_sync_interrupted",