Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

*: add doc for tikv_client_read_timeout system variable #14964

Merged
merged 34 commits into from
Oct 7, 2023

Conversation

crazycs520
Copy link
Contributor

First-time contributors' checklist

What is changed, added or deleted? (Required)

add doc for tidb_kv_read_timeout system variable and optimizer hint

Which TiDB version(s) do your changes apply to? (Required)

Tips for choosing the affected version(s):

By default, CHOOSE MASTER ONLY so your changes will be applied to the next TiDB major or minor releases. If your PR involves a product feature behavior change or a compatibility change, CHOOSE THE AFFECTED RELEASE BRANCH(ES) AND MASTER.

For details, see tips for choosing the affected versions (in Chinese).

  • master (the latest development version)
  • v7.4 (TiDB 7.4 versions)
  • v7.3 (TiDB 7.3 versions)
  • v7.2 (TiDB 7.2 versions)
  • v7.1 (TiDB 7.1 versions)
  • v7.0 (TiDB 7.0 versions)
  • v6.5 (TiDB 6.5 versions)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 versions)
  • v5.3 (TiDB 5.3 versions)
  • v5.2 (TiDB 5.2 versions)
  • v5.1 (TiDB 5.1 versions)
  • v5.0 (TiDB 5.0 versions)

What is the related PR or file link(s)?

Do your changes match any of the following descriptions?

  • Delete files
  • Change aliases
  • Need modification after applied to another branch
  • Might cause conflicts after applied to another branch

@crazycs520
Copy link
Contributor Author

@cfzjywxk PTAL

@ti-chi-bot ti-chi-bot bot added missing-translation-status This PR does not have translation status info. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels Sep 4, 2023
@hfxsd hfxsd added translation/doing This PR’s assignee is translating this PR. v7.4 This PR/issue applies to TiDB v7.4. and removed missing-translation-status This PR does not have translation status info. labels Sep 5, 2023
@hfxsd hfxsd self-assigned this Sep 5, 2023
@hfxsd hfxsd self-requested a review September 5, 2023 02:24
@hfxsd hfxsd added the type/compatibility-or-feature-change This PR involves compatibility changes or feature behavior changes. label Sep 5, 2023
system-variables.md Outdated Show resolved Hide resolved
optimizer-hints.md Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added the needs-1-more-lgtm Indicates a PR needs 1 more LGTM. label Sep 5, 2023
optimizer-hints.md Outdated Show resolved Hide resolved
optimizer-hints.md Outdated Show resolved Hide resolved
optimizer-hints.md Outdated Show resolved Hide resolved
@@ -742,6 +742,16 @@ SELECT /*+ MAX_EXECUTION_TIME(1000) */ * FROM t1 inner join t2 WHERE t1.id = t2.

除了 Hint 之外,系统变量 `global.max_execution_time` 也能对语句执行时间进行限制。

### TIDB_KV_READ_TIMEOUT(N)

`TIDB_KV_READ_TIMEOUT(N)` 用于设置查询语句中 TiDB 发送 KV RPC 读请求的超时时间。通常不建议用户设置该变量的值。当 TiDB 集群在网络不稳定,或者 I/O 延迟抖动严重的环境下,且用户对查询 SQL 的延迟比较敏感时,可以通过设置 `TIDB_KV_READ_TIMEOUT(N)` 调小 KV RPC 读请求的超时时间,这样当某个 TiKV 出现 I/O 延迟抖动时,TiDB 侧可以快速超时并重新发送 KV RPC 请求给下一个 KV Region Peer 所在的 TiKV。如果所有 KV Region Peer 都请求超时,则会用默认的超时时间进行重试。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

不建议用户使用

我们需要有最佳实践和适配场景指引,一般副作用较大只解决极个别场景的用法才作为 “不推荐、不建议使用”

optimizer-hints.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
@hfxsd hfxsd added translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. and removed translation/doing This PR’s assignee is translating this PR. labels Sep 5, 2023
Co-authored-by: xixirangrang <[email protected]>
@ti-chi-bot ti-chi-bot bot added size/S Denotes a PR that changes 10-29 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Sep 12, 2023
>
> - 一般情况下一个普通查询的常规耗时是几毫秒,但偶尔可能会出现某个 TiKV 的网络不稳定、或者某个 TiKV 的 I/O 抖动,导致查询耗时超过 1 秒甚至 10 秒。此时你可以尝试通过 Optimizer Hint `/*+ SET_VAR(TIKV_CLIENT_READ_TIMEOUT=100) */` 为该查询语句设置 TiKV RPC 读请求超时时间为 100 毫秒,这样即使遇到某个 TiKV 查询慢,也可以快速超时然后重新发送 RPC 请求给下一个 TiKV Region Peer 所在的 TiKV。由于两个 TiKV 同时出现 I/O 抖动的概率较低,所以该查询语句的耗时通常可以预期在几毫秒到 110 毫秒之间。
> - 不建议将 `tikv_client_read_timeout` 的值设置的太小,否则 TiDB 集群在负载压力较大时会很容易导致请求超时,然后重试会进一步增加 TiDB 集群的压力。
> - 建议使用 Optimizer Hint 为不同类型的查询语句设置不同的超时时间。
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

后续如果 retry doc 有对应 public doc,这里也可以补充一个 link
/cc @zyguan @crazycs520

@ti-chi-bot ti-chi-bot bot requested a review from zyguan September 12, 2023 04:02
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 12, 2023

@cfzjywxk: GitHub didn't allow me to request PR reviews from the following users: crazycs520.

Note that only pingcap members and repo collaborators can review this PR, and authors cannot review their own PRs.

In response to this:

后续如果 retry doc 有对应 public doc,这里也可以补充一个 link
/cc @zyguan @crazycs520

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 12, 2023

@cfzjywxk: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

system-variables.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
system-variables.md Outdated Show resolved Hide resolved
@ti-chi-bot ti-chi-bot bot added lgtm and removed needs-1-more-lgtm Indicates a PR needs 1 more LGTM. labels Sep 18, 2023
@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 18, 2023

[LGTM Timeline notifier]

Timeline:

  • 2023-09-05 03:01:01.077885647 +0000 UTC m=+2414425.626901634: ☑️ agreed by hfxsd.
  • 2023-09-18 01:55:44.62614813 +0000 UTC m=+482510.593736164: ☑️ agreed by qiancai.

@hfxsd hfxsd changed the title *: add doc for tikv_client_read_timeout system variable *: add doc for tikv_client_read_timeout system variable Sep 22, 2023
Copy link
Contributor

@benmaoer benmaoer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@ti-chi-bot
Copy link

ti-chi-bot bot commented Sep 25, 2023

@benmaoer: adding LGTM is restricted to approvers and reviewers in OWNERS files.

In response to this:

LGTM

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository.

@hfxsd
Copy link
Collaborator

hfxsd commented Sep 28, 2023

/verify

@hfxsd
Copy link
Collaborator

hfxsd commented Oct 7, 2023

/approve

@ti-chi-bot
Copy link

ti-chi-bot bot commented Oct 7, 2023

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: easonn7, hfxsd

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@ti-chi-bot ti-chi-bot bot added the approved label Oct 7, 2023
@ti-chi-bot ti-chi-bot bot merged commit 65e37c0 into pingcap:master Oct 7, 2023
2 of 3 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
approved lgtm size/S Denotes a PR that changes 10-29 lines, ignoring generated files. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. type/compatibility-or-feature-change This PR involves compatibility changes or feature behavior changes. v7.4 This PR/issue applies to TiDB v7.4.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants