diff --git a/mysql-test/main/mysqld--help.result b/mysql-test/main/mysqld--help.result index 5f97793197e5a..fadab01a0e80a 100644 --- a/mysql-test/main/mysqld--help.result +++ b/mysql-test/main/mysqld--help.result @@ -1549,6 +1549,10 @@ The following specify which files/extra groups are read (specified before remain The number of cached open tables --table-open-cache-instances=# Maximum number of table cache instances + --table-open-cache-instances-fix + Activate all table_open_cache_instances early. Can be + useful for cases when table cache warm up period is + undesired. Such as benchmarking --tc-heuristic-recover=name Decision to use in heuristic recover process. One of: OFF, COMMIT, ROLLBACK @@ -2055,6 +2059,7 @@ sysdate-is-now FALSE system-versioning-alter-history ERROR system-versioning-insert-history FALSE table-definition-cache 400 +table-open-cache-instances-fix FALSE tc-heuristic-recover OFF tcp-keepalive-interval 0 tcp-keepalive-probes 0 diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result index dce6fbcfb4b63..51bd0b183b89c 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_embedded.result @@ -3942,6 +3942,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME TABLE_OPEN_CACHE_INSTANCES_FIX +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Activate all table_open_cache_instances early. Can be useful for cases when table cache warm up period is undesired. Such as benchmarking +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST OFF,ON +READ_ONLY YES +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME TCP_KEEPALIVE_INTERVAL VARIABLE_SCOPE GLOBAL VARIABLE_TYPE INT diff --git a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result index ef501a5b2173c..298a47ae5e342 100644 --- a/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result +++ b/mysql-test/suite/sys_vars/r/sysvars_server_notembedded.result @@ -4722,6 +4722,16 @@ NUMERIC_BLOCK_SIZE 1 ENUM_VALUE_LIST NULL READ_ONLY YES COMMAND_LINE_ARGUMENT REQUIRED +VARIABLE_NAME TABLE_OPEN_CACHE_INSTANCES_FIX +VARIABLE_SCOPE GLOBAL +VARIABLE_TYPE BOOLEAN +VARIABLE_COMMENT Activate all table_open_cache_instances early. Can be useful for cases when table cache warm up period is undesired. Such as benchmarking +NUMERIC_MIN_VALUE NULL +NUMERIC_MAX_VALUE NULL +NUMERIC_BLOCK_SIZE NULL +ENUM_VALUE_LIST OFF,ON +READ_ONLY YES +COMMAND_LINE_ARGUMENT OPTIONAL VARIABLE_NAME TCP_KEEPALIVE_INTERVAL VARIABLE_SCOPE GLOBAL VARIABLE_TYPE INT diff --git a/mysql-test/suite/sys_vars/r/table_open_cache_instances_fix.result b/mysql-test/suite/sys_vars/r/table_open_cache_instances_fix.result new file mode 100644 index 0000000000000..2ff55c2d2055f --- /dev/null +++ b/mysql-test/suite/sys_vars/r/table_open_cache_instances_fix.result @@ -0,0 +1,9 @@ +SHOW VARIABLES LIKE 'table_open_cache_instances_fix'; +Variable_name Value +table_open_cache_instances_fix ON +SHOW VARIABLES LIKE 'table_open_cache_instances'; +Variable_name Value +table_open_cache_instances 4 +SHOW STATUS LIKE 'table_open_cache_active_instances'; +Variable_name Value +Table_open_cache_active_instances 4 diff --git a/mysql-test/suite/sys_vars/t/table_open_cache_instances_fix.opt b/mysql-test/suite/sys_vars/t/table_open_cache_instances_fix.opt new file mode 100644 index 0000000000000..518106e6612c1 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/table_open_cache_instances_fix.opt @@ -0,0 +1 @@ +--table-open-cache-instances-fix --table-open-cache=100 --table-open-cache-instances=4 diff --git a/mysql-test/suite/sys_vars/t/table_open_cache_instances_fix.test b/mysql-test/suite/sys_vars/t/table_open_cache_instances_fix.test new file mode 100644 index 0000000000000..80509b69487a3 --- /dev/null +++ b/mysql-test/suite/sys_vars/t/table_open_cache_instances_fix.test @@ -0,0 +1,3 @@ +SHOW VARIABLES LIKE 'table_open_cache_instances_fix'; +SHOW VARIABLES LIKE 'table_open_cache_instances'; +SHOW STATUS LIKE 'table_open_cache_active_instances'; diff --git a/sql/sys_vars.cc b/sql/sys_vars.cc index 76a5fbb9a9ecd..bdab8b6f5f8e8 100644 --- a/sql/sys_vars.cc +++ b/sql/sys_vars.cc @@ -4299,6 +4299,14 @@ static Sys_var_ulong Sys_table_cache_size( BLOCK_SIZE(1), NO_MUTEX_GUARD, NOT_IN_BINLOG, ON_CHECK(0), ON_UPDATE(fix_table_open_cache)); +static Sys_var_mybool Sys_table_cache_instances_fix( + "table_open_cache_instances_fix", + "Activate all table_open_cache_instances early. Can be useful for " + "cases when table cache warm up period is undesired. Such as " + "benchmarking", + READ_ONLY GLOBAL_VAR(tc_instances_fix), CMD_LINE(OPT_ARG), + DEFAULT(FALSE)); + static Sys_var_uint Sys_table_cache_instances( "table_open_cache_instances", "Maximum number of table cache instances", READ_ONLY GLOBAL_VAR(tc_instances), CMD_LINE(REQUIRED_ARG), diff --git a/sql/table_cache.cc b/sql/table_cache.cc index 48cd63401e6f4..bc6eacf729c67 100644 --- a/sql/table_cache.cc +++ b/sql/table_cache.cc @@ -71,6 +71,7 @@ I_P_List > unused_shares; static bool tdc_inited; +my_bool tc_instances_fix; /** @@ -612,6 +613,8 @@ bool tdc_init(void) DBUG_RETURN(true); tc_allocated_size= (tc_instances + 1) * sizeof *tc; update_malloc_size(tc_allocated_size, 0); + if (tc_instances_fix) + tc_active_instances.store(tc_instances, std::memory_order_relaxed); tdc_inited= true; mysql_mutex_init(key_LOCK_unused_shares, &LOCK_unused_shares, MY_MUTEX_INIT_FAST); diff --git a/sql/table_cache.h b/sql/table_cache.h index 71704ff2ed082..30b97365c052f 100644 --- a/sql/table_cache.h +++ b/sql/table_cache.h @@ -64,6 +64,7 @@ struct TDC_element extern ulong tdc_size; extern ulong tc_size; extern uint32 tc_instances; +extern my_bool tc_instances_fix; extern bool tdc_init(void); extern void tdc_start_shutdown(void);