The server shutdown routine detected leftover threads that could not be terminated, triggering EE_FAILED_TO_KILL_ALL_THREADS (error 45).
MySQL Error 45: EE_FAILED_TO_KILL_ALL_THREADS occurs when mysqld shuts down but background threads remain alive. Restart the instance with --skip-grant-tables, inspect INFORMATION_SCHEMA.PROCESSLIST, kill lingering thread IDs, then perform a clean shutdown to resolve the issue.
Error in my_thread_global_end(): %d thread(s) did not exit. EE_FAILED_TO_KILL_ALL_THREADS was added in 8.0.13.
The exact message is: Error in my_thread_global_end(): %d thread(s) did not exit. EE_FAILED_TO_KILL_ALL_THREADS was added in 8.0.13.
It appears during server shutdown or restart.
The error signals that MySQL’s internal thread manager could not terminate every worker thread within the allowed timeout, leaving one or more threads active. The server writes the message to the error log and may exit with a non-zero status.
Ignoring the error risks data corruption, table metadata locks, or replication lag.
Fixing it quickly restores predictable shutdown behavior and stability.
.
Leftover client connections or long-running queries often keep threads alive past the shutdown signal.
When the timeout expires, MySQL reports EE_FAILED_TO_KILL_ALL_THREADS.
Background plugins or UDFs that spawn their own threads (backup utilities, audit plugins, full-text indexers) can also block shutdown if they do not respond to THD::shutdown
.
Operating-system limits such as low ulimit -n
or thread scheduling issues can delay thread cleanup long enough to trigger the error.
Bugs in earlier 8.0 releases occasionally leaked THD objects. Upgrading to the latest 8.0 series reduces that risk.
.
First, restart MySQL in restricted mode so you can investigate safely.
sudo systemctl stop mysqld
mysqld --skip-grant-tables --skip-networking &
Next, list active threads and identify any that never exit.
SELECT ID, USER, HOST, COMMAND, TIME, STATE
FROM INFORMATION_SCHEMA.PROCESSLIST
WHERE COMMAND NOT IN ('Sleep');
Terminate lingering threads.
KILL 12345;
KILL 12346;
Flush tables and perform a clean shutdown.
FLUSH TABLES WITH READ LOCK;
mysqladmin shutdown;
If a plugin causes the leak, uninstall or upgrade it, then start MySQL normally.
.
Long-running ALTER TABLE - Wait or KILL the session, then retry shutdown.
Unresponsive replication thread - Execute STOP SLAVE;
before stopping mysqld.
Third-party backup plugin - Disable the plugin and retest. Contact the vendor for a patched build.
OS resource exhaustion - Raise file descriptor and thread limits, then monitor shutdown logs.
Monitor INFORMATION_SCHEMA.PROCESSLIST
and alert when threads exceed normal lifetimes.
Always stop replication and close client pools before invoking systemctl stop mysqld
.
Patch MySQL to the latest minor version; many thread-leak defects are fixed upstream.
If you use Galaxy, the desktop SQL editor surfaces long-running queries in real time and lets you KILL sessions directly from the UI, helping you clear stuck threads before shutdown.
CR_SERVER_LOST - Client lost connection; may leave orphaned threads.
ER_QUERY_INTERRUPTED - Query killed; handle gracefully to prevent leaks.
ER_CANT_CREATE_THREAD - New thread creation failed, often preceding EE_FAILED_TO_KILL_ALL_THREADS.
No, but it indicates an unclean shutdown. Fix it quickly to avoid corruption.
A restart may mask the issue temporarily, but lingering bugs or plugins can resurface. Always investigate.
shutdown_timeout
help?Yes, a higher timeout gives threads longer to exit, but it only masks the root cause. Identify and fix lingering threads.
Galaxy highlights long-running sessions and offers one-click KILL, allowing engineers to clear stuck threads before issuing a shutdown command.