TheRobotLearns Platform · ProxySQL: from first install to production
Diagnosing Killed Client Connections and Session Cleanup
Learning objectives
- Distinguish kill-decision warnings from final session-cleanup warnings in ProxySQL logs.
- Correlate kill events by client address and port while accounting for log rotation.
- Investigate timeout-driven kills using effective wait timeout and transaction idle/runtime limits.
- Diagnose fast-forward kills caused by offline backends and review relevant configuration.
- Diagnose sessions with only cleanup warnings by reviewing Admin or client KILL activity.
- Use stats_mysql_commands_counters and stats_mysql_processlist to quantify/sample KILL commands, noting cumulative/snapshot limits.
Two Warnings, One Client Session
You search ProxySQL logs and find Closing killed client connection :. That message is the final cleanup for a client session ProxySQL has already marked for termination. It reports cleanup, not the original reason.
Connection termination has two log points. The first is the kill decision. Timeout-driven and some automatic conditions mark the session as killed and first log Killing client connection ... because ....
Explicit Admin session termination or a client KILL CONNECTION marks the session without that reason warning. The second point is final cleanup, when a worker removes the already-killed session and logs Closing killed client connection :.
To follow one session, correlate the messages by client address and port. Account for log rotation when matching these messages. If the complete log window contains the cleanup warning but no earlier reason warning for that connection, investigate an explicit KILL command.
Takeaway: Match cleanup and reason warnings by client address and port, and account for log rotation.
Which Timeout Caused the Kill?
You see Killing client connection ... because inactive for ms. That warning is a kill decision, not cleanup. It says ProxySQL found the client idle longer than the effective wait timeout.
ProxySQL points you to mysql-wait_timeout and a client-specific SET wait_timeout value. Timeout values are milliseconds. Compare them with the application’s connection-pool lifetime and idle-time settings before changing them.
Two other decision warnings name transaction limits. A warning about (possible) transaction idle for ms points to mysql-max_transaction_idle_time. A warning about (possible) transaction running for ms points to mysql-max_transaction_time.
These warnings are decision-phase messages. A later Closing killed client connection : line confirms only that a worker removed the killed session.
You search for the client address and port, read the because text, then open the variable the causes table names. A cleanup line alone does not identify one of these timeout causes.
Takeaway: For inactive or transaction warnings, check the named timeout variables before changing ProxySQL settings.
Fast-Forward Kills and Offline Backends
A log line contains Killing client connection ... due to 'session_fast_forward' and offline backends. This is a kill decision for a fast-forward session using an offline backend. Unlike explicit Admin or client KILL activity, this condition has its own reason warning.
ProxySQL does not label this cause as a timeout warning. The same session later produces the final cleanup message when a worker removes it. You correlate the two lines by client address and port. Account for log rotation when correlating them.
Investigate backend status first. The cause text says an offline backend is involved. The causes table lists this message with backend status and the session’s fast-forward configuration.
Then review the session’s fast-forward configuration. If you see only Closing killed client connection :, this fast-forward cause is not established. You need the earlier due-to warning, or you need to investigate explicit Admin or client KILL activity.
Takeaway: For fast-forward kills, review backend status and the session’s fast-forward configuration.
Cleanup-Only Logs and KILL Stats
You have a complete log window for one client address and port. It contains only Closing killed client connection :. That means an explicit Admin or client kill marked the session without a reason warning.
Audit logging records connection lifecycle events. It can help correlate the victim session’s authentication and close records, but it does not record query text. It cannot identify who issued KILL CONNECTION.
To capture client statements, use controlled query event logging scoped with query rules. Protect the output because it contains client activity. Also review application logs, connection-pool logs, scheduled admin jobs, health checks, and incident automation for commands targeting the same connection. Review Admin scripts and automation logs separately.
Use two stats queries to quantify and sample behavior. stats_mysql_commands_counters is cumulative. stats_mysql_processlist is only a current snapshot, so a short-lived command may not appear.
KILL QUERY can contribute to the command counter. It cancels the running backend query rather than marking the client session killed. It does not by itself explain this cleanup warning.
Do not suppress the cleanup warning until you understand the source of unexpected kills.
Takeaway: Use audit lifecycle events, query event logging, application logs, stats_mysql_commands_counters, and stats_mysql_processlist to trace cleanup-only sessions.
Tracing KILL Activity After Cleanup
-- Find cumulative KILL commands in ProxySQL stats.
SELECT *
FROM stats_mysql_commands_counters
WHERE UPPER(Command) = 'KILL';
-- Sample current process list entries whose info begins with KILL.
SELECT ThreadID, SessionID, user, cli_host, cli_port, info
FROM stats_mysql_processlist
WHERE info LIKE 'KILL%';The first query returns rows from stats_mysql_commands_counters where Command is KILL. That table is cumulative, so it can count past KILL commands. The second query returns current rows from stats_mysql_processlist where info begins with KILL. That table is only a current snapshot, so a short-lived KILL command may not appear. KILL QUERY can contribute to the first table, but it cancels the running backend query rather than marking the client session killed.
Try it: config_layer_sim
You connect to the ProxySQL Admin interface. You run SELECT * FROM stats_mysql_commands_counters WHERE UPPER(Command) = 'KILL';. You run SELECT ThreadID, SessionID, user, cli_host, cli_port, info FROM stats_mysql_processlist WHERE info LIKE 'KILL%';. You compare the cumulative counter rows with the current snapshot rows. If the first query shows KILL commands and the second query shows none, the process list may be too late to catch a short-lived command. KILL QUERY can contribute to the counter, but it cancels the running backend query rather than marking the client session killed.
Sources
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
- Killed Client Connection Warnings
Do more with an account
- Graded quizzes is available on your account.
- Saving your progress is available on your account.
- Hands-on labs is available on your account.
- AI tutoring is available on your account.