KILL

更新时间:
复制 MD 格式

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'
Note PolarDB for Xscale does not support 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:

FormScopeEffect
KILL PROCESS_IDLogical + physicalStops both the logical and physical SQL threads of a connection, then closes the connection
KILL 'PHYSICAL_PROCESS_ID'Physical onlyStops a specific physical SQL thread on a storage node
KILL 'ALL'All physicalStops all physical SQL threads on the instance

Kill a connection

To stop a connection and all its associated SQL threads:

  1. Get the PROCESS_ID of the target connection:

    SHOW [FULL] PROCESSLIST;
  2. Kill the connection:

    KILL PROCESS_ID;

    Replace PROCESS_ID with the numeric ID from SHOW [FULL] PROCESSLIST.

Kill a physical SQL thread

To stop a specific physical SQL thread on a storage node:

  1. Get the PHYSICAL_PROCESS_ID of the target thread:

    SHOW PHYSICAL_PROCESS_ID;
  2. Kill the physical thread:

    KILL 'PHYSICAL_PROCESS_ID';

    Replace PHYSICAL_PROCESS_ID with 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 QUERY is not supported. To stop a query, kill the connection with KILL PROCESS_ID.

  • PHYSICAL_PROCESS_ID is a string value, not a numeric value. Always enclose it in double quotation marks (").