Bug #72322 | Query to I_S.tables and I_S.columns leads to huge memory usage | ||
---|---|---|---|
Submitted: | 11 Apr 2014 23:52 | Modified: | 12 May 2015 12:41 |
Reporter: | Przemyslaw Malkowski | Email Updates: | |
Status: | Closed | Impact on me: | |
Category: | MySQL Server: Information schema | Severity: | S2 (Serious) |
Version: | 5.5 5.6 5.7 | OS: | Any |
Assigned to: | CPU Architecture: | Any | |
Tags: | information_schema memory leak |
[11 Apr 2014 23:52]
Przemyslaw Malkowski
[11 Apr 2014 23:53]
Przemyslaw Malkowski
simple script to create tables for test case
Attachment: create_tables.php (application/x-php, text), 937 bytes.
[11 Apr 2014 23:54]
Przemyslaw Malkowski
Massif mem profile visualized
Attachment: I_S_mem_leak_massif_visual.png (image/png, text), 330.54 KiB.
[11 Apr 2014 23:55]
Przemyslaw Malkowski
raw massif file
Attachment: massif_5.7.4.out (application/octet-stream, text), 376.15 KiB.
[14 Apr 2014 10:19]
MySQL Verification Team
Hello Przemyslaw, Thank you for the bug report and test case. Verified as described. Thanks, Umesh
[14 Apr 2014 10:21]
MySQL Verification Team
// on a 6G instance, RES reaches ~6G in no time... PID USER PR NI VIRT RES SHR S %CPU %MEM TIME+ COMMAND 16833 root 20 0 14.5g 5.6g 4092 S 93.7 92.1 15:41.38 mysqld OOMkiller invoked when it it reached ~6G
[14 Apr 2014 10:23]
MySQL Verification Team
// used 5.6.18 tar binaries
[13 Sep 2014 5:15]
Paul Namuag
Any update on this ticket? Przemyslaw have stated in his fix suggestion as follows: "Fix if this is a memory leak. Or explain why this happens otherwise." Can you please provide such comment around this one? Thanks!
[12 May 2015 12:41]
Paul DuBois
Noted in 5.5.44, 5.6.25, 5.7.8, 5.8.0 changelogs. Certain queries for the INFORMATION_SCHEMA TABLES and COLUMNS tables could lead to excessive memory use when there were large numbers of empty InnoDB tables.
[23 Jun 2015 14:09]
Laurynas Biveinis
commit c3870e089a0f9ba50adcf17c8795871132e81697 Author: V S Murthy Sidagam <venkata.sidagam@oracle.com> Date: Mon Apr 27 23:50:13 2015 +0530 Bug #18592390 QUERY TO I_S.TABLES AND I_S.COLUMNS LEADS TO HUGE MEMORY USAGE Description: On an example MySQL instance with 28k empty InnoDB tables, a specific query to information_schema.tables and information_schema.columns leads to memory consumption over 38GB RSS. Analysis: In get_all_tables() call, we fill the I_S tables from frm files and storage engine. As part of that process we call make_table_name_list() and allocate memory for all the 28k frm file names in the THD mem_root through make_lex_string_root(). Since it has been called around 28k * 28k times there is a huge memory getting hogged in THD mem_root. This causes the RSS to grow to 38GB. Fix: As part of fix we are creating a temporary mem_root in get_all_tables and passing it to fill_fiels(). There we replace the THD mem_root with the temporary mem_root and allocates the file names in temporary mem_root and frees it once we fill the I_S tables in get_all_tables and re-assign the original mem_root back to THD mem_root. Note: Checked the massif out put with the fix now the memory growth is just around 580MB at peak. commit 31c803e8d0543b330aa8e61ef878da43fe1f68f7 Author: V S Murthy Sidagam <venkata.sidagam@oracle.com> Date: Wed Apr 29 13:51:29 2015 +0530 Bug #18592390 QUERY TO I_S.TABLES AND I_S.COLUMNS LEADS TO HUGE MEMORY USAGE As part of the fix find_files() prototype has been modified and mysql-cluster uses find_files() function. Hence modified find_files() call in ha_ndbcluster_binlog.cc file to make mysql-cluster build successful.