Description
This statement is used to terminate a server-side session.
Privilege requirements
By default, a regular user can only terminate all sessions under their own tenant. Sessions in other tenants are not visible to them. Whether a regular user can terminate sessions of other users in the same tenant depends on their current tenant privileges. The sys tenant of OceanBase Database can terminate any session within its own tenant. The root@proxysys user of OceanBase Database 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 a client session in OceanBase Database. You can run the SHOW PROCESSLIST; or SHOW PROXYSESSION; statement to query it. The Id column in the output is the cs_id. |
| connection_id | The ID of a client in OceanBase Database. In MySQL mode, you can run the SELECT CONNECTION_ID(); statement to query it. In Oracle mode, you can run the SHOW FULL PROCESSLIST; statement to query it.
NoteWhen client_session_id_version is set to |
| ss_id | The ID of a server session in OceanBase Database. You can run the SHOW PROXYSESSION ATTRIBUTE statement to query it. |
Examples
Log in to OceanBase Database by using the root@sys user through OceanBase Database Proxy.
obclient -h10.10.10.1 -uroot@sys#obdemo -P2883 -p -c -AThe preceding example is for reference only. You need to modify it based on your actual situation.
View the client connections and obtain the
cs_id.SHOW PROCESSLIST;The output is as follows. The
Idcolumn in the output is thecs_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 | +------------+-------------+---------------------+-----------+---------+------+--------+------------------+Obtain the
ss_idbased on thecs_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-side session on the client connection.
KILL PROXYSESSION 1607729162 299;
