Use the KILL statement to stop a running SQL thread on a PolarDB for Xscale instance.
Syntax
PolarDB for Xscale supports three forms of the KILL statement:
-- Stop the logical and physical SQL threads of a connection, then close it
KILL PROCESS_ID
-- Stop a specific physical SQL thread
KILL 'PHYSICAL_PROCESS_ID'
-- Stop all physical SQL threads on the instance
KILL 'ALL'KILL QUERY.How it works
PolarDB for Xscale is a distributed database. When a query runs, it spawns both a logical SQL thread on the coordinator node and one or more physical SQL threads on the underlying storage nodes. The three KILL forms target different layers:
| Form | Scope | Effect |
|---|---|---|
KILL PROCESS_ID | Logical + physical | Stops both the logical and physical SQL threads of a connection, then closes the connection |
KILL 'PHYSICAL_PROCESS_ID' | Physical only | Stops a specific physical SQL thread on a storage node |
KILL 'ALL' | All physical | Stops all physical SQL threads on the instance |
Kill a connection
To stop a connection and all its associated SQL threads:
Get the
PROCESS_IDof the target connection:SHOW [FULL] PROCESSLIST;Kill the connection:
KILL PROCESS_ID;Replace
PROCESS_IDwith the numeric ID fromSHOW [FULL] PROCESSLIST.
Kill a physical SQL thread
To stop a specific physical SQL thread on a storage node:
Get the
PHYSICAL_PROCESS_IDof the target thread:SHOW PHYSICAL_PROCESS_ID;Kill the physical thread:
KILL 'PHYSICAL_PROCESS_ID';Replace
PHYSICAL_PROCESS_IDwith the string value from step 1. The value is dash-separated (for example,0-0-521570) and must be enclosed in double quotation marks (").Example:
KILL '0-0-521570';Query OK, 0 rows affected (0.01 sec)
Kill all physical SQL threads
To stop all physical SQL threads running on the instance:
KILL 'ALL';Limitations
KILL QUERYis not supported. To stop a query, kill the connection withKILL PROCESS_ID.PHYSICAL_PROCESS_IDis a string value, not a numeric value. Always enclose it in double quotation marks (").