<@U0A71G31CDV> how to kill connection
# questions-and-troubleshooting
z
@Rocky how to kill connection
r
To terminate a connection or a query in StarRocks, you can use the
KILL
command. 1. Identify the Connection or Query ID First, find the ID of the session or query you want to stop: * To see all active connections:
Copy code
sql
    SHOW [FULL] PROCESSLIST;
Look for the
Id
column. * To see all running queries (with more detail):
Copy code
sql
    SHOW PROC '/current_queries';
Look for the
ConnectionId
or
QueryId
. * To get your own current connection ID:
Copy code
sql
    SELECT CONNECTION_ID();
2. Kill the Connection or Query * To terminate a connection (and its current query):
Copy code
sql
    KILL <connection_id>;
    -- OR
    KILL CONNECTION <connection_id>;
This closes the session and stops any running statement. * To terminate only the current query (keeps the connection open):
Copy code
sql
    KILL QUERY <connection_id>;
Summary of Syntax Command | Description
KILL <id>
| Terminates the connection associated with the
processlist_id
.
KILL CONNECTION <id>
| Same as
KILL <id>
.
KILL QUERY <id>
| Stops the query the connection is executing but leaves the connection intact. Note: No special privileges are required for a user to kill their own connections. To kill connections of other users, you typically need administrative privileges. References • administration/management/resource_management/Query_management.md • sql-reference/sql-statements/cluster-management/nodes_processes/KILL.md • faq/Sql_faq.md • administration/management/monitor_manage_big_queries.md • administration/management/FE_configuration.md
z
@Rocky KILL CONNECTION does not work [HY000][1094] Unknown thread id: 16821471
r
The error
[HY000][1094] Unknown thread id
occurs because connection IDs (thread IDs) are local to the specific FE (Frontend) node that accepted the connection. If your StarRocks cluster has multiple FEs and you are connected to
FE-A
, but the connection you want to kill is on
FE-B
,
FE-A
will not recognize the ID and will return the "Unknown thread id" error. How to resolve this 1. Locate the correct FE Use the following command to find which FE node is hosting the connection/query:
Copy code
sql
SHOW PROC '/global_current_queries';
_Note: If your version is older than 3.4, use
SHOW PROC '/current_queries';
on each FE individually._ In the output, look for the
feIp
column associated with your
ConnectionId
or
QueryId
. 2. Connect directly to that FE Once you have the
feIp
, you must connect your MySQL client specifically to that IP address (using the same query port, usually
9030
). 3. Issue the KILL command After connecting to the correct FE, run the command again:
Copy code
sql
KILL <connection_id>;
Why does this happen? StarRocks follows the MySQL protocol where connection management is handled by the server (FE) that maintains the TCP session. While StarRocks shares metadata across FEs, the actual active session/thread state is stored in the memory of the specific FE node handling that client. Summary of useful commands * See local connections:
SHOW PROCESSLIST;
* See connections across all FEs:
SHOW PROC '/global_current_queries';
(v3.4+) * Kill a query by ID (instead of connection):
KILL QUERY <query_id>;
(This also usually needs to be run on the originating FE). References • sql-reference/sql-statements/cluster-management/nodes_processes/SHOW_PROC.md • using_starrocks/running_queries.md • administration/management/monitor_manage_big_queries.md