Skip to content

Commit 236f825

Browse files
sachinagarwal1111dr-m
authored andcommitted
Bug #31576731 INNODB_FT_TOTAL_CACHE_SIZE NOT CAPPED WHEN SET TO 32000000
Problem: Server throws OOM error when we execute twitter load with SELECTs for UPDATE + UPDATES, and SELECT queries on tables with full-text index. FTS cache->total_memory store count of total memory allocated to FTS cache (for all fulltext indexes on a table). For each word in fts cache, we store doc-id & word position in a node->ilist. we increment cache->total_memory with size of doc-id & word position whereas we allocate ilist in chuck of 16, 32 ,64 bytes or 1.2 times of last size. When we wil insert huge amount of data into the FTS aux index tables then collectively these small chucks for each token become huge unaccounted memory allocated for FTS cache. Fix: Incremented cache->total_memory by size of chunk allocated to node->ilist. RB: 25286 Reviewed by : Rahul Agarkar <rahul.agarkar@oracle.com> mysql/mysql-server@7ab5707
1 parent c4295b9 commit 236f825

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

storage/innobase/fts/fts0fts.cc

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*****************************************************************************
22
3-
Copyright (c) 2011, 2018, Oracle and/or its affiliates. All Rights Reserved.
4-
Copyright (c) 2016, 2020, MariaDB Corporation.
3+
Copyright (c) 2011, 2021, Oracle and/or its affiliates.
4+
Copyright (c) 2016, 2021, MariaDB Corporation.
55
66
This program is free software; you can redistribute it and/or modify it under
77
the terms of the GNU General Public License as published by the Free Software
@@ -1299,6 +1299,9 @@ fts_cache_node_add_positions(
12991299
ptr = ilist + node->ilist_size;
13001300

13011301
node->ilist_size_alloc = new_size;
1302+
if (cache) {
1303+
cache->total_size += new_size;
1304+
}
13021305
}
13031306

13041307
ptr_start = ptr;
@@ -1325,17 +1328,16 @@ fts_cache_node_add_positions(
13251328
if (node->ilist_size > 0) {
13261329
memcpy(ilist, node->ilist, node->ilist_size);
13271330
ut_free(node->ilist);
1331+
if (cache) {
1332+
cache->total_size -= node->ilist_size;
1333+
}
13281334
}
13291335

13301336
node->ilist = ilist;
13311337
}
13321338

13331339
node->ilist_size += enc_len;
13341340

1335-
if (cache) {
1336-
cache->total_size += enc_len;
1337-
}
1338-
13391341
if (node->first_doc_id == FTS_NULL_DOC_ID) {
13401342
node->first_doc_id = doc_id;
13411343
}

0 commit comments

Comments
 (0)