Commit ca0c96fc authored by Monty's avatar Monty

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.
parent 4d83b015
...@@ -4458,6 +4458,7 @@ sub extract_warning_lines ($$) { ...@@ -4458,6 +4458,7 @@ sub extract_warning_lines ($$) {
qr|SSL error: Failed to set ciphers to use|, qr|SSL error: Failed to set ciphers to use|,
qr/Plugin 'InnoDB' will be forced to shutdown/, qr/Plugin 'InnoDB' will be forced to shutdown/,
qr|Could not increase number of max_open_files to more than|, 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: Error table encrypted but encryption service not available.*/,
qr/InnoDB: Could not find a valid tablespace file for*/, qr/InnoDB: Could not find a valid tablespace file for*/,
qr/InnoDB: Tablespace open failed for*/, qr/InnoDB: Tablespace open failed for*/,
......
...@@ -147,7 +147,7 @@ drop table t1; ...@@ -147,7 +147,7 @@ drop table t1;
CREATE USER mysqltest_u1@localhost; CREATE USER mysqltest_u1@localhost;
GRANT USAGE ON *.* TO 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; SET GLOBAL event_scheduler = ON;
# -- Waiting for Event Scheduler to start... # -- Waiting for Event Scheduler to start...
...@@ -191,6 +191,13 @@ event_scheduler ...@@ -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
mysqltest_u1
mysqltest_u1
mysqltest_u1
root root
# -- Resetting variables... # -- Resetting variables...
......
SET GLOBAL log_warnings=4; SET GLOBAL log_warnings=4;
SET GLOBAL max_connections=2; SET GLOBAL max_connections=10;
SELECT 1; SELECT 1;
1 1
1 1
......
...@@ -1906,9 +1906,9 @@ DROP TABLE t1; ...@@ -1906,9 +1906,9 @@ DROP TABLE t1;
# #
# BUG#48438 - crash with error in unioned query against merge table and view... # 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); 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 1
SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
......
...@@ -121,10 +121,10 @@ ...@@ -121,10 +121,10 @@
sync-relay-log 10000 sync-relay-log 10000
sync-relay-log-info 10000 sync-relay-log-info 10000
sysdate-is-now FALSE sysdate-is-now FALSE
-table-cache 431 -table-cache 421
+table-cache 2000 +table-cache 2000
table-definition-cache 400 table-definition-cache 400
-table-open-cache 431 -table-open-cache 421
+table-open-cache 2000 +table-open-cache 2000
tc-heuristic-recover OFF tc-heuristic-recover OFF
thread-cache-size 0 thread-cache-size 0
......
...@@ -1438,9 +1438,9 @@ sync-master-info 10000 ...@@ -1438,9 +1438,9 @@ sync-master-info 10000
sync-relay-log 10000 sync-relay-log 10000
sync-relay-log-info 10000 sync-relay-log-info 10000
sysdate-is-now FALSE sysdate-is-now FALSE
table-cache 431 table-cache 421
table-definition-cache 400 table-definition-cache 400
table-open-cache 431 table-open-cache 421
tc-heuristic-recover OFF tc-heuristic-recover OFF
thread-cache-size 0 thread-cache-size 0
thread-pool-idle-timeout 60 thread-pool-idle-timeout 60
......
...@@ -7946,7 +7946,7 @@ CLOSE cur1; ...@@ -7946,7 +7946,7 @@ CLOSE cur1;
end| end|
set @tmp_toc= @@table_open_cache; set @tmp_toc= @@table_open_cache;
set @tmp_tdc= @@table_definition_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; set global table_definition_cache=1;
Warnings: Warnings:
Warning 1292 Truncated incorrect table_definition_cache value: '1' Warning 1292 Truncated incorrect table_definition_cache value: '1'
......
...@@ -748,10 +748,10 @@ Warnings: ...@@ -748,10 +748,10 @@ Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '-1' Warning 1292 Truncated incorrect table_open_cache value: '-1'
SHOW VARIABLES LIKE 'table_open_cache'; SHOW VARIABLES LIKE 'table_open_cache';
Variable_name Value Variable_name Value
table_open_cache 1 table_open_cache 10
SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache'; SELECT * FROM INFORMATION_SCHEMA.SESSION_VARIABLES WHERE VARIABLE_NAME LIKE 'table_open_cache';
VARIABLE_NAME VARIABLE_VALUE VARIABLE_NAME VARIABLE_VALUE
TABLE_OPEN_CACHE 1 TABLE_OPEN_CACHE 10
SET GLOBAL table_open_cache=DEFAULT; SET GLOBAL table_open_cache=DEFAULT;
set character_set_results=NULL; set character_set_results=NULL;
select ifnull(@@character_set_results,"really null"); select ifnull(@@character_set_results,"really null");
......
...@@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0 ...@@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0
FIRST_ERROR_SEEN set FIRST_ERROR_SEEN set
LAST_ERROR_SEEN set LAST_ERROR_SEEN set
set global max_user_connections = 0; set global max_user_connections = 0;
set global max_connections = 3; set global max_connections = 10;
flush user_resources; flush user_resources;
select "Con4a is alive"; select "Con4a is alive";
Con4a is alive Con4a is alive
......
...@@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0 ...@@ -525,7 +525,7 @@ COUNT_UNKNOWN_ERRORS 0
FIRST_ERROR_SEEN set FIRST_ERROR_SEEN set
LAST_ERROR_SEEN set LAST_ERROR_SEEN set
set global max_user_connections = 0; set global max_user_connections = 0;
set global max_connections = 3; set global max_connections = 10;
flush user_resources; flush user_resources;
select "Con4a is alive"; select "Con4a is alive";
Con4a is alive Con4a is alive
......
...@@ -176,9 +176,17 @@ disconnect con4c; ...@@ -176,9 +176,17 @@ disconnect con4c;
--source ../include/wait_for_pfs_thread_count.inc --source ../include/wait_for_pfs_thread_count.inc
set global max_user_connections = 0; set global max_user_connections = 0;
set global max_connections = 3; set global max_connections = 10;
flush user_resources; 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,); connect (con5a,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive"; select "Con4a is alive";
select current_user(); select current_user();
...@@ -233,6 +241,13 @@ connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,); ...@@ -233,6 +241,13 @@ connect (con5d,"127.0.0.1",quota,,test,$MASTER_MYPORT,);
disconnect con5a; disconnect con5a;
disconnect con5b; 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 # Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc --source ../include/wait_for_pfs_thread_count.inc
......
...@@ -177,9 +177,17 @@ disconnect con4c; ...@@ -177,9 +177,17 @@ disconnect con4c;
--source ../include/wait_for_pfs_thread_count.inc --source ../include/wait_for_pfs_thread_count.inc
set global max_user_connections = 0; set global max_user_connections = 0;
set global max_connections = 3; set global max_connections = 10;
flush user_resources; 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,); connect (con5a,"::1",quota,,test,$MASTER_MYPORT,);
select "Con4a is alive"; select "Con4a is alive";
select current_user(); select current_user();
...@@ -215,6 +223,13 @@ connect (con5d,"::1",quota,,test,$MASTER_MYPORT,); ...@@ -215,6 +223,13 @@ connect (con5d,"::1",quota,,test,$MASTER_MYPORT,);
disconnect con5a; disconnect con5a;
disconnect con5b; 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 # Wait for all disconnects
--source ../include/wait_for_pfs_thread_count.inc --source ../include/wait_for_pfs_thread_count.inc
......
...@@ -27,20 +27,24 @@ SELECT @@global.max_connections; ...@@ -27,20 +27,24 @@ SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
65536 65536
SET @@global.max_connections = 1; SET @@global.max_connections = 1;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '1'
SELECT @@global.max_connections; SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
1 10
SET @@global.max_connections = 2; SET @@global.max_connections = 2;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '2'
SELECT @@global.max_connections; SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
2 10
'#--------------------FN_DYNVARS_074_04-------------------------#' '#--------------------FN_DYNVARS_074_04-------------------------#'
SET @@global.max_connections = -1; SET @@global.max_connections = -1;
Warnings: Warnings:
Warning 1292 Truncated incorrect max_connections value: '-1' Warning 1292 Truncated incorrect max_connections value: '-1'
SELECT @@global.max_connections; SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
1 10
SET @@global.max_connections = 100000000000; SET @@global.max_connections = 100000000000;
Warnings: Warnings:
Warning 1292 Truncated incorrect max_connections value: '100000000000' Warning 1292 Truncated incorrect max_connections value: '100000000000'
...@@ -57,13 +61,13 @@ Warnings: ...@@ -57,13 +61,13 @@ Warnings:
Warning 1292 Truncated incorrect max_connections value: '-1024' Warning 1292 Truncated incorrect max_connections value: '-1024'
SELECT @@global.max_connections; SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
1 10
SET @@global.max_connections = 0; SET @@global.max_connections = 0;
Warnings: Warnings:
Warning 1292 Truncated incorrect max_connections value: '0' Warning 1292 Truncated incorrect max_connections value: '0'
SELECT @@global.max_connections; SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
1 10
SET @@global.max_connections = 100001; SET @@global.max_connections = 100001;
Warnings: Warnings:
Warning 1292 Truncated incorrect max_connections value: '100001' Warning 1292 Truncated incorrect max_connections value: '100001'
...@@ -98,15 +102,17 @@ WHERE VARIABLE_NAME='max_connections'; ...@@ -98,15 +102,17 @@ WHERE VARIABLE_NAME='max_connections';
1 1
'#---------------------FN_DYNVARS_074_07----------------------#' '#---------------------FN_DYNVARS_074_07----------------------#'
SET @@global.max_connections = TRUE; SET @@global.max_connections = TRUE;
Warnings:
Warning 1292 Truncated incorrect max_connections value: '1'
SELECT @@global.max_connections; SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
1 10
SET @@global.max_connections = FALSE; SET @@global.max_connections = FALSE;
Warnings: Warnings:
Warning 1292 Truncated incorrect max_connections value: '0' Warning 1292 Truncated incorrect max_connections value: '0'
SELECT @@global.max_connections; SELECT @@global.max_connections;
@@global.max_connections @@global.max_connections
1 10
'#---------------------FN_DYNVARS_074_08----------------------#' '#---------------------FN_DYNVARS_074_08----------------------#'
SET @@global.max_connections = 5000; SET @@global.max_connections = 5000;
SELECT @@max_connections = @@global.max_connections; SELECT @@max_connections = @@global.max_connections;
......
...@@ -1837,7 +1837,7 @@ DEFAULT_VALUE 151 ...@@ -1837,7 +1837,7 @@ DEFAULT_VALUE 151
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of simultaneous clients allowed VARIABLE_COMMENT The number of simultaneous clients allowed
NUMERIC_MIN_VALUE 1 NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 100000 NUMERIC_MAX_VALUE 100000
NUMERIC_BLOCK_SIZE 1 NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL
...@@ -3847,13 +3847,13 @@ READ_ONLY NO ...@@ -3847,13 +3847,13 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME TABLE_OPEN_CACHE VARIABLE_NAME TABLE_OPEN_CACHE
SESSION_VALUE NULL SESSION_VALUE NULL
GLOBAL_VALUE 2000 GLOBAL_VALUE 100
GLOBAL_VALUE_ORIGIN COMPILE-TIME GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 2000 DEFAULT_VALUE 2000
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of cached open tables VARIABLE_COMMENT The number of cached open tables
NUMERIC_MIN_VALUE 1 NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 1048576 NUMERIC_MAX_VALUE 1048576
NUMERIC_BLOCK_SIZE 1 NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL
......
...@@ -2019,7 +2019,7 @@ DEFAULT_VALUE 151 ...@@ -2019,7 +2019,7 @@ DEFAULT_VALUE 151
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of simultaneous clients allowed VARIABLE_COMMENT The number of simultaneous clients allowed
NUMERIC_MIN_VALUE 1 NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 100000 NUMERIC_MAX_VALUE 100000
NUMERIC_BLOCK_SIZE 1 NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL
...@@ -4547,13 +4547,13 @@ READ_ONLY NO ...@@ -4547,13 +4547,13 @@ READ_ONLY NO
COMMAND_LINE_ARGUMENT REQUIRED COMMAND_LINE_ARGUMENT REQUIRED
VARIABLE_NAME TABLE_OPEN_CACHE VARIABLE_NAME TABLE_OPEN_CACHE
SESSION_VALUE NULL SESSION_VALUE NULL
GLOBAL_VALUE 2000 GLOBAL_VALUE 100
GLOBAL_VALUE_ORIGIN COMPILE-TIME GLOBAL_VALUE_ORIGIN CONFIG
DEFAULT_VALUE 2000 DEFAULT_VALUE 2000
VARIABLE_SCOPE GLOBAL VARIABLE_SCOPE GLOBAL
VARIABLE_TYPE BIGINT UNSIGNED VARIABLE_TYPE BIGINT UNSIGNED
VARIABLE_COMMENT The number of cached open tables VARIABLE_COMMENT The number of cached open tables
NUMERIC_MIN_VALUE 1 NUMERIC_MIN_VALUE 10
NUMERIC_MAX_VALUE 1048576 NUMERIC_MAX_VALUE 1048576
NUMERIC_BLOCK_SIZE 1 NUMERIC_BLOCK_SIZE 1
ENUM_VALUE_LIST NULL ENUM_VALUE_LIST NULL
......
SET @start_value = @@global.table_open_cache ; SET @start_value = @@global.table_open_cache ;
SELECT @start_value; SELECT @start_value;
@start_value @start_value
2000 421
'#--------------------FN_DYNVARS_001_01------------------------#' '#--------------------FN_DYNVARS_001_01------------------------#'
SET @@global.table_open_cache = 99; SET @@global.table_open_cache = 99;
SET @@global.table_open_cache = DeFAULT; SET @@global.table_open_cache = DeFAULT;
...@@ -15,13 +15,17 @@ SELECT @@global.table_open_cache = 400; ...@@ -15,13 +15,17 @@ SELECT @@global.table_open_cache = 400;
0 0
'#--------------------FN_DYNVARS_001_03------------------------#' '#--------------------FN_DYNVARS_001_03------------------------#'
SET @@global.table_open_cache = 8; SET @@global.table_open_cache = 8;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '8'
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
8 10
SET @@global.table_open_cache = 1; SET @@global.table_open_cache = 1;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '1'
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
1 10
SET @@global.table_open_cache = 1073741824; SET @@global.table_open_cache = 1073741824;
Warnings: Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '1073741824' Warning 1292 Truncated incorrect table_open_cache value: '1073741824'
...@@ -42,7 +46,7 @@ Warnings: ...@@ -42,7 +46,7 @@ Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '-1' Warning 1292 Truncated incorrect table_open_cache value: '-1'
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
1 10
SET @@global.table_open_cache = 100000000000; SET @@global.table_open_cache = 100000000000;
Warnings: Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '100000000000' Warning 1292 Truncated incorrect table_open_cache value: '100000000000'
...@@ -54,13 +58,13 @@ Warnings: ...@@ -54,13 +58,13 @@ Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '-1024' Warning 1292 Truncated incorrect table_open_cache value: '-1024'
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
1 10
SET @@global.table_open_cache = 0; SET @@global.table_open_cache = 0;
Warnings: Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '0' Warning 1292 Truncated incorrect table_open_cache value: '0'
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
1 10
SET @@global.table_open_cache = 10000.01; SET @@global.table_open_cache = 10000.01;
ERROR 42000: Incorrect argument type to variable 'table_open_cache' ERROR 42000: Incorrect argument type to variable 'table_open_cache'
SET @@global.table_open_cache = ON; SET @@global.table_open_cache = ON;
...@@ -78,15 +82,17 @@ SELECT @@global.table_open_cache = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL ...@@ -78,15 +82,17 @@ SELECT @@global.table_open_cache = VARIABLE_VALUE FROM INFORMATION_SCHEMA.GLOBAL
1 1
'#---------------------FN_DYNVARS_001_09----------------------#' '#---------------------FN_DYNVARS_001_09----------------------#'
SET @@global.table_open_cache = TRUE; SET @@global.table_open_cache = TRUE;
Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '1'
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
1 10
SET @@global.table_open_cache = FALSE; SET @@global.table_open_cache = FALSE;
Warnings: Warnings:
Warning 1292 Truncated incorrect table_open_cache value: '0' Warning 1292 Truncated incorrect table_open_cache value: '0'
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
1 10
'#---------------------FN_DYNVARS_001_10----------------------#' '#---------------------FN_DYNVARS_001_10----------------------#'
SET @@global.table_open_cache = 10; SET @@global.table_open_cache = 10;
SELECT @@table_open_cache = @@global.table_open_cache ; SELECT @@table_open_cache = @@global.table_open_cache ;
...@@ -104,4 +110,4 @@ ERROR 42S22: Unknown column 'table_open_cache' in 'field list' ...@@ -104,4 +110,4 @@ ERROR 42S22: Unknown column 'table_open_cache' in 'field list'
SET @@global.table_open_cache = @start_value; SET @@global.table_open_cache = @start_value;
SELECT @@global.table_open_cache ; SELECT @@global.table_open_cache ;
@@global.table_open_cache @@global.table_open_cache
2000 421
--loose-innodb-flush-log-at-timeout=3 --loose-innodb-flush-log-at-timeout=3
--table_open_cache=200
...@@ -143,9 +143,18 @@ GRANT USAGE ON *.* TO mysqltest_u1@localhost; ...@@ -143,9 +143,18 @@ GRANT USAGE ON *.* TO mysqltest_u1@localhost;
--echo --echo
let $saved_max_connections = `SELECT @@global.max_connections`; let $saved_max_connections = `SELECT @@global.max_connections`;
SET GLOBAL max_connections = 3; SET GLOBAL max_connections = 10;
SET GLOBAL event_scheduler = ON; SET GLOBAL event_scheduler = ON;
connect (tmp_con1,localhost,mysqltest_u1,,);
connect (tmp_con2,localhost,mysqltest_u1,,);
connect (tmp_con3,localhost,mysqltest_u1,,);
connect (tmp_con4,localhost,mysqltest_u1,,);
connect (tmp_con5,localhost,mysqltest_u1,,);
connect (tmp_con6,localhost,mysqltest_u1,,);
connect (tmp_con7,localhost,mysqltest_u1,,);
connection default;
--echo --echo
--echo # -- Waiting for Event Scheduler to start... --echo # -- Waiting for Event Scheduler to start...
let $wait_condition = let $wait_condition =
...@@ -230,6 +239,13 @@ let $wait_condition = ...@@ -230,6 +239,13 @@ let $wait_condition =
--disconnect con_2 --disconnect con_2
--disconnect con_3 --disconnect con_3
--disconnect con_super_1 --disconnect con_super_1
--disconnect tmp_con1
--disconnect tmp_con2
--disconnect tmp_con3
--disconnect tmp_con4
--disconnect tmp_con5
--disconnect tmp_con6
--disconnect tmp_con7
--echo --echo
--echo # -- Restoring default connection... --echo # -- Restoring default connection...
......
...@@ -4,7 +4,16 @@ ...@@ -4,7 +4,16 @@
--source include/not_embedded.inc --source include/not_embedded.inc
SET GLOBAL log_warnings=4; SET GLOBAL log_warnings=4;
SET GLOBAL max_connections=2; SET GLOBAL max_connections=10;
--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 (tmp_con8,localhost,root,,)
--connect (con1,localhost,root,,) --connect (con1,localhost,root,,)
SELECT 1; SELECT 1;
......
...@@ -1216,9 +1216,9 @@ DROP TABLE t1; ...@@ -1216,9 +1216,9 @@ DROP TABLE t1;
--echo # --echo #
--echo # BUG#48438 - crash with error in unioned query against merge table and view... --echo # BUG#48438 - crash with error in unioned query against merge table and view...
--echo # --echo #
SET GLOBAL table_open_cache=3; SET GLOBAL table_open_cache=10;
CREATE TABLE t1(a INT); 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;
SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES SELECT TABLE_ROWS, DATA_LENGTH FROM INFORMATION_SCHEMA.TABLES
WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1'; WHERE TABLE_SCHEMA='test' AND TABLE_NAME='t1';
DROP TABLE t1; DROP TABLE t1;
......
...@@ -9408,7 +9408,7 @@ DELIMITER ;| ...@@ -9408,7 +9408,7 @@ DELIMITER ;|
set @tmp_toc= @@table_open_cache; set @tmp_toc= @@table_open_cache;
set @tmp_tdc= @@table_definition_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; set global table_definition_cache=1;
call p1(); call p1();
......
...@@ -4287,11 +4287,20 @@ static int init_common_variables() ...@@ -4287,11 +4287,20 @@ static int init_common_variables()
/* connections and databases needs lots of files */ /* connections and databases needs lots of files */
{ {
uint files, wanted_files, max_open_files; uint files, wanted_files, max_open_files, min_tc_size, extra_files,
min_connections;
ulong org_max_connections, org_tc_size;
/* Number of files reserved for temporary files */
extra_files= 30;
min_connections= 10;
/* MyISAM requires two file handles per table. */ /* MyISAM requires two file handles per table. */
wanted_files= (10 + max_connections + extra_max_connections + wanted_files= (extra_files + max_connections + extra_max_connections +
tc_size * 2); tc_size * 2);
min_tc_size= MY_MIN(tc_size, TABLE_OPEN_CACHE_MIN);
org_max_connections= max_connections;
org_tc_size= tc_size;
/* /*
We are trying to allocate no less than max_connections*5 file We are trying to allocate no less than max_connections*5 file
handles (i.e. we are trying to set the limit so that they will handles (i.e. we are trying to set the limit so that they will
...@@ -4306,38 +4315,49 @@ static int init_common_variables() ...@@ -4306,38 +4315,49 @@ static int init_common_variables()
(max_connections + extra_max_connections)*5), (max_connections + extra_max_connections)*5),
open_files_limit); open_files_limit);
files= my_set_max_open_files(max_open_files); files= my_set_max_open_files(max_open_files);
SYSVAR_AUTOSIZE_IF_CHANGED(open_files_limit, files, ulong);
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 (files < wanted_files)
{
if (!open_files_limit)
{
/* /*
If we have requested too much file handles than we bring If we have requested too much file handles than we bring
max_connections in supported bounds. max_connections in supported bounds. Still leave at least
'min_connections' connections
*/ */
SYSVAR_AUTOSIZE(max_connections, SYSVAR_AUTOSIZE_IF_CHANGED(max_connections,
(ulong) MY_MIN(files-10-TABLE_OPEN_CACHE_MIN*2, max_connections)); (ulong) MY_MAX(MY_MIN(files- extra_files-
min_tc_size*2,
max_connections),
min_connections),
ulong);
/* /*
Decrease tc_size according to max_connections, but Decrease tc_size according to max_connections, but
not below TABLE_OPEN_CACHE_MIN. Outer MY_MIN() ensures that we not below min_tc_size. Outer MY_MIN() ensures that we
never increase tc_size automatically (that could never increase tc_size automatically (that could
happen if max_connections is decreased above). happen if max_connections is decreased above).
*/ */
SYSVAR_AUTOSIZE(tc_size, SYSVAR_AUTOSIZE_IF_CHANGED(tc_size,
(ulong) MY_MIN(MY_MAX((files - 10 - max_connections) / 2, (ulong) MY_MIN(MY_MAX((files - extra_files -
TABLE_OPEN_CACHE_MIN), tc_size)); max_connections) / 2,
min_tc_size),
tc_size), ulong);
DBUG_PRINT("warning", DBUG_PRINT("warning",
("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", ("Current limits: max_open_files: %u max_connections: %ld table_cache: %ld",
files, max_connections, tc_size)); files, max_connections, tc_size));
if (global_system_variables.log_warnings > 1) if (global_system_variables.log_warnings > 1 &&
sql_print_warning("Changed limits: max_open_files: %u max_connections: %ld table_cache: %ld", (max_connections < org_max_connections ||
files, max_connections, tc_size); tc_size < org_tc_size))
} sql_print_warning("Changed limits: max_open_files: %u max_connections: %lu (was %lu) table_cache: %lu (was %lu)",
else if (global_system_variables.log_warnings) files, max_connections, org_max_connections,
sql_print_warning("Could not increase number of max_open_files to more than %u (request: %u)", files, wanted_files); tc_size, org_tc_size);
}
SYSVAR_AUTOSIZE(open_files_limit, files);
} }
/*
Max_connections and tc_cache are now set.
Now we can fix other variables depending on this variable.
*/
unireg_init(opt_specialflag); /* Set up extern variabels */ unireg_init(opt_specialflag); /* Set up extern variabels */
if (!(my_default_lc_messages= if (!(my_default_lc_messages=
my_locale_by_name(lc_messages))) my_locale_by_name(lc_messages)))
......
...@@ -394,6 +394,16 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool free); ...@@ -394,6 +394,16 @@ int sql_set_variables(THD *thd, List<set_var_base> *var_list, bool free);
set_sys_var_value_origin(&VAR, sys_var::AUTO); \ set_sys_var_value_origin(&VAR, sys_var::AUTO); \
} while(0) } while(0)
#define SYSVAR_AUTOSIZE_IF_CHANGED(VAR,VAL,TYPE) \
do { \
TYPE tmp= (VAL); \
if (VAR != tmp) \
{ \
VAR= (VAL); \
set_sys_var_value_origin(&VAR, sys_var::AUTO); \
} \
} while(0)
void set_sys_var_value_origin(void *ptr, enum sys_var::where here); void set_sys_var_value_origin(void *ptr, enum sys_var::where here);
enum sys_var::where get_sys_var_value_origin(void *ptr); enum sys_var::where get_sys_var_value_origin(void *ptr);
......
...@@ -124,7 +124,7 @@ ...@@ -124,7 +124,7 @@
#define MAX_ACCEPT_RETRY 10 // Test accept this many times #define MAX_ACCEPT_RETRY 10 // Test accept this many times
#define MAX_FIELDS_BEFORE_HASH 32 #define MAX_FIELDS_BEFORE_HASH 32
#define USER_VARS_HASH_SIZE 16 #define USER_VARS_HASH_SIZE 16
#define TABLE_OPEN_CACHE_MIN 400 #define TABLE_OPEN_CACHE_MIN 200
#define TABLE_OPEN_CACHE_DEFAULT 2000 #define TABLE_OPEN_CACHE_DEFAULT 2000
#define TABLE_DEF_CACHE_DEFAULT 400 #define TABLE_DEF_CACHE_DEFAULT 400
/** /**
......
...@@ -1387,7 +1387,7 @@ static bool fix_max_connections(sys_var *self, THD *thd, enum_var_type type) ...@@ -1387,7 +1387,7 @@ static bool fix_max_connections(sys_var *self, THD *thd, enum_var_type type)
static Sys_var_ulong Sys_max_connections( static Sys_var_ulong Sys_max_connections(
"max_connections", "The number of simultaneous clients allowed", "max_connections", "The number of simultaneous clients allowed",
PARSED_EARLY GLOBAL_VAR(max_connections), CMD_LINE(REQUIRED_ARG), PARSED_EARLY GLOBAL_VAR(max_connections), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, 100000), VALID_RANGE(10, 100000),
DEFAULT(MAX_CONNECTIONS_DEFAULT), BLOCK_SIZE(1), NO_MUTEX_GUARD, DEFAULT(MAX_CONNECTIONS_DEFAULT), BLOCK_SIZE(1), NO_MUTEX_GUARD,
NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_max_connections)); NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_max_connections));
...@@ -3192,7 +3192,7 @@ static bool fix_table_open_cache(sys_var *, THD *, enum_var_type) ...@@ -3192,7 +3192,7 @@ static bool fix_table_open_cache(sys_var *, THD *, enum_var_type)
static Sys_var_ulong Sys_table_cache_size( static Sys_var_ulong Sys_table_cache_size(
"table_open_cache", "The number of cached open tables", "table_open_cache", "The number of cached open tables",
GLOBAL_VAR(tc_size), CMD_LINE(REQUIRED_ARG), GLOBAL_VAR(tc_size), CMD_LINE(REQUIRED_ARG),
VALID_RANGE(1, 1024*1024), DEFAULT(TABLE_OPEN_CACHE_DEFAULT), VALID_RANGE(10, 1024*1024), DEFAULT(TABLE_OPEN_CACHE_DEFAULT),
BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0),
ON_UPDATE(fix_table_open_cache)); ON_UPDATE(fix_table_open_cache));
......
drop table if exists t1; drop table if exists t1;
set @orig_table_open_cache = @@global.table_open_cache; set @orig_table_open_cache = @@global.table_open_cache;
create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb); create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb);
lock tables t1 read; lock tables t1 read,t1 as t2 read,t1 as t3 read, t1 as t4 read, t1 as t5 read, t1 as t6 read, t1 as t7 read, t1 as t8 read, t1 as t9 read, t1 as t10 read;
set @@global.table_open_cache = 1; set @@global.table_open_cache = 10;
begin; begin;
insert into t1 values(1),(1); insert into t1 values(1),(1);
select * from t1 where c like _ucs2 0x039C0025 collate ucs2_unicode_ci; select * from t1 where c like _ucs2 0x039C0025 collate ucs2_unicode_ci;
......
...@@ -7,8 +7,8 @@ drop table if exists t1; ...@@ -7,8 +7,8 @@ drop table if exists t1;
enable_warnings; enable_warnings;
set @orig_table_open_cache = @@global.table_open_cache; set @orig_table_open_cache = @@global.table_open_cache;
create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb); create table t1(a int) engine = tokudb partition by key(a) partitions 2 (partition p0 engine = tokudb, partition p1 engine = tokudb);
lock tables t1 read; lock tables t1 read,t1 as t2 read,t1 as t3 read, t1 as t4 read, t1 as t5 read, t1 as t6 read, t1 as t7 read, t1 as t8 read, t1 as t9 read, t1 as t10 read;
set @@global.table_open_cache = 1; set @@global.table_open_cache = 10;
begin; begin;
insert into t1 values(1),(1); insert into t1 values(1),(1);
# when the bug is present, this results in a lock wait timeout # when the bug is present, this results in a lock wait timeout
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment