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

update stale read doc for ga #6715

Merged
merged 2 commits into from
Jul 28, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 1 addition & 5 deletions as-of-timestamp.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ summary: 了解如何使用 AS OF TIMESTAMP 语法读取历史数据。

> **警告:**
>
> Stale Read 目前为实验特性。不推荐在生产环境下使用该特性。
>
> 目前 Stale Read 特性无法和 TiFlash 一起使用。如果你的查询中带有 `AS OF TIMESTAMP` 并且 TiDB 可能从 TiFlash 副本读取数据,你可能会遇到 `ERROR 1105 (HY000): stale requests require tikv backend` 报错信息。
>
> 要解决该问题,你需要为使用 Stale Read 特性的查询禁用 TiFlash 副本。要禁用 TiFlash 副本,你可以使用以下任一方法:
Expand Down Expand Up @@ -47,9 +45,7 @@ TiDB 支持通过标准 SQL 接口,即通过 `AS OF TIMESTAMP` SQL 语法的
>
> 除了指定时间戳,`AS OF TIMESTAMP` 语法最常用使用的方式是读几秒前的数据。如果采用这种方式,推荐读 5 秒以上的历史数据。
>
> 使用 Stale Read 时需要为 TiDB 和 PD 节点部署 NTP 服务,防止 TiDB 指定的时间戳超过当前最新的 TSO 分配进度(如几秒后的时间戳),或者落后于 GC safe point 的时间戳。当指定的时间戳超过服务范围,TiDB 会产生报错或者等待事务提交等行为。
>
> `Prepare` 语句与 `AS OF TIMESTAMP` 语法的兼容支持尚不完善,不推荐同时使用。
> 使用 Stale Read 时需要为 TiDB 和 PD 节点部署 NTP 服务,防止 TiDB 指定的时间戳超过当前最新的 TSO 分配进度(如几秒后的时间戳),或者落后于 GC safe point 的时间戳。当指定的时间戳超过服务范围,TiDB 会返回错误。

## 示例

Expand Down
1 change: 0 additions & 1 deletion experimental-features.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ aliases: ['/docs-cn/dev/experimental-features-4.0/','/zh/tidb/dev/experimental-f
+ [自定义变量](/user-defined-variables.md#用户自定义变量)。
+ [JSON 数据类型](/data-type-json.md) 及 [JSON 函数](/functions-and-operators/json-functions.md)。
+ [View](/information-schema/information-schema-views.md)。
+ [Stale Read](/stale-read.md)。

## 配置管理

Expand Down
4 changes: 0 additions & 4 deletions stale-read.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ summary: 介绍 Stale Read 功能和使用场景。

本文档介绍 Stale Read 的使用场景。Stale Read 是一种读取历史数据版本的机制,读取 TiDB 中存储的历史数据版本。通过 Stale Read 功能,你能从指定时间点或时间范围内读取对应的历史数据,从而避免数据同步带来延迟。当使用 Stale Read 时,TiDB 默认会随机选择一个副本来读取数据,因此能利用所有副本。如果你的应用程序不能容忍读到非实时的数据,请勿使用 Stale Read,否则读到的数据可能不是最新成功写入的数据。

> **警告:**
>
> Stale Read 目前为实验特性。不推荐在生产环境下使用该特性。

## 场景描述

+ 场景一:如果一个事务仅涉及只读操作,并且一定程度上可容忍牺牲实时性,你可以使用 Stale Read 功能来读取历史数据。由于牺牲了一定的实时性,使用 Stale Read 后,TiDB 可以让请求分发到任一个副本上,使得查询的执行获得更大的吞吐量。特别是在一些小表的查询场景中,如果使用了强一致性读,Leader 可能集中在某一个存储节点上,导致查询压力集中在该节点,成为整个查询的瓶颈。通过 Stale Read,可以提升了查询整体的吞吐能力,从而显著提升查询性能。
Expand Down