@@ -4432,7 +4432,7 @@ static int init_common_variables()
4432
4432
min_connections= 10 ;
4433
4433
/* MyISAM requires two file handles per table. */
4434
4434
wanted_files= (extra_files + max_connections + extra_max_connections +
4435
- tc_size * 2 );
4435
+ tc_size * 2 * tc_instances );
4436
4436
#if defined(HAVE_POOL_OF_THREADS) && !defined(__WIN__)
4437
4437
// add epoll or kevent fd for each threadpool group, in case pool of threads is used
4438
4438
wanted_files+= (thread_handling > SCHEDULER_NO_THREADS) ? 0 : threadpool_size;
@@ -4461,14 +4461,22 @@ static int init_common_variables()
4461
4461
if (files < wanted_files && global_system_variables.log_warnings )
4462
4462
sql_print_warning (" Could not increase number of max_open_files to more than %u (request: %u)" , files, wanted_files);
4463
4463
4464
+ /* If we required too much tc_instances than we reduce */
4465
+ SYSVAR_AUTOSIZE_IF_CHANGED (tc_instances,
4466
+ (uint32) MY_MIN (MY_MAX ((files - extra_files -
4467
+ max_connections)/
4468
+ 2 /tc_size,
4469
+ 1 ),
4470
+ tc_instances),
4471
+ uint32);
4464
4472
/*
4465
4473
If we have requested too much file handles than we bring
4466
4474
max_connections in supported bounds. Still leave at least
4467
4475
'min_connections' connections
4468
4476
*/
4469
4477
SYSVAR_AUTOSIZE_IF_CHANGED (max_connections,
4470
4478
(ulong) MY_MAX (MY_MIN (files- extra_files-
4471
- min_tc_size*2 ,
4479
+ min_tc_size*2 *tc_instances ,
4472
4480
max_connections),
4473
4481
min_connections),
4474
4482
ulong);
@@ -4481,7 +4489,7 @@ static int init_common_variables()
4481
4489
*/
4482
4490
SYSVAR_AUTOSIZE_IF_CHANGED (tc_size,
4483
4491
(ulong) MY_MIN (MY_MAX ((files - extra_files -
4484
- max_connections) / 2 ,
4492
+ max_connections) / 2 / tc_instances ,
4485
4493
min_tc_size),
4486
4494
tc_size), ulong);
4487
4495
DBUG_PRINT (" warning" ,
0 commit comments