Bug #93837 use lsof command found that the handle was not released and swap is used
Submitted: 7 Jan 15:06 Modified: 9 Jan 13:19
Reporter: Support 800best Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.7.21 OS:CentOS (7.4.1708)
Assigned to: CPU Architecture:Any

[7 Jan 15:06] Support 800best
Description:
executed the command lsof| grep-i delete|grep mysqld| wc -l ,I found that mysqld holds 30351 handles that have been deleted
[root@sq-mysql1 ~]# lsof|grep delete|grep mysqld|wc -l
30351

It's only 26 handles when executed lsof -p [mysqld pid]|grep -i delete|wc -l
[root@sq-mysql1 ~]# lsof -p 34225|grep delete|wc -l
26

check the number of mysql threads
[root@sq-mysql1 ~]# ps -eLlf|grep mysql|wc -l
822

All handles are like the following
mysqld    34225 48665          mysql  101u      REG              253,2            0   15865288 /Data/mysqldata_3306/MLdK5LDC (deleted)
mysqld    34225 48665          mysql  396u      REG              253,2            0   15860214 /Data/mysqldata_3306/ML8QTX9x (deleted)
mysqld    34225 48665          mysql  400u      REG              253,2            0   15865353 /Data/mysqldata_3306/MLkmTFXT (deleted)

How to repeat:
start mysql and use it
[8 Jan 2:32] Support 800best
now there is a little memory left and swap is used
[9 Jan 13:19] Sinisa Milivojevic
Hi,

What you are experiencing is not actually caused by our code. The files that you are listing are all temporary files.

Linux is unique in handling temporary files, because it has a very nice feature named "pool of temporary files". We use that feature, for the performance purposes, so that entire handling of temporary files is left to the OS. I guess that this feature can be tuned in the OS, so this is something that your sysadmin should be able to solve.

Regarding running out of the memory, it has to do with how you have configured your MySQL server and can not be a bug.