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 document about stale read transaction #6347

Merged
merged 59 commits into from
Jun 15, 2021

Conversation

Yisaer
Copy link
Contributor

@Yisaer Yisaer commented May 27, 2021

What is changed, added or deleted? (Required)

add document about stale read transaction

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

  • master (the latest development version)
  • v5.1 (TiDB 5.0 versions)
  • v5.0 (TiDB 5.0 versions)
  • v4.0 (TiDB 4.0 versions)
  • v3.1 (TiDB 3.1 versions)
  • v3.0 (TiDB 3.0 versions)
  • v2.1 (TiDB 2.1 versions)

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

  • This PR is translated from:
  • Other reference 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

Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
@ti-chi-bot ti-chi-bot requested a review from TomShawn May 27, 2021 06:21
@ti-chi-bot ti-chi-bot added missing-translation-status This PR does not have translation status info. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels May 27, 2021
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
@TomShawn TomShawn added v5.1 This PR/issue applies to TiDB v5.1. translation/doing This PR’s assignee is translating this PR. labels May 27, 2021
@ti-chi-bot ti-chi-bot removed the missing-translation-status This PR does not have translation status info. label May 27, 2021
Signed-off-by: yisaer <disxiaofei@163.com>
@pingcap pingcap deleted a comment from ti-chi-bot May 27, 2021
@pingcap pingcap deleted a comment from ti-chi-bot May 27, 2021
@TomShawn TomShawn requested a review from nolouch May 27, 2021 06:43
@TomShawn TomShawn added the status/PTAL This PR is ready for reviewing. label May 27, 2021
Signed-off-by: yisaer <disxiaofei@163.com>
Signed-off-by: yisaer <disxiaofei@163.com>
@ti-chi-bot ti-chi-bot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label May 27, 2021
read-stale-data.md Outdated Show resolved Hide resolved
read-stale-data.md Outdated Show resolved Hide resolved
@TomShawn TomShawn added status/require-change Needs the author to address comments. and removed status/PTAL This PR is ready for reviewing. labels Jun 1, 2021
Signed-off-by: JmPotato <ghzpotato@gmail.com>
Signed-off-by: JmPotato <ghzpotato@gmail.com>
@ti-chi-bot ti-chi-bot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Jun 1, 2021
Signed-off-by: JmPotato <ghzpotato@gmail.com>
stale-read.md Outdated Show resolved Hide resolved
Signed-off-by: JmPotato <ghzpotato@gmail.com>
stale-read.md Outdated Show resolved Hide resolved
stale-read.md Outdated

+ 场景二:在一些小表的查询场景中,如果使用了强一致性读,数据可能集中在某一个存储节点上,导致查询压力集中在该节点,成为整个查询的瓶颈。使用 Stale Read 功能后,TiDB 可以将请求分发到对应数据的每一个副本上,提升了查询整体的吞吐能力,从而显著提升查询性能。

+ 场景三:在部分跨数据中心部署的场景中,如果使用了强一致性的 Follower 读,为了读到的数据与 Leader 上的数据一致,会产生跨数据中心获取 Readindex 来校验的请求,导致整体查询的访问延迟增加。通过使用 Stale Read 功能,可以牺牲一定的实时性,可就近访问对应数据所在当前中心的副本,避免跨数据中心的网络延迟,降低整体查询的访问延迟。
Copy link
Contributor

Choose a reason for hiding this comment

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

针对场景三,就近读取到一个尽可能新的数据即可,一定要改 sql,加上「as of timestamp」么,还要明确指定一个时间?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

只要使用 Stale read 功能,就要改 SQL,和哪个场景没关系。

Signed-off-by: yisaer <disxiaofei@163.com>

add local read

Signed-off-by: yisaer <disxiaofei@163.com>
Copy link
Member

@nolouch nolouch 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
Member

@nolouch: Please use GitHub review feature instead of /lgtm [cancel] when you want to submit review to the pull request.
For how to use GitHub review feature, see also this document provided by GitHub.

For the reason we drop support to the commands, see also this page.
This reply is being used as a temporary reply during the migration of review process and will be removed on July 1st.

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 ti-community-infra/tichi repository.

@ti-chi-bot
Copy link
Member

@nolouch: Thanks for your review. The bot only counts approvals from reviewers and higher roles in list, but you're still welcome to leave your comments.

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 ti-community-infra/tichi repository.

best-practices/three-dc-local-read.md Outdated Show resolved Hide resolved
best-practices/three-dc-local-read.md Outdated Show resolved Hide resolved
best-practices/three-dc-local-read.md Show resolved Hide resolved
best-practices/three-dc-local-read.md Outdated Show resolved Hide resolved
read-historical-data.md Outdated Show resolved Hide resolved
stale-read.md Outdated Show resolved Hide resolved
stale-read.md Outdated Show resolved Hide resolved
Co-authored-by: TomShawn <41534398+TomShawn@users.noreply.github.com>
Copy link
Contributor

@TomShawn TomShawn 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
Member

[REVIEW NOTIFICATION]

This pull request has been approved by:

  • TomShawn

To complete the pull request process, please ask the reviewers in the list to review by filling /cc @reviewer in the comment.
After your PR has acquired the required number of LGTMs, you can assign this pull request to the committer in the list by filling /assign @committer in the comment to help you merge this pull request.

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

Reviewer can indicate their review by submitting an approval review.
Reviewer can cancel approval by submitting a request changes review.

@ti-chi-bot ti-chi-bot added the status/LGT1 Indicates that a PR has LGTM 1. label Jun 15, 2021
@TomShawn
Copy link
Contributor

/remove-status LGT1
/status LGT2

@ti-chi-bot ti-chi-bot added status/LGT2 Indicates that a PR has LGTM 2. and removed status/LGT1 Indicates that a PR has LGTM 1. labels Jun 15, 2021
@TomShawn
Copy link
Contributor

/merge

@ti-chi-bot
Copy link
Member

This pull request has been accepted and is ready to merge.

Commit hash: 84ddbea

@ti-chi-bot ti-chi-bot added the status/can-merge Indicates a PR has been approved by a committer. label Jun 15, 2021
@TomShawn TomShawn removed the status/require-change Needs the author to address comments. label Jun 15, 2021
@ti-chi-bot ti-chi-bot merged commit c984ed2 into pingcap:master Jun 15, 2021
@TomShawn TomShawn assigned CharLotteiu and unassigned qiancai Jun 16, 2021
@TomShawn
Copy link
Contributor

@CharLotteiu This PR is further updated in #6453. Please also translate the update. Thanks!

@TomShawn TomShawn 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 Jun 18, 2021

## 示例

本节通过多个示例介绍 `AS OF TIMESTAMP` 语法的不同使用方法。在本节中,先介绍如何准备用于恢复的数据,再分别展示如何通过 `SELECT`、`START TRANSACTION READ ONLY AS OF TIMESTAMP`、`SET TRANSACTION READ ONLY AS OF TIMESTAMP` 以及 `SELECT` 子句使用 `AS OF TIMESTAMP`。
Copy link
Contributor

Choose a reason for hiding this comment

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

SELECT 子句


# 在三数据中心下就近读取数据

在三数据中心模式下,Region 的三个副本都会隔离在各个数据中心里。然而在强一致读的要求下,tidb 的每一个查询都需要访问对应数据的 Leader 副本,而查询的来源可能和 Leader 所在的数据中心不一致,这就会引起跨数据中心的数据访问,从而造成访问的延迟上升。本文主要介绍使用 [Stale Read](/stale-read.md) 功能,以牺牲数据实时性的方式,避免跨数据中心的访问,从而降低访问的延迟。
Copy link
Contributor

Choose a reason for hiding this comment

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

tidb -> TiDB

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. status/can-merge Indicates a PR has been approved by a committer. status/LGT2 Indicates that a PR has LGTM 2. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. v5.1 This PR/issue applies to TiDB v5.1.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

10 participants