Bug #79414 thread_cache_size is not preallocated on server startup
Submitted: 25 Nov 2015 21:50 Modified: 13 Nov 2019 13:10
Reporter: Tyler Mitchell Email Updates:
Status: Not a Bug Impact on me:
None 
Category:MySQL Server Severity:S3 (Non-critical)
Version:5.5, 5.6 OS:Any
Assigned to: CPU Architecture:Any

[25 Nov 2015 21:50] Tyler Mitchell
Description:
thread_cache_size is not preallocated on server startup. When doing failover to set a passive MySQL node active, this can cause the newly active node to stall due to it not being able to create and cache threads fast enough to handle its workload.

Once a sufficient number of concurrent connections are made, the thread cache is populated and threads are not evicted from the cache. Therefore, this cache should simply be preallocated on startup.

How to repeat:
1. Restart MySQL and note that no threads are cached.
$ sudo service mysql start
$ mysqladmin ext | grep "Threads_cached"
| Threads_cached                                | 0           |

2. Spawn concurrent connections to MySQL.
$ thread_warmer -h localhost
2015-11-25 21:40:07,727 [INFO] Starting thread warmup for 8000 threads

3. Note that connections are now present.
$ mysqladmin ext | grep "Threads_cached"
| Threads_cached                                | 8000        |

Suggested fix:
Preallocate thread cache on server startup.
[13 Nov 2019 13:10] MySQL Verification Team
Hello Mr. Mitchell,

Thank you for your bug report.

However, this is not a bug.

Simply, there is no such thing is a preallocation of the threads. Thread cache works only after client-side created connection is closed.

Let me cite you from our 5.6 Reference Manual:
"
To enable N inactive connection threads to be cached, set thread_cache_size to N at server startup or at runtime. A connection thread becomes inactive when the client connection with which it was associated terminates.

"

Not a bug.