MDEV-12547: InnoDB FULLTEXT index has too strict innodb_ft_result_cache_limit max limit

- Backported the MYSQL_SYSVAR_SIZE_T to 10.0
- The parameter innodb_ft_result_cache_limit was only 32 bits wide
also on 64-bit systems. Make it size_t, so that it will be 64 bits
on 64-bit systems.
- Added a test case that show how innodb_ft_result_cache_limit variables
behaves in 32bit and 64 bit system.
This commit is contained in:
Thirunarayanan Balathandayuthapani 2018-10-16 13:02:50 +05:30
parent 3c5f6aa21c
commit 1dacd5f299
17 changed files with 80 additions and 20 deletions

View file

@ -383,6 +383,18 @@ DECLARE_MYSQL_SYSVAR_SIMPLE(name, unsigned long long) = { \
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \ PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
#name, comment, check, update, &varname, def, min, max, blk } #name, comment, check, update, &varname, def, min, max, blk }
#ifdef _WIN64
#define MYSQL_SYSVAR_SIZE_T(name, varname, opt, comment, check, update, def, min, max, blk) \
DECLARE_MYSQL_SYSVAR_SIMPLE(name, size_t) = { \
PLUGIN_VAR_LONGLONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
#name, comment, check, update, &varname, def, min, max, blk }
#else
#define MYSQL_SYSVAR_SIZE_T(name, varname, opt, comment, check, update, def, min, max, blk) \
DECLARE_MYSQL_SYSVAR_SIMPLE(name, size_t) = { \
PLUGIN_VAR_LONG | PLUGIN_VAR_UNSIGNED | ((opt) & PLUGIN_VAR_MASK), \
#name, comment, check, update, &varname, def, min, max, blk }
#endif
#define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \ #define MYSQL_SYSVAR_ENUM(name, varname, opt, comment, check, update, def, typelib) \
DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \ DECLARE_MYSQL_SYSVAR_TYPELIB(name, unsigned long) = { \
PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \ PLUGIN_VAR_ENUM | ((opt) & PLUGIN_VAR_MASK), \

View file

@ -0,0 +1,9 @@
disable_query_log;
disable_warnings;
let $VERSION_COMPILE_64BIT=
`SELECT IF(@@version_compile_machine like '%64%', 1, 0)`;
enable_warnings;
enable_query_log;
if ($VERSION_COMPILE_64BIT) {
skip Need a 32 bit machine/binary;
}

View file

@ -0,0 +1,9 @@
disable_query_log;
disable_warnings;
let $VERSION_COMPILE_64BIT=
`SELECT IF(@@version_compile_machine like '%64%', 1, 0)`;
enable_warnings;
enable_query_log;
if (!$VERSION_COMPILE_64BIT) {
skip Need a 64 bit machine/binary;
}

View file

@ -0,0 +1,7 @@
set global innodb_ft_result_cache_limit=5000000000;
Warnings:
Warning 1292 Truncated incorrect innodb_ft_result_cache_limit value: '5000000000'
select @@innodb_ft_result_cache_limit;
@@innodb_ft_result_cache_limit
4294967295
set global innodb_ft_result_cache_limit=2000000000;

View file

@ -0,0 +1,5 @@
set global innodb_ft_result_cache_limit=5000000000;
select @@innodb_ft_result_cache_limit;
@@innodb_ft_result_cache_limit
5000000000
set global innodb_ft_result_cache_limit=2000000000;

View file

@ -0,0 +1,9 @@
--source include/have_32bit.inc
--source include/have_innodb.inc
let $innodb_ft_result_cache_limit_orig=`select @@innodb_ft_result_cache_limit`;
set global innodb_ft_result_cache_limit=5000000000;
select @@innodb_ft_result_cache_limit;
eval set global innodb_ft_result_cache_limit=$innodb_ft_result_cache_limit_orig;

View file

@ -0,0 +1,9 @@
--source include/have_64bit.inc
--source include/have_innodb.inc
let $innodb_ft_result_cache_limit_orig=`select @@innodb_ft_result_cache_limit`;
set global innodb_ft_result_cache_limit=5000000000;
select @@innodb_ft_result_cache_limit;
eval set global innodb_ft_result_cache_limit=$innodb_ft_result_cache_limit_orig;

View file

@ -67,7 +67,7 @@ UNIV_INTERN ulong fts_max_total_cache_size;
/** This is FTS result cache limit for each query and would be /** This is FTS result cache limit for each query and would be
a configurable variable */ a configurable variable */
UNIV_INTERN ulong fts_result_cache_limit; UNIV_INTERN size_t fts_result_cache_limit;
/** Variable specifying the maximum FTS max token size */ /** Variable specifying the maximum FTS max token size */
UNIV_INTERN ulong fts_max_token_size; UNIV_INTERN ulong fts_max_token_size;
@ -4308,7 +4308,7 @@ fts_sync_begin(
if (fts_enable_diag_print) { if (fts_enable_diag_print) {
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"FTS SYNC for table %s, deleted count: %ld size: " "FTS SYNC for table %s, deleted count: %ld size: "
"%lu bytes", "%zu bytes",
sync->table->name, sync->table->name,
ib_vector_size(cache->deleted_doc_ids), ib_vector_size(cache->deleted_doc_ids),
cache->total_size); cache->total_size);

View file

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@ -76,7 +76,7 @@ struct fts_query_t {
fts_table_t fts_index_table;/*!< FTS auxiliary index table def */ fts_table_t fts_index_table;/*!< FTS auxiliary index table def */
ulint total_size; /*!< total memory size used by query */ size_t total_size; /*!< total memory size used by query */
fts_doc_ids_t* deleted; /*!< Deleted doc ids that need to be fts_doc_ids_t* deleted; /*!< Deleted doc ids that need to be
filtered from the output */ filtered from the output */
@ -4039,7 +4039,7 @@ fts_query(
/* Log memory consumption & result size */ /* Log memory consumption & result size */
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"Full Search Memory: " "Full Search Memory: "
"%lu (bytes), Row: %lu .", "%zu (bytes), Row: %lu .",
query.total_size, query.total_size,
(*result)->rankings_by_id (*result)->rankings_by_id
? rbt_size((*result)->rankings_by_id) ? rbt_size((*result)->rankings_by_id)

View file

@ -16931,10 +16931,10 @@ static MYSQL_SYSVAR_ULONG(ft_total_cache_size, fts_max_total_cache_size,
"Total memory allocated for InnoDB Fulltext Search cache", "Total memory allocated for InnoDB Fulltext Search cache",
NULL, NULL, 640000000, 32000000, 1600000000, 0); NULL, NULL, 640000000, 32000000, 1600000000, 0);
static MYSQL_SYSVAR_ULONG(ft_result_cache_limit, fts_result_cache_limit, static MYSQL_SYSVAR_SIZE_T(ft_result_cache_limit, fts_result_cache_limit,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"InnoDB Fulltext search query result cache limit in bytes", "InnoDB Fulltext search query result cache limit in bytes",
NULL, NULL, 2000000000L, 1000000L, 4294967295UL, 0); NULL, NULL, 2000000000L, 1000000L, SIZE_T_MAX, 0);
static MYSQL_SYSVAR_ULONG(ft_min_token_size, fts_min_token_size, static MYSQL_SYSVAR_ULONG(ft_min_token_size, fts_min_token_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,

View file

@ -355,7 +355,7 @@ extern ulong fts_max_cache_size;
extern ulong fts_max_total_cache_size; extern ulong fts_max_total_cache_size;
/** Variable specifying the FTS result cache limit for each query */ /** Variable specifying the FTS result cache limit for each query */
extern ulong fts_result_cache_limit; extern size_t fts_result_cache_limit;
/** Variable specifying the maximum FTS max token size */ /** Variable specifying the maximum FTS max token size */
extern ulong fts_max_token_size; extern ulong fts_max_token_size;

View file

@ -161,7 +161,7 @@ struct fts_cache_t {
the document from the table. Each the document from the table. Each
element is of type fts_doc_t */ element is of type fts_doc_t */
ulint total_size; /*!< total size consumed by the ilist size_t total_size; /*!< total size consumed by the ilist
field of all nodes. SYNC is run field of all nodes. SYNC is run
whenever this gets too big */ whenever this gets too big */
fts_sync_t* sync; /*!< sync structure to sync data to fts_sync_t* sync; /*!< sync structure to sync data to
@ -243,7 +243,7 @@ struct fts_fetch_t {
fts_sql_callback fts_sql_callback
read_record; /*!< Callback for reading index read_record; /*!< Callback for reading index
record */ record */
ulint total_memory; /*!< Total memory used */ size_t total_memory; /*!< Total memory used */
}; };
/** For horizontally splitting an FTS auxiliary index */ /** For horizontally splitting an FTS auxiliary index */

View file

@ -67,7 +67,7 @@ UNIV_INTERN ulong fts_max_total_cache_size;
/** This is FTS result cache limit for each query and would be /** This is FTS result cache limit for each query and would be
a configurable variable */ a configurable variable */
UNIV_INTERN ulong fts_result_cache_limit; UNIV_INTERN size_t fts_result_cache_limit;
/** Variable specifying the maximum FTS max token size */ /** Variable specifying the maximum FTS max token size */
UNIV_INTERN ulong fts_max_token_size; UNIV_INTERN ulong fts_max_token_size;
@ -4308,7 +4308,7 @@ fts_sync_begin(
if (fts_enable_diag_print) { if (fts_enable_diag_print) {
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"FTS SYNC for table %s, deleted count: %ld size: " "FTS SYNC for table %s, deleted count: %ld size: "
"%lu bytes", "%zu bytes",
sync->table->name, sync->table->name,
ib_vector_size(cache->deleted_doc_ids), ib_vector_size(cache->deleted_doc_ids),
cache->total_size); cache->total_size);

View file

@ -1,7 +1,7 @@
/***************************************************************************** /*****************************************************************************
Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved. Copyright (c) 2007, 2018, Oracle and/or its affiliates. All Rights Reserved.
Copyright (c) 2017, MariaDB Corporation. Copyright (c) 2017, 2018, MariaDB Corporation.
This program is free software; you can redistribute it and/or modify it under 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 the terms of the GNU General Public License as published by the Free Software
@ -76,7 +76,7 @@ struct fts_query_t {
fts_table_t fts_index_table;/*!< FTS auxiliary index table def */ fts_table_t fts_index_table;/*!< FTS auxiliary index table def */
ulint total_size; /*!< total memory size used by query */ size_t total_size; /*!< total memory size used by query */
fts_doc_ids_t* deleted; /*!< Deleted doc ids that need to be fts_doc_ids_t* deleted; /*!< Deleted doc ids that need to be
filtered from the output */ filtered from the output */
@ -4058,7 +4058,7 @@ fts_query(
/* Log memory consumption & result size */ /* Log memory consumption & result size */
ib_logf(IB_LOG_LEVEL_INFO, ib_logf(IB_LOG_LEVEL_INFO,
"Full Search Memory: " "Full Search Memory: "
"%lu (bytes), Row: %lu .", "%zu (bytes), Row: %lu .",
query.total_size, query.total_size,
(*result)->rankings_by_id (*result)->rankings_by_id
? rbt_size((*result)->rankings_by_id) ? rbt_size((*result)->rankings_by_id)

View file

@ -18460,10 +18460,10 @@ static MYSQL_SYSVAR_ULONG(ft_total_cache_size, fts_max_total_cache_size,
"Total memory allocated for InnoDB Fulltext Search cache", "Total memory allocated for InnoDB Fulltext Search cache",
NULL, NULL, 640000000, 32000000, 1600000000, 0); NULL, NULL, 640000000, 32000000, 1600000000, 0);
static MYSQL_SYSVAR_ULONG(ft_result_cache_limit, fts_result_cache_limit, static MYSQL_SYSVAR_SIZE_T(ft_result_cache_limit, fts_result_cache_limit,
PLUGIN_VAR_RQCMDARG, PLUGIN_VAR_RQCMDARG,
"InnoDB Fulltext search query result cache limit in bytes", "InnoDB Fulltext search query result cache limit in bytes",
NULL, NULL, 2000000000L, 1000000L, 4294967295UL, 0); NULL, NULL, 2000000000L, 1000000L, SIZE_T_MAX, 0);
static MYSQL_SYSVAR_ULONG(ft_min_token_size, fts_min_token_size, static MYSQL_SYSVAR_ULONG(ft_min_token_size, fts_min_token_size,
PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY, PLUGIN_VAR_RQCMDARG | PLUGIN_VAR_READONLY,

View file

@ -355,7 +355,7 @@ extern ulong fts_max_cache_size;
extern ulong fts_max_total_cache_size; extern ulong fts_max_total_cache_size;
/** Variable specifying the FTS result cache limit for each query */ /** Variable specifying the FTS result cache limit for each query */
extern ulong fts_result_cache_limit; extern size_t fts_result_cache_limit;
/** Variable specifying the maximum FTS max token size */ /** Variable specifying the maximum FTS max token size */
extern ulong fts_max_token_size; extern ulong fts_max_token_size;

View file

@ -161,7 +161,7 @@ struct fts_cache_t {
the document from the table. Each the document from the table. Each
element is of type fts_doc_t */ element is of type fts_doc_t */
ulint total_size; /*!< total size consumed by the ilist size_t total_size; /*!< total size consumed by the ilist
field of all nodes. SYNC is run field of all nodes. SYNC is run
whenever this gets too big */ whenever this gets too big */
fts_sync_t* sync; /*!< sync structure to sync data to fts_sync_t* sync; /*!< sync structure to sync data to
@ -243,7 +243,7 @@ struct fts_fetch_t {
fts_sql_callback fts_sql_callback
read_record; /*!< Callback for reading index read_record; /*!< Callback for reading index
record */ record */
ulint total_memory; /*!< Total memory used */ size_t total_memory; /*!< Total memory used */
}; };
/** For horizontally splitting an FTS auxiliary index */ /** For horizontally splitting an FTS auxiliary index */