Purpose
You can use this statement to terminate server connections.
Required privileges
By default, a normal user can terminate only sessions of the current user, and sessions in other tenants are invisible to the user. Whether a normal user can terminate sessions of other users in the same tenant depends on the privileges of the current tenant. In OceanBase Database, the sys tenant can terminate any session in the current tenant. The super administrator (root@proxysys) of OceanBase Database Proxy (ODP) can terminate sessions in all clusters and tenants.
Syntax
KILL PROXYSESSION {cs_id | connection_id} ss_id;
Parameters
| Parameter | Description |
|---|---|
| cs_id | The ID of the client session allocated by ODP. You can query the client session ID by using the SHOW PROCESSLIST; or SHOW PROXYSESSION; statement. The value of the Id column in the output is the client session ID. |
| connection_id | The ID of the client session allocated by OceanBase Database. In MySQL mode, you can use SELECT CONNECTION_ID(); to query the client session ID. In Oracle mode, you can use SHOW FULL PROCESSLIST; to query the client session ID.
NoteWhen client_session_id_version is set to |
| ss_id | The ID of the server session in ODP. You can use the SHOW PROXYSESSION ATTRIBUTE statement to query the server session ID. |
Examples
Log in to OceanBase Database through ODP as the
root@sysuser.obclient -h10.10.10.1 -uroot@sys#obdemo -P2883 -p -c -AThe preceding command is only an example. You need to modify the parameter values based on the actual situation. For more information, see Connect to an OceanBase Database tenant by using OBClient in MySQL mode.
View the client session and query the client session ID.
SHOW PROCESSLIST;The output is as follows, where the value of
Idis the client session ID:+------------+-------------+---------------------+-----------+---------+------+--------+------------------+ | Id | User | Host | db | Command | Time | State | Info | +------------+-------------+---------------------+-----------+---------+------+--------+------------------+ | 1607729164 | proxyro | 10.10.10.1:47366 | oceanbase | Sleep | 2 | SLEEP | NULL | | 1607729162 | root | 10.10.10.1:47362 | oceanbase | Query | 0 | ACTIVE | SHOW PROCESSLIST | +------------+-------------+---------------------+-----------+---------+------+--------+------------------+Query the server session ID based on the client session ID.
SHOW PROXYSESSION ATTRIBUTE 1607729162 LIKE "%id%";The output is as follows:
+------------------------+--------------------+----------------+ | attribute_name | value | info | +------------------------+--------------------+----------------+ | proxy_sessid | 838175719856210097 | cs common | | cs_id | 1607729162 | cs common | | tid | 108071 | cs common | | pid | 108071 | cs common | | idc_name | | cs common | | last_insert_id_version | 0 | cs var version | | server_sessid | 3221555468 | last used ss | | ss_id | 299 | last used ss | | last_insert_id_version | 0 | last used ss | +------------------------+--------------------+----------------+Terminate the server session for the client session.
KILL PROXYSESSION 64940 16;