This happens because we don't adjust the size of open table cache based on the number of files we can open.
The current code adjust tc_size only if the following is true:
The code should be adjusted so that we always adjust tc_size if it's bigger than
(I think that 10 is probably too low, we may need more file descriptors for temporary files etc).
Currently the tc_size has a lower value of TABLE_OPEN_CACHE_MIN, which is 400.
I think this should be made lower to at least 200 as it's more important that we get correct operations than run faster to a problem.
- Move code for adjusting tc_size out of current block and to be always
tested. Write a warning if warning_level > 1 if it's adjusted
- Change TABLE_OPEN_CACHE_MIN to 200
- Change '10' to '30', to get a margin
- Ensure that mtr engines/funcs.crash_manytables_number works, even when
running it in a loop for a few times
When mysqld is started with systemd, the number of files that can be
opened is 64K and all of the above changes will have no affect. In
other words, this change mostly affect development and test systems
and when running mysql-test-run. It should not affect production systems.