Bug #86279 Information Schema - Tables : memory growing
Submitted: 11 May 2017 6:57 Modified: 11 Dec 2017 3:17
Reporter: Ivan Ma Email Updates:
Status: Verified Impact on me:
None 
Category:MySQL Server: Information schema Severity:S3 (Non-critical)
Version:5.7.15, 5.7.17 OS:Linux
Assigned to: CPU Architecture:Any
Tags: Memory Growing, out of memory

[11 May 2017 6:57] Ivan Ma
Description:
Running a query (on Information _Schema.tables (where clause) to exclude system schema, showing memory growing eventually Out-of-memory.  Number of table entries around 20,000 (40 databases with 500 tables for each db)

mysql -uroot -h127.0.0.1 -e "select concat_ws('|',ifnull(TABLE_SCHEMA,''),ifnull(TABLE_NAME,''),ifnull(ENGINE,''),ifnull(TABLE_ROWS,'0'),ifnull(DATA_LENGTH,'0'),  ifnull(INDEX_LENGTH,'0'),ifnull(DATA_FREE,'0'), ifnull(TABLE_COLLATION,''),ifnull(CREATE_TIME,''), ifnull(UPDATE_TIME,''))   from information_schema.TABLES where TABLE_SCHEMA not in ('mysql','test','information_schema','performance_schema','sys');"

How to repeat:
Please refer to attached document.

table_definition_cache=10000
table_open_cache =10000
innodb_open_files=10000
open_files_limit=10000

run the sql query every second and record the memory growing from OS and the mysqld.

mysql -uroot -h127.0.0.1 -e "select concat_ws('|',ifnull(TABLE_SCHEMA,''),ifnull(TABLE_NAME,''),ifnull(ENGINE,''),ifnull(TABLE_ROWS,'0'),ifnull(DATA_LENGTH,'0'),  ifnull(INDEX_LENGTH,'0'),ifnull(DATA_FREE,'0'), ifnull(TABLE_COLLATION,''),ifnull(CREATE_TIME,''), ifnull(UPDATE_TIME,''))   from information_schema.TABLES where TABLE_SCHEMA not in ('mysql','test','information_schema','performance_schema','sys');"

Suggested fix:
No idea but the memory is growing.
[11 May 2017 6:58] Ivan Ma
change the title with "memory growing"
[19 May 2017 14:25] MySQL Verification Team
Thank you for the bug report.
[19 Jun 2017 10:42] MySQL Verification Team
so far my opinion is that given the testcase presented,  2G ram is certainly insufficient memory for both mysqld and the OS.
[11 Dec 2017 2:57] Zhao Jianwei
Hi, guys

Is there any progress on this bug?
[29 May 2019 21:05] Christian Roser
I'm managing a huge mysql shared hosting plattform with ~ 3.5mio databases and having servers with around 2k databases mostly serving apps like wordpress, joomla and so on. 

Currentl we're planning on migrating from 5.5 to 5.7 but this bug definetly is a regression as MySQL 5.5 is not affected. I'm running a select on information_schema.tables once a day to get an inventory of data_free, data_length, index_length for each database. This query results in 70k to 100k rows and after a few days mysql will run out of memory and crash. 

This will absolutely stop us from using mysql 5.7 in a large scale.
[29 May 2019 21:07] Christian Roser
Btw I'm using 5.7.26 and this is still persisting.
[5 Nov 2021 5:32] Kaige Ye
Thanks for this report so that I can easily reproduce an OOM just by `select * from information_schema.tables`.

I did some explaination base on my investigation in https://bugs.mysql.com/bug.php?id=83047