diff options
author | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-25 10:55:57 +0200 |
---|---|---|
committer | Marko Mäkelä <marko.makela@mariadb.com> | 2022-02-25 10:55:57 +0200 |
commit | 0eabc285a3c0cf0285d569a29c549634238fbdae (patch) | |
tree | 97e9ad58113e475b427fcb9672fbdf102ab02dcd /storage | |
parent | 46764652dfa7b779a058f2802fc1d4233aece79c (diff) | |
parent | 7ab3db142bffa733587f6788c13b7d057a1bc13e (diff) | |
download | mariadb-git-0eabc285a3c0cf0285d569a29c549634238fbdae.tar.gz |
Merge 10.3 into 10.4 (MDEV-27913)
Diffstat (limited to 'storage')
-rw-r--r-- | storage/innobase/fts/fts0fts.cc | 21 | ||||
-rw-r--r-- | storage/innobase/handler/ha_innodb.cc | 44 | ||||
-rw-r--r-- | storage/innobase/include/fts0fts.h | 6 |
3 files changed, 58 insertions, 13 deletions
diff --git a/storage/innobase/fts/fts0fts.cc b/storage/innobase/fts/fts0fts.cc index 156dd8e25df..0efaf794af2 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 */ @@ -4258,7 +4258,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. @@ -4283,11 +4283,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) { @@ -4310,6 +4316,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 4c356aaeefb..9143af5dbbf 100644 --- a/storage/innobase/handler/ha_innodb.cc +++ b/storage/innobase/handler/ha_innodb.cc @@ -785,6 +785,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. @@ -19466,15 +19478,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 f9c3187bee9..09f47c071da 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 @@ -352,10 +352,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; |