doc/killed_client_connections_documentation.md
ProxySQL logs the message "Closing killed client connection <IP>:<PORT>" as a final cleanup step when a client session that has already been marked for termination is removed from a worker thread. This warning appears only after the session has been marked as killed (killed=true), and it does not indicate the reason for the kill.
To diagnose why connections are being killed, you must look for earlier log entries that explain why the session was marked as killed in the first place.
ProxySQL handles client connection termination in two distinct phases:
Kill Decision Phase: A condition triggers the session to be marked as killed (killed=true).
"Killing client connection … because …" warning at this point.killed=true silently.Cleanup Phase: The worker thread detects killed=true and performs final cleanup, logging:
"Closing killed client connection <IP>:<PORT>"
Key Insight: If you see only the "Closing killed client connection …" warning without a preceding "Killing client connection because …" message, the kill was triggered by an explicit command, not by a timeout.
These mechanisms log a "Killing client connection … because …" warning before setting killed=true.
If any of these are the cause, you will see both the reason warning and the final cleanup warning.
wait_timeout)wait_timeout."Killing client connection <IP>:<PORT> because inactive for <ms>ms"mysql‑wait_timeout (global)wait_timeout (if set via SET wait_timeout=…)max_transaction_idle_time)max_transaction_idle_time."Killing client connection <IP>:<PORT> because of (possible) transaction idle for <ms>ms"mysql‑max_transaction_idle_timemax_transaction_time)max_transaction_time."Killing client connection <IP>:<PORT> because of (possible) transaction running for <ms>ms"mysql‑max_transaction_timesession_fast_forward mode and all backends are OFFLINE."Killing client connection <IP>:<PORT> due to 'session_fast_forward' and offline backends"mysql‑session_fast_forwardThese triggers set killed=true without logging a "Killing client connection because …" warning.
You will see only the final "Closing killed client connection …" message.
KILL CONNECTION command executed via the ProxySQL Admin interface.MySQL_Threads_Handler::kill_session() → sets killed=true directly.kill_connection_or_query() called by:
KILL CONNECTION or KILL QUERY statementskill_connection_or_query() → places request in per‑thread queue → Scan_Sessions_to_Kill() processes queue → sets killed=true.killed=true is set.[WARNING] Killing client connection 192.168.123.45:56789 because inactive for 3600000ms
[WARNING] Closing killed client connection 192.168.123.45:56789
Diagnosis: A timeout mechanism killed the connection.
Action: Adjust the relevant timeout variable (wait_timeout, max_transaction_idle_time, etc.) or investigate why the client stayed idle so long.
[WARNING] Closing killed client connection 192.168.123.45:56789
Diagnosis: The connection was killed by an explicit command (admin or client KILL). Action:
KILL CONNECTION commands.KILL commands.Possible Causes:
KILL commands.Investigation Steps:
Enable audit logging:
SET mysql-auditlog_filename='/var/log/proxysql_audit.log';
LOAD MYSQL VARIABLES TO RUNTIME;
Audit logs capture KILL commands with source IP and username.
Check stats_mysql_commands_counters:
SELECT * FROM stats_mysql_commands_counters WHERE Command='Kill';
Shows how many KILL commands have been executed.
Monitor active kills:
SELECT * FROM stats_mysql_processlist WHERE info LIKE 'KILL%';
Shows currently executing KILL commands.
Review client‑side logs: Look for connection‑pool or application‑layer kill patterns.
| Variable | Default | Description |
|---|---|---|
mysql‑wait_timeout | 28800000 ms (8 hours) | Maximum idle time before connection is killed. |
mysql‑max_transaction_idle_time | 0 (disabled) | Maximum idle time for an open transaction. |
mysql‑max_transaction_time | 0 (disabled) | Maximum total time a transaction can run. |
mysql‑session_fast_forward | false | Enable fast‑forward mode (kills connections if backends go OFFLINE). |
mysql‑throttle_max_transaction_time | 0 (disabled) | Alternative to max_transaction_time; throttles instead of kills. |
Note: Timeouts are expressed in milliseconds. A value of 0 disables the timeout.
KILL commands, timeouts that are too aggressive for your workload.wait_timeout with your application’s connection‑pool idleTimeout.max_transaction_idle_time and max_transaction_time to prevent runaway transactions.-- Enable audit logging
SET mysql-auditlog_filename='/var/log/proxysql_audit.log';
SET mysql-auditlog_filesize=1000000;
SET mysql-auditlog=true;
LOAD MYSQL VARIABLES TO RUNTIME;
SAVE MYSQL VARIABLES TO DISK;
Audit logs record every KILL command with timestamp, client IP, and username.
-- Track kill sources
SELECT
SUM(CASE WHEN Command='Kill' THEN Total_Time_us ELSE 0 END) AS kill_time_us,
SUM(CASE WHEN Command='Kill' THEN cnt ELSE 0 END) AS kill_count
FROM stats_mysql_commands_counters;
-- Check for recent kills in the processlist
SELECT * FROM stats_mysql_processlist
WHERE info LIKE 'KILL%'
ORDER BY time_ms DESC
LIMIT 10;
stats_mysql_commands_counters.mysql‑query_processor_log) to capture more context.A: The kill was triggered by an explicit KILL command (admin or client), not by a timeout. Explicit kills do not log a reason at the moment killed=true is set.
A: Yes, by lowering the log‑verbosity level. However, doing so removes visibility into connection termination. Instead, investigate and address the root cause of the kills.
A: The same two‑phase pattern applies to PostgreSQL, with analogous timeout variables (pgsql‑wait_timeout, etc.) and kill mechanisms. The warning messages are similar but may appear in PgSQL_Thread instead of MySQL_Thread.
KILL and an admin KILL?A: Audit logs show the source IP and username. Client KILL commands originate from application IPs; admin KILL commands come from the admin‑interface IP (usually 127.0.0.1 or your admin network).
A:
KILL connections gracefully (e.g., with COM_QUIT instead of KILL CONNECTION).The "Closing killed client connection …" warning is a cleanup message, not a root‑cause indicator. Diagnosing why connections are killed requires examining earlier logs for "Killing client connection because …" warnings or identifying explicit KILL commands via audit logs and statistics.
Use the troubleshooting steps and monitoring practices outlined above to identify the source of kills and adjust your configuration or application behavior accordingly.