summaryrefslogtreecommitdiff
path: root/storage
diff options
context:
space:
mode:
authorMarko Mäkelä <marko.makela@mariadb.com>2022-02-25 11:47:27 +0200
committerMarko Mäkelä <marko.makela@mariadb.com>2022-02-25 11:47:27 +0200
commitf42d6234bdc5838f140f6a4541acb17a96434ba6 (patch)
tree02046da29cb9ef24fca74709a4d4b4e1901cc0ed /storage
parent97ed3dd6df2f37d7616df3252b027e47017625c8 (diff)
parent0eabc285a3c0cf0285d569a29c549634238fbdae (diff)
downloadmariadb-git-f42d6234bdc5838f140f6a4541acb17a96434ba6.tar.gz
Merge 10.4 into 10.5 (MDEV-27913)
Diffstat (limited to 'storage')
-rw-r--r--storage/innobase/fts/fts0fts.cc21
-rw-r--r--storage/innobase/handler/ha_innodb.cc44
-rw-r--r--storage/innobase/include/fts0fts.h6
3 files changed, 58 insertions, 13 deletions
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc
index 06fea24e9f6..971ecabf5a8 100644
--- a/storage/innobase/fts/fts0fts.cc
+++ b/storage/innobase/fts/fts0fts.cc
@@ -53,14 +53,14 @@ 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;
+Atomic_relaxed<size_t> fts_max_cache_size;
/** 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;
+Atomic_relaxed<size_t> fts_max_total_cache_size;
/** This is FTS result cache limit for each query and would be
a configurable variable */
@@ -4246,7 +4246,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.
@@ -4271,11 +4271,17 @@ fts_sync(
fts_sync_begin(sync);
begin_sync:
- if (cache->total_size > fts_max_cache_size) {
+ fts_cache_size= fts_max_cache_size;
+ 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) {
@@ -4296,6 +4302,13 @@ begin_sync:
if (error != DB_SUCCESS) {
goto end_sync;
}
+
+ if (!sync->unlock_cache
+ && cache->total_size < fts_max_cache_size) {
+ /* 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",
diff --git a/storage/innobase/handler/ha_innodb.cc b/storage/innobase/handler/ha_innodb.cc
index 487a5e8526d..3e847f7d3ae 100644
--- a/storage/innobase/handler/ha_innodb.cc
+++ b/storage/innobase/handler/ha_innodb.cc
@@ -662,6 +662,18 @@ innodb_stopword_table_validate(
for update function */
struct st_mysql_value* value); /*!< in: incoming string */
+static
+void innodb_ft_cache_size_update(THD*, st_mysql_sys_var*, void*, const void* save)
+{
+ fts_max_cache_size= *static_cast<const size_t*>(save);
+}
+
+static
+void innodb_ft_total_cache_size_update(THD*, st_mysql_sys_var*, void*, const void* save)
+{
+ fts_max_total_cache_size= *static_cast<const size_t*>(save);
+}
+
static bool is_mysql_datadir_path(const char *path);
/** Validate passed-in "value" is a valid directory name.
@@ -19439,15 +19451,35 @@ static MYSQL_SYSVAR_STR(ft_aux_table, innodb_ft_aux_table,
"FTS internal auxiliary table to be checked",
innodb_ft_aux_table_validate, NULL, NULL);
-static MYSQL_SYSVAR_ULONG(ft_cache_size, fts_max_cache_size,
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+#if UNIV_WORD_SIZE == 4
+
+static MYSQL_SYSVAR_SIZE_T(ft_cache_size,
+ *reinterpret_cast<size_t*>(&fts_max_cache_size),
+ PLUGIN_VAR_RQCMDARG,
"InnoDB Fulltext search cache size in bytes",
- NULL, NULL, 8000000, 1600000, 80000000, 0);
+ NULL, innodb_ft_cache_size_update, 8000000, 1600000, 1U << 29, 0);
-static MYSQL_SYSVAR_ULONG(ft_total_cache_size, fts_max_total_cache_size,
- PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,
+static MYSQL_SYSVAR_SIZE_T(ft_total_cache_size,
+ *reinterpret_cast<size_t*>(&fts_max_total_cache_size),
+ PLUGIN_VAR_RQCMDARG,
"Total memory allocated for InnoDB Fulltext Search cache",
- NULL, NULL, 640000000, 32000000, 1600000000, 0);
+ NULL, innodb_ft_total_cache_size_update, 640000000, 32000000, 1600000000, 0);
+
+#else
+
+static MYSQL_SYSVAR_SIZE_T(ft_cache_size,
+ *reinterpret_cast<size_t*>(&fts_max_cache_size),
+ PLUGIN_VAR_RQCMDARG,
+ "InnoDB Fulltext search cache size in bytes",
+ NULL, innodb_ft_cache_size_update, 8000000, 1600000, 1ULL << 40, 0);
+
+static MYSQL_SYSVAR_SIZE_T(ft_total_cache_size,
+ *reinterpret_cast<size_t*>(&fts_max_total_cache_size),
+ PLUGIN_VAR_RQCMDARG,
+ "Total memory allocated for InnoDB Fulltext Search cache",
+ NULL, innodb_ft_total_cache_size_update, 640000000, 32000000, 1ULL << 40, 0);
+
+#endif
static MYSQL_SYSVAR_SIZE_T(ft_result_cache_limit, fts_result_cache_limit,
PLUGIN_VAR_RQCMDARG,
diff --git a/storage/innobase/include/fts0fts.h b/storage/innobase/include/fts0fts.h
index e45d6fc98f3..c9f68a2cd57 100644
--- a/storage/innobase/include/fts0fts.h
+++ b/storage/innobase/include/fts0fts.h
@@ -1,7 +1,7 @@
/*****************************************************************************
Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved.
-Copyright (c) 2016, 2021, MariaDB Corporation.
+Copyright (c) 2016, 2022, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under
the terms of the GNU General Public License as published by the Free Software
@@ -355,10 +355,10 @@ struct fts_stopword_t;
extern const char* fts_default_stopword[];
/** Variable specifying the maximum FTS cache size for each table */
-extern ulong fts_max_cache_size;
+extern Atomic_relaxed<size_t> fts_max_cache_size;
/** Variable specifying the total memory allocated for FTS cache */
-extern ulong fts_max_total_cache_size;
+extern Atomic_relaxed<size_t> fts_max_total_cache_size;
/** Variable specifying the FTS result cache limit for each query */
extern size_t fts_result_cache_limit;