Skip to content

Commit

Permalink
Merge pull request #33330 from FlyingZC/dev1021-doc
Browse files Browse the repository at this point in the history
Add kill query documentation
  • Loading branch information
iamhucong authored Oct 21, 2024
2 parents dbe9a96 + 59829e5 commit f205426
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title = "会话管理"
weight = 7
+++

ShardingSphere 支持会话管理,可通过原生数据库的 SQL 查看当前会话或杀掉会话。目前此功能仅限于存储节点为 MySQL 的情况,支持 MySQL `SHOW PROCESSLIST` 命令和 `KILL` 命令。
ShardingSphere 支持会话管理,可通过原生数据库的 SQL 查看当前会话或终止会话里面执行的 SQL。目前此功能仅限于存储节点为 MySQL 的情况,支持 MySQL `SHOW PROCESSLIST` 命令和 `KILL QUERY` 命令。

## 相关操作

Expand All @@ -25,12 +25,13 @@ mysql> show processlist;

模拟原生 MySQL 的输出,但 `Id` 字段较为特殊为随机字符串。

### 杀掉会话
### 终止会话语句

用户根据 `SHOW PROCESSLIST` 返回的结果,判断是否需要执行 `KILL` 语句,ShardingSphere 会根据 `KILL` 语句中的 ID 取消正在执行中的 SQL。
用户根据 `SHOW PROCESSLIST` 返回的结果,判断是否需要执行 `KILL QUERY` 语句,ShardingSphere 会根据 `KILL QUERY` 语句中的 ID 取消该 PROCESS ID 正在执行中的 SQL。

```sql
mysql> kill 05ede3bd584fd4a429dcaac382be2973;
-- 取消指定会话里正在执行中的 SQL 语句。
mysql> KILL QUERY 05ede3bd584fd4a429dcaac382be2973;
Query OK, 0 rows affected (0.04 sec)

mysql> show processlist;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ title = "Session Management"
weight = 7
+++

ShardingSphere supports session management. You can view the current session or kill the session through the SQL of the native database. At present, this function is only available when the storage node is MySQL. MySQL `SHOW PROCESSLIST` and `KILL` commands are supported.
ShardingSphere supports session management. You can view the current session or terminate the SQL executed in the session through the SQL of the native database. At present, this function is only available when the storage node is MySQL. MySQL `SHOW PROCESSLIST` and `KILL QUERY` commands are supported.

## Usage
### View Session
Expand All @@ -24,14 +24,15 @@ mysql> show processlist;

Simulates the output of native MySQL, but the `Id` field is a special random string.

### Kill Session
### KILL THE SQL IN THE SESSION

The user determines whether the `KILL` statement needs to be executed according to the results returned by `SHOW PROCESSLIST`. ShardingSphere cancels the SQL being executed according to the ID in the `KILL` statement.
The user determines whether the `KILL QUERY` statement needs to be executed according to the results returned by `SHOW PROCESSLIST`. ShardingSphere cancels the SQL being executed according to the ID in the `KILL QUERY` statement.

```sql
mysql> kill 05ede3bd584fd4a429dcaac382be2973;
-- Cancel the SQL statement currently executing in the specified session.
mysql> KILL QUERY 05ede3bd584fd4a429dcaac382be2973;
Query OK, 0 rows affected (0.04 sec)

mysql> show processlist;
mysql> SHOW PROCESSLIST;
Empty set (0.02 sec)
```

0 comments on commit f205426

Please sign in to comment.