summaryrefslogtreecommitdiff
path: root/sql/mysqld.cc
diff options
context:
space:
mode:
authorOleksandr Byelkin <sanja@mariadb.com>2019-07-10 13:40:54 +0200
committerOleksandr Byelkin <sanja@mariadb.com>2020-02-05 15:34:02 +0100
commita241d411951f72d6cdbe8fa15a3f4c4adf7b0261 (patch)
treebea16f3b0ae07962efcbb7d9586c00673b60e052 /sql/mysqld.cc
parenta9d1324867075fd3c014d4382a48b5af29e77724 (diff)
downloadmariadb-git-a241d411951f72d6cdbe8fa15a3f4c4adf7b0261.tar.gz
MDEV-18027: Running out of file descriptors and eventual crash
For automatic number of opened files limit take into account number of table instances for table cache
Diffstat (limited to 'sql/mysqld.cc')
-rw-r--r--sql/mysqld.cc14
1 files changed, 11 insertions, 3 deletions
diff --git a/sql/mysqld.cc b/sql/mysqld.cc
index 58106add403..128dd19cbfc 100644
--- a/sql/mysqld.cc
+++ b/sql/mysqld.cc
@@ -4432,7 +4432,7 @@ static int init_common_variables()
min_connections= 10;
/* MyISAM requires two file handles per table. */
wanted_files= (extra_files + max_connections + extra_max_connections +
- tc_size * 2);
+ tc_size * 2 * tc_instances);
#if defined(HAVE_POOL_OF_THREADS) && !defined(__WIN__)
// add epoll or kevent fd for each threadpool group, in case pool of threads is used
wanted_files+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size;
@@ -4461,6 +4461,14 @@ static int init_common_variables()
if (files < wanted_files && global_system_variables.log_warnings)
sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files);
+ /* If we required too much tc_instances than we reduce */
+ SYSVAR_AUTOSIZE_IF_CHANGED(tc_instances,
+ (uint32) MY_MIN(MY_MAX((files - extra_files -
+ max_connections)/
+ 2/tc_size,
+ 1),
+ tc_instances),
+ uint32);
/*
If we have requested too much file handles than we bring
max_connections in supported bounds. Still leave at least
@@ -4468,7 +4476,7 @@ static int init_common_variables()
*/
SYSVAR_AUTOSIZE_IF_CHANGED(max_connections,
(ulong) MY_MAX(MY_MIN(files- extra_files-
- min_tc_size*2,
+ min_tc_size*2*tc_instances,
max_connections),
min_connections),
ulong);
@@ -4481,7 +4489,7 @@ static int init_common_variables()
*/
SYSVAR_AUTOSIZE_IF_CHANGED(tc_size,
(ulong) MY_MIN(MY_MAX((files - extra_files -
- max_connections) / 2,
+ max_connections) / 2 / tc_instances,
min_tc_size),
tc_size), ulong);
DBUG_PRINT("warning",