Description:
Hi:
we os file limit fs.file-max=65535,sometime reach limit,mysqld return error Table doesn't exist and error log no obvious error reported.
An obvious error should be added,when check .frm file.
thanks.
How to repeat:
mysql client:
mysql> select version();
+------------+
| version() |
+------------+
| 5.7.40-log |
+------------+
1 row in set (0.00 sec)
mysql> show variables like '%log_error_verbosity%';
+---------------------+-------+
| Variable_name | Value |
+---------------------+-------+
| log_error_verbosity | 3 |
+---------------------+-------+
1 row in set (0.01 sec)
mysql> truncate table io;
Query OK, 0 rows affected (0.00 sec)
mysql> truncate table io;
Query OK, 0 rows affected (0.00 sec)
mysql> truncate table io;
Query OK, 0 rows affected (0.00 sec)
mysql> truncate table io;
Query OK, 0 rows affected (0.00 sec)
change os file-max
vi /etc/sysctl.conf add fs.file-max = 128
sysctl -p
back to mysql client
mysql> truncate table io;
ERROR 1146 (42S02): Table 'mytest.io' doesn't exist
mysql> drop table io;
ERROR 1051 (42S02): Unknown table 'mytest.io'
check mysql error log,no obvious error reported.
Suggested fix:
diff --git a/D:/mysqlsorce/mysqlsource/mysql-5.7.40/sql/datadict.cc b/D:/mysqlsorce/sourceb/mysql-5.7.40/sql/datadict.cc
index 1090f50..8389eb7 100644
--- a/D:/mysqlsorce/mysqlsource/mysql-5.7.40/sql/datadict.cc
+++ b/D:/mysqlsorce/sourceb/mysql-5.7.40/sql/datadict.cc
@@ -26,6 +26,7 @@
#include "pfs_file_provider.h"
#include "mysql/psi/mysql_file.h"
+#include "log.h"
/**
Check type of .frm if we are not going to parse it.
@@ -49,7 +50,9 @@ frm_type_enum dd_frm_type(THD *thd, char *path, enum legacy_db_type *dbt)
*dbt= DB_TYPE_UNKNOWN;
if ((file= mysql_file_open(key_file_frm, path, O_RDONLY | O_SHARE, MYF(0))) < 0)
- DBUG_RETURN(FRMTYPE_ERROR);
+ {sql_print_error("Error in open frm file: %s, %s", path,strerror(errno));
+ DBUG_RETURN(FRMTYPE_ERROR);}
+
error= mysql_file_read(file, (uchar*) header, sizeof(header), MYF(MY_NABP));
mysql_file_close(file, MYF(MY_WME));
2023-03-22T07:41:26.995765Z 2 [ERROR] Error in open frm file: ./t2/myt.frm, Too many open files in system
2023-03-22T07:41:36.834439Z 2 [ERROR] Error in open frm file: ./t2/myt.frm, Too many open files in system