Skip to content
Permalink
Browse files
Adjust table_open_cache to avoid getting error 24 (too many open files)
MDEV--15609 engines/funcs.crash_manytables_number crashes with error 24
           (too many open files)
MDEV-10286  Adjustment of table_open_cache according to system limits
            does not work when open-files-limit option is provided

Fixed by adjusting tc_size downwards if there is not enough file
descriptors to use.

Other changes:
- Ensure that there is 30 (was 10) extra file descriptors for other usage
- Decrease TABLE_OPEN_CACHE_MIN to 200 as it's better to have a smaller
  table cache than getting error 24
- Increase minimum of max_connections and table_open_cache from 1 to 10
  as 1 is not usable for any real application, only for testing.
  • Loading branch information
montywi committed Mar 26, 2018
1 parent 4d83b01 commit ca0c96f
Show file tree
Hide file tree
Showing 29 changed files with 193 additions and 85 deletions.
@@ -4458,6 +4458,7 @@ ($$)
qr|SSL error: Failed to set ciphers to use|,
qr/Plugin 'InnoDB' will be forced to shutdown/,
qr|Could not increase number of max_open_files to more than|,
qr|Changed limits: max_open_files|,
qr/InnoDB: Error table encrypted but encryption service not available.*/,
qr/InnoDB: Could not find a valid tablespace file for*/,
qr/InnoDB: Tablespace open failed for*/,
@@ -147,7 +147,7 @@ drop table t1;
CREATE USER mysqltest_u1@localhost;
GRANT USAGE ON *.* TO mysqltest_u1@localhost;

SET GLOBAL max_connections = 3;
SET GLOBAL max_connections = 10;
SET GLOBAL event_scheduler = ON;

# -- Waiting for Event Scheduler to start...
@@ -191,6 +191,13 @@ event_scheduler
mysqltest_u1
mysqltest_u1
mysqltest_u1
mysqltest_u1
mysqltest_u1
mysqltest_u1
mysqltest_u1
mysqltest_u1
mysqltest_u1
mysqltest_u1
root

# -- Resetting variables...
@@ -1,5 +1,5 @@
SET GLOBAL log_warnings=4;
SET GLOBAL max_connections=2;
SET GLOBAL max_connections=10;
SELECT 1;
1
1
@@ -1906,9 +1906,9 @@ DROP TABLE t1;
#
# BUG#48438 - crash with error in unioned query against merge table and view...
#
SET GLOBAL table_open_cache=3;
SET GLOBAL table_open_cache=10;
CREATE TABLE t1(a INT);
SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4 FOR UPDATE;
SELECT 1 FROM t1 AS a1, t1 AS a2, t1 AS a3, t1 AS a4, t1 AS a5, t1 AS a6, t1 AS a7, t1 AS a8, t1 AS a9, t1 AS a10, t1 AS a11 FOR UPDATE;
1
SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
@@ -121,10 +121,10 @@
sync-relay-log 10000
sync-relay-log-info 10000
sysdate-is-now FALSE
-table-cache 431
-table-cache 421
+table-cache 2000
table-definition-cache 400
-table-open-cache 431
-table-open-cache 421
+table-open-cache 2000
tc-heuristic-recover OFF
thread-cache-size 0
@@ -1438,9 +1438,9 @@ sync-master-info 10000
sync-relay-log 10000
sync-relay-log-info 10000
sysdate-is-now FALSE
table-cache 431
table-cache 421
table-definition-cache 400
table-open-cache 431
table-open-cache 421
tc-heuristic-recover OFF
thread-cache-size 0
thread-pool-idle-timeout 60
@@ -7946,7 +7946,7 @@ CLOSE cur1;
end|
set @tmp_toc= @@table_open_cache;
set @tmp_tdc= @@table_definition_cache;
set global table_open_cache=1;
set global table_open_cache=10;
set global table_definition_cache=1;
Warnings:
Warning 1292 Truncated incorrect table_definition_cache value: '1'
@@ -748,10 +748,10 @@ Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '-1'
SHOW VARIABLES LIKE 'table_open_cache';
Variable_name Value
table_open_cache 1
table_open_cache 10
SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache';
VARIABLE_NAME VARIABLE_VALUE
TABLE_OPEN_CACHE 1
TABLE_OPEN_CACHE 10
SET GLOBAL table_open_cache=DEFAULT;
set character_set_results=NULL;
select ifnull(@@character_set_results,"really null");
@@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0
FIRST_ERROR_SEEN set
LAST_ERROR_SEEN set
set global max_user_connections = 0;
set global max_connections = 3;
set global max_connections = 10;
flush user_resources;
select "Con4a is alive";
Con4a is alive
@@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0
FIRST_ERROR_SEEN set
LAST_ERROR_SEEN set
set global max_user_connections = 0;
set global max_connections = 3;
set global max_connections = 10;
flush user_resources;
select "Con4a is alive";
Con4a is alive
@@ -176,9 +176,17 @@ disconnect con4c;
--source ../include/wait_for_pfs_thread_count.inc

set global max_user_connections = 0;
set global max_connections = 3;
set global max_connections = 10;
flush user_resources;

connect (tmp_con1,localhost,root,,);
connect (tmp_con2,localhost,root,,);
connect (tmp_con3,localhost,root,,);
connect (tmp_con4,localhost,root,,);
connect (tmp_con5,localhost,root,,);
connect (tmp_con6,localhost,root,,);
connect (tmp_con7,localhost,root,,);

connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive";
select current_user();
@@ -233,6 +241,13 @@ connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);

disconnect con5a;
disconnect con5b;
--disconnect tmp_con1
--disconnect tmp_con2
--disconnect tmp_con3
--disconnect tmp_con4
--disconnect tmp_con5
--disconnect tmp_con6
--disconnect tmp_con7

# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc
@@ -177,9 +177,17 @@ disconnect con4c;
--source ../include/wait_for_pfs_thread_count.inc

set global max_user_connections = 0;
set global max_connections = 3;
set global max_connections = 10;
flush user_resources;

connect (tmp_con1,localhost,root,,);
connect (tmp_con2,localhost,root,,);
connect (tmp_con3,localhost,root,,);
connect (tmp_con4,localhost,root,,);
connect (tmp_con5,localhost,root,,);
connect (tmp_con6,localhost,root,,);
connect (tmp_con7,localhost,root,,);

connect (con5a,"::1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive";
select current_user();
@@ -215,6 +223,13 @@ connect (con5d,"::1",quota,,test,$MASTER_MYPORT,);

disconnect con5a;
disconnect con5b;
--disconnect tmp_con1
--disconnect tmp_con2
--disconnect tmp_con3
--disconnect tmp_con4
--disconnect tmp_con5
--disconnect tmp_con6
--disconnect tmp_con7

# Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc
@@ -27,20 +27,24 @@ SELECT @@global.max_connections;
@@global.max_connections
65536
SET @@global.max_connections = 1;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '1'
SELECT @@global.max_connections;
@@global.max_connections
1
10
SET @@global.max_connections = 2;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '2'
SELECT @@global.max_connections;
@@global.max_connections
2
10
'#--------------------FN_DYNVARS_074_04-------------------------#'
SET @@global.max_connections = -1;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '-1'
SELECT @@global.max_connections;
@@global.max_connections
1
10
SET @@global.max_connections = 100000000000;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '100000000000'
@@ -57,13 +61,13 @@ Warnings:
Warning 1292 Truncated incorrect max_connections value: '-1024'
SELECT @@global.max_connections;
@@global.max_connections
1
10
SET @@global.max_connections = 0;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '0'
SELECT @@global.max_connections;
@@global.max_connections
1
10
SET @@global.max_connections = 100001;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '100001'
@@ -98,15 +102,17 @@ WHERE VARIABLE_NAME='max_connections';
1
'#---------------------FN_DYNVARS_074_07----------------------#'
SET @@global.max_connections = TRUE;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '1'
SELECT @@global.max_connections;
@@global.max_connections
1
10
SET @@global.max_connections = FALSE;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '0'
SELECT @@global.max_connections;
@@global.max_connections
1
10
'#---------------------FN_DYNVARS_074_08----------------------#'
SET @@global.max_connections = 5000;
SELECT @@max_connections = @@global.max_connections;
@@ -1837,7 +1837,7 @@ DEFAULT_VALUE 151
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of simultaneous clients allowed
NUMERIC_MIN_VALUE 1
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 100000
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
@@ -3847,13 +3847,13 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME TABLE_OPEN_CACHE
SESSION_VALUE NULL
GLOBAL_VALUE 2000
GLOBAL_VALUE_ORIGIN COMPILE-TIME
GLOBAL_VALUE 100
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 2000
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of cached open tables
NUMERIC_MIN_VALUE 1
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 1048576
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
@@ -2019,7 +2019,7 @@ DEFAULT_VALUE 151
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of simultaneous clients allowed
NUMERIC_MIN_VALUE 1
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 100000
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
@@ -4547,13 +4547,13 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME TABLE_OPEN_CACHE
SESSION_VALUE NULL
GLOBAL_VALUE 2000
GLOBAL_VALUE_ORIGIN COMPILE-TIME
GLOBAL_VALUE 100
GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 2000
VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of cached open tables
NUMERIC_MIN_VALUE 1
NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 1048576
NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL
@@ -1,7 +1,7 @@
SET @start_value = @@global.table_open_cache ;
SELECT @start_value;
@start_value
2000
421
'#--------------------FN_DYNVARS_001_01------------------------#'
SET @@global.table_open_cache = 99;
SET @@global.table_open_cache = DeFAULT;
@@ -15,13 +15,17 @@ SELECT @@global.table_open_cache = 400;
0
'#--------------------FN_DYNVARS_001_03------------------------#'
SET @@global.table_open_cache = 8;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '8'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
8
10
SET @@global.table_open_cache = 1;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '1'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
10
SET @@global.table_open_cache = 1073741824;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '1073741824'
@@ -42,7 +46,7 @@ Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '-1'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
10
SET @@global.table_open_cache = 100000000000;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '100000000000'
@@ -54,13 +58,13 @@ Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '-1024'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
10
SET @@global.table_open_cache = 0;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '0'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
10
SET @@global.table_open_cache = 10000.01;
ERROR 42000: Incorrect argument type to variable 'table_open_cache'
SET @@global.table_open_cache = ON;
@@ -78,15 +82,17 @@ SELECT @@global.table_open_cache = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL
1
'#---------------------FN_DYNVARS_001_09----------------------#'
SET @@global.table_open_cache = TRUE;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '1'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
10
SET @@global.table_open_cache = FALSE;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '0'
SELECT @@global.table_open_cache ;
@@global.table_open_cache
1
10
'#---------------------FN_DYNVARS_001_10----------------------#'
SET @@global.table_open_cache = 10;
SELECT @@table_open_cache = @@global.table_open_cache ;
@@ -104,4 +110,4 @@ ERROR 42S22: Unknown column 'table_open_cache' in 'field list'
SET @@global.table_open_cache = @start_value;
SELECT @@global.table_open_cache ;
@@global.table_open_cache
2000
421
@@ -1 +1,2 @@
--loose-innodb-flush-log-at-timeout=3
--table_open_cache=200
@@ -0,0 +1 @@
--table_open_cache=100
@@ -0,0 +1 @@
--table_open_cache=100

0 comments on commit ca0c96f

Please sign in to comment.