Skip to content

Commit 9747d75

Browse files
authored
feat: jdbc set query timeout (#20546) (#20553)
1 parent da98a69 commit 9747d75

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

develop/dev-guide-timeouts-in-tidb.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,11 @@ TiDB 还提供了一个系统变量来限制单条 SQL 语句的执行时间,
4949

5050
## JDBC 查询超时
5151

52-
MySQL jdbc 的查询超时设置 `setQueryTimeout()` 对 TiDB 不起作用。这是因为现实客户端感知超时时,向数据库发送一个 KILL 命令。但是由于 tidb-server 是负载均衡的,为防止在错误的 tidb-server 上终止连接,tidb-server 不会执行这个 KILL。这时就要用 `MAX_EXECUTION_TIME` 实现查询超时的效果。
52+
从 v6.1.0 起,当 [`enable-global-kill`](/tidb-configuration-file.md#enable-global-kill-从-v610-版本开始引入) 配置项为默认值 `true` 时,你可以使用 MySQL JDBC 提供的 `setQueryTimeout()` 方法来控制查询的超时时间。
53+
54+
>**注意:**
55+
>
56+
> 当 TiDB 版本低于 v6.1.0 或 [`enable-global-kill`](/tidb-configuration-file.md#enable-global-kill-从-v610-版本开始引入)`false` 时,`setQueryTimeout()` 对 TiDB 不起作用。这是因为查询超时后,客户端会向数据库发送一条 `KILL` 命令。但是由于 TiDB 服务是负载均衡的,为防止 `KILL` 命令在错误的 TiDB 节点上终止连接,TiDB 不会执行该命令。此时,可以通过设置 `max_execution_time` 实现查询超时控制。
5357
5458
TiDB 提供了三个与 MySQL 兼容的超时控制参数:
5559

0 commit comments

Comments
 (0)