0

Every few seconds MySQL is opening a file and not closing it, which we can see in real time by querying

SHOW GLOBAL STATUS WHERE variable_name = 'Open_files';

Looking at the open file descriptors using

sudo ls -la /proc/<pid>/fd | less

shows that these open files are mostly deleted temporary tables:

lrwx------ 1 mysql mysql 64 Apr 17 08:56 990 -> /tmp/mysql_temptable.xTHQV4 (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 991 -> /tmp/mysql_temptable.gr1swq (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 992 -> /tmp/mysql_temptable.sXackV (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 993 -> /tmp/mysql_temptable.Tom8Pa (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 994 -> /tmp/mysql_temptable.OqNhMl (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 995 -> /tmp/mysql_temptable.VOlk8X (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 996 -> /tmp/mysql_temptable.ti1nry (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 997 -> /tmp/mysql_temptable.EeXTiS (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 998 -> /tmp/mysql_temptable.r2GHks (deleted)
lrwx------ 1 mysql mysql 64 Apr 17 08:56 999 -> /tmp/mysql_temptable.NDCeta (deleted)

This is similar to the issue reported at MySQL crashing at about 70k open files, although we get a different error when MySQL runs out of file descriptors. There it's mentioned that this is fixed in 8.0.16, but who knows when that version will release. Meanwhile, we're having serious issues...

Is there any way we can find out what queries are causing these temporary tables to be created? Or is there a way to mitigate this problem in some other way?

1 Answer 1

0

We've followed the advice at What value of thread_cache_size should I use? and increased thread_cache_size, which was one of the suggested changes at MySQL crashing at about 70k open files as well. This seems to have stopped Open_files from increasing as it was before (it was increasing by 1 every few seconds).

I believe this makes sense: if the bug is that threads aren't correctly releasing certain files, then creating less threads (reusing more cached threads) could result in less files being left open. This is of course just guesswork of mine.

2
  • Please post results of SELECT @@VERSION; Thanks Apr 22, 2019 at 15:44
  • Please post results of SELECT @@thread_cache_size; May 4, 2019 at 16:48

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.