Aaron
03/12/2026, 3:34 AMRocky
03/12/2026, 3:34 AMwait_timeout)
For connections that are alive but inactive (no queries being sent), StarRocks uses the wait_timeout system variable.
* Default Timeout: 28800 seconds (8 hours).
* Behavior: If a client does not interact with the StarRocks server for this duration, StarRocks will actively close the connection.
* How to Change: You can adjust this globally or for a specific session:
sql
-- Set globally for all new connections
SET GLOBAL wait_timeout = 3600; -- 1 hour
-- Set for the current session
SET wait_timeout = 600; -- 10 minutes
2. Dead or Orphaned Connections
If a client "disappears" (e.g., the client process crashes or a network cable is pulled) without closing the connection properly, StarRocks relies on the following:
* TCP Keep-Alive: By default, StarRocks enables TCP Keep-Alive for MySQL connections to detect dead peers.
* FE Configuration: mysql_service_nio_enable_keep_alive (Default: true).
* Automatic Cleanup on Disconnect: If StarRocks detects that the TCP connection has been closed (EOF on read), it will clean up the session.
* FE Configuration: mysql_service_kill_after_disconnect (Default: true). When enabled, StarRocks immediately kills any running queries associated with that connection and performs cleanup.
3. Query Timeouts (query_timeout)
If a connection is "stuck" because a query is running for too long, the query_timeout variable applies.
* Default Timeout: 300 seconds (5 minutes).
* Behavior: If a query exceeds this limit, StarRocks will terminate the query, though the connection itself remains open for the next request (unless wait_timeout is also reached).
Summary Table
Connection State | Governing Variable / Config | Default Value
Idle (Inactive) | wait_timeout | 28800s (8 hrs)
Running Query | query_timeout | 300s (5 mins)
TCP Disconnected | mysql_service_kill_after_disconnect | true (Immediate)
Orphaned (Dead Peer) | TCP Keep-Alive | OS Level / mysql_service_nio_enable_keep_alive
Tip: You can manually inspect and remove connections using:
* SHOW PROCESSLIST; — To see all active connections and their idle time (the Time column).
* KILL [connection_id]; — To manually terminate a specific connection.
References
• administration/management/FE_configuration.md
• faq/Sql_faq.md