Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master'
Browse files Browse the repository at this point in the history
  • Loading branch information
hfxsd committed May 30, 2024
2 parents 7011274 + 6b16384 commit 4f63b5b
Show file tree
Hide file tree
Showing 10 changed files with 26 additions and 21 deletions.
2 changes: 1 addition & 1 deletion alert-rules.md
Original file line number Diff line number Diff line change
Expand Up @@ -119,7 +119,7 @@ aliases: ['/docs-cn/dev/alert-rules/','/docs-cn/dev/reference/alert-rules/']

* 规则描述:

TiDB 处理请求的延时。如果延迟大于 1 秒的概率超过 99%,则报警
TiDB 处理请求的延时。99% 的请求的响应时间都应在 1 秒之内,否则报警

* 处理方法:

Expand Down
2 changes: 1 addition & 1 deletion releases/release-6.1.6.md
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ TiDB 版本:6.1.6

+ TiDB Lightning

- 修复冲突处理逻辑 (`duplicate-resolution`) 可能导致 checksum 不一致的问题 [#40657](https://github.com/pingcap/tidb/issues/40657) @[gozssky](https://github.com/gozssky)
- 修复冲突处理逻辑 (`duplicate-resolution`) 可能导致 checksum 不一致的问题 [#40657](https://github.com/pingcap/tidb/issues/40657) @[sleepymole](https://github.com/sleepymole)
- 修复 TiDB Lightning 在 split-region 阶段发生 panic 的问题 [#40934](https://github.com/pingcap/tidb/issues/40934) @[lance6716](https://github.com/lance6716)
- 修复了在使用 Local Backend 模式导入数据时,当导入目标表的复合主键中存在 `auto_random` 列,且源数据中没有指定该列的值时,相关列没有自动生成数据的问题 [#41454](https://github.com/pingcap/tidb/issues/41454) @[D3Hunter](https://github.com/D3Hunter)
- 修复在并行导入时,当除最后一个 TiDB Lightning 实例外的其他实例都遇到本地重复记录时,TiDB Lightning 可能会错误地跳过冲突处理的问题 [#40923](https://github.com/pingcap/tidb/issues/40923) @[lichunzhu](https://github.com/lichunzhu)
2 changes: 1 addition & 1 deletion releases/release-6.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ TiDB 版本:6.2.0-DMR

此特性无需手动配置,目标 TiDB 集群版本在 v6.1.0 及以上且 TiDB Lightning 在 v6.2.0 及以上时自动生效。

[用户文档](/tidb-lightning/tidb-lightning-physical-import-mode-usage.md#导入时暂停-pd-调度的范围) [#35148](https://github.com/pingcap/tidb/issues/35148) @[gozssky](https://github.com/gozssky)
[用户文档](/tidb-lightning/tidb-lightning-physical-import-mode-usage.md#导入时暂停-pd-调度的范围) [#35148](https://github.com/pingcap/tidb/issues/35148) @[sleepymole](https://github.com/sleepymole)

* 调整 [TiDB Lightning 在线文档](/tidb-lightning/tidb-lightning-overview.md),使其目录结构更加合理和清晰。同时对文档中关于“后端模式”的描述进行了修改,使用物理导入模式替代原有 `local` 后端模式,使用逻辑导入模式替代原有 `tidb` 后端模式,以降低新用户的理解难度。

Expand Down
2 changes: 1 addition & 1 deletion releases/release-6.5.1.md
Original file line number Diff line number Diff line change
Expand Up @@ -182,6 +182,6 @@ TiDB 版本:6.5.1

- 修复 precheck 检查项有时无法监测到之前的导入失败遗留的脏数据的问题 [#39477](https://github.com/pingcap/tidb/issues/39477) @[dsdashun](https://github.com/dsdashun)
- 修复 TiDB Lightning 在 split-region 阶段发生 panic 的问题 [#40934](https://github.com/pingcap/tidb/issues/40934) @[lance6716](https://github.com/lance6716)
- 修复冲突处理逻辑 (`duplicate-resolution`) 可能导致 checksum 不一致的问题 [#40657](https://github.com/pingcap/tidb/issues/40657) @[gozssky](https://github.com/gozssky)
- 修复冲突处理逻辑 (`duplicate-resolution`) 可能导致 checksum 不一致的问题 [#40657](https://github.com/pingcap/tidb/issues/40657) @[sleepymole](https://github.com/sleepymole)
- 修复在并行导入时,当除最后一个 TiDB Lightning 实例外的其他实例都遇到本地重复记录时,TiDB Lightning 可能会错误地跳过冲突处理的问题 [#40923](https://github.com/pingcap/tidb/issues/40923) @[lichunzhu](https://github.com/lichunzhu)
- 修复了在使用 Local Backend 模式导入数据时,当导入目标表的复合主键中存在 `auto_random` 列,且源数据中没有指定该列的值时,相关列没有自动生成数据的问题 [#41454](https://github.com/pingcap/tidb/issues/41454) @[D3Hunter](https://github.com/D3Hunter)
6 changes: 3 additions & 3 deletions releases/release-7.0.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ TiDB 版本:7.0.0

更多信息,请参考[用户文档](/sql-statements/sql-statement-load-data.md)

* TiDB Lightning 向 TiKV 传输键值对时支持启用压缩传输 [#41163](https://github.com/pingcap/tidb/issues/41163) @[gozssky](https://github.com/gozssky)
* TiDB Lightning 向 TiKV 传输键值对时支持启用压缩传输 [#41163](https://github.com/pingcap/tidb/issues/41163) @[sleepymole](https://github.com/sleepymole)

自 v7.0.0 起,TiDB Lightning 正式支持将本地编码排序后的键值对在网络传输时进行压缩再发送到 TiKV,从而减少网络传输的数据量,降低 50% ~ 80% 网络带宽开销。在 v6.6.0 版本之前不支持该功能,在数据量较大的情况下,TiDB Lightning 对网络带宽要求相对较高,且会产生较高的流量费。相比 v6.6.0, v7.0.0 优化了压缩算法,能以更快的速度将数据导入到 TiKV 中。同样是开启压缩选项,v6.6.0 会增加 2 倍导入时间,而 v7.0.0 只会增加大约 60% 时间。以上的压缩率和导入时长仅供参考,不同的使用场景会有差异。

Expand Down Expand Up @@ -419,7 +419,7 @@ TiDB 版本:7.0.0

+ TiDB Lightning

- TiDB Lightning 的物理导入模式 (Physical Import Mode) 支持导入数据和索引分离导入,提升导入速度和稳定性 [#42132](https://github.com/pingcap/tidb/issues/42132) @[gozssky](https://github.com/gozssky)
- TiDB Lightning 的物理导入模式 (Physical Import Mode) 支持导入数据和索引分离导入,提升导入速度和稳定性 [#42132](https://github.com/pingcap/tidb/issues/42132) @[sleepymole](https://github.com/sleepymole)

TiDB Lightning 增加 `add-index-by-sql` 参数。默认值为 `false`,表示仍然会用 TiDB Lightning 将行数据以及索引数据编码成 KV pairs 后再一同导入到 TiKV。如果设置为 `true`,表示在物理导入模式 (Physical Import Mode) 下,会在导入数据完成后,通过 `ADD INDEX` 的 SQL 语句帮你建索引,提升导入数据的速度和稳定性。

Expand Down Expand Up @@ -504,7 +504,7 @@ TiDB 版本:7.0.0
- [BornChanger](https://github.com/BornChanger)
- [Dousir9](https://github.com/Dousir9)
- [erwadba](https://github.com/erwadba)
- [HappyUncle](https://github.com/HappyUncle)
- [happy-v587](https://github.com/happy-v587)
- [jiyfhust](https://github.com/jiyfhust)
- [L-maple](https://github.com/L-maple)
- [liumengya94](https://github.com/liumengya94)
Expand Down
2 changes: 1 addition & 1 deletion releases/release-7.2.0.md
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ TiDB 版本:7.2.0
- [darraes](https://github.com/darraes)
- [demoManito](https://github.com/demoManito)
- [dhysum](https://github.com/dhysum)
- [HappyUncle](https://github.com/HappyUncle)
- [happy-v587](https://github.com/happy-v587)
- [jiyfhust](https://github.com/jiyfhust)
- [L-maple](https://github.com/L-maple)
- [nyurik](https://github.com/nyurik)
Expand Down
5 changes: 5 additions & 0 deletions sql-statements/sql-statement-add-index.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,10 @@ aliases: ['/docs-cn/dev/sql-statements/sql-statement-add-index/','/docs-cn/dev/r

`ALTER TABLE.. ADD INDEX` 语句用于在已有表中添加一个索引。在 TiDB 中,`ADD INDEX` 为在线操作,不会阻塞表中的数据读写。

> **Tip:**
>
> 你可以使用 [TiDB 分布式执行框架](/tidb-distributed-execution-framework.md)加速该语句的执行。
> **警告:**
>
> - 在升级 TiDB 集群的过程中,**请勿执行** DDL 语句,否则可能会出现行为未定义的问题。
Expand Down Expand Up @@ -124,3 +128,4 @@ EXPLAIN SELECT * FROM t1 WHERE c1 = 3;
* [ADD COLUMN](/sql-statements/sql-statement-add-column.md)
* [CREATE TABLE](/sql-statements/sql-statement-create-table.md)
* [EXPLAIN](/sql-statements/sql-statement-explain.md)
* [TiDB 分布式执行框架](/tidb-distributed-execution-framework.md)
1 change: 1 addition & 0 deletions sql-statements/sql-statement-import-into.md
Original file line number Diff line number Diff line change
Expand Up @@ -351,3 +351,4 @@ IMPORT INTO t FROM SELECT * FROM src AS OF TIMESTAMP '2024-02-27 11:38:00';

* [`SHOW IMPORT JOB(s)`](/sql-statements/sql-statement-show-import-job.md)
* [`CANCEL IMPORT JOB`](/sql-statements/sql-statement-cancel-import-job.md)
* [TiDB 分布式执行框架](/tidb-distributed-execution-framework.md)
21 changes: 10 additions & 11 deletions tidb-distributed-execution-framework.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TiDB 采用计算存储分离架构,具有出色的扩展性和弹性的扩缩

## 使用场景

在数据库中,除了核心的事务型负载任务 (TP) 和分析型查询任务 (AP),也存在着其他重要任务,如 DDL 语句、IMPORT INTOTTL、Analyze 和 Backup/Restore 等。这些任务需要处理数据库对象(表)中的大量数据,通常具有如下特点:
在数据库中,除了核心的事务型负载任务 (TP) 和分析型查询任务 (AP),也存在着其他重要任务,如 DDL 语句、[`IMPORT INTO`](/sql-statements/sql-statement-import-into.md)[TTL](/time-to-live.md)[`ANALYZE`](/sql-statements/sql-statement-analyze-table.md) 和 Backup/Restore 等。这些任务需要处理数据库对象(表)中的大量数据,通常具有如下特点:

- 需要处理一个 schema 或者一个数据库对象(表)中的所有数据。
- 可能需要周期执行,但频率较低。
Expand All @@ -23,29 +23,28 @@ TiDB 采用计算存储分离架构,具有出色的扩展性和弹性的扩缩
- 支持任务分布式执行,可以在整个 TiDB 集群可用的计算资源范围内进行灵活的调度,从而更好地利用 TiDB 集群内的计算资源。
- 提供统一的资源使用和管理能力,从整体和单个任务两个维度提供资源管理的能力。

目前,分布式执行框架支持分布式执行 `ADD INDEX``IMPORT INTO` 这两类任务。
目前,分布式执行框架支持分布式执行 [`ADD INDEX`](/sql-statements/sql-statement-add-index.md)[`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) 这两类任务。

- `ADD INDEX`,即 DDL 创建索引的场景。例如以下 SQL 语句:
- [`ADD INDEX`](/sql-statements/sql-statement-add-index.md),即 DDL 创建索引的场景。例如以下 SQL 语句:

```sql
ALTER TABLE t1 ADD INDEX idx1(c1);
CREATE INDEX idx1 ON table t1(c1);
```

- `IMPORT INTO` 即通过该 SQL 语句将 `CSV``SQL``PARQUET` 等格式的数据导入到一张空表中。详情请参考 [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md)。
- [`IMPORT INTO`](/sql-statements/sql-statement-import-into.md) 即通过该 SQL 语句将 CSV、SQL、PARQUET 等格式的数据导入到一张空表中

## 使用限制

分布式执行框架最多同时调度 16 个任务(包括 `ADD INDEX``IMPORT INTO`)。
分布式执行框架最多同时调度 16 个任务(包括 [`ADD INDEX`](/sql-statements/sql-statement-add-index.md)[`IMPORT INTO`](/sql-statements/sql-statement-import-into.md))。

### `ADD INDEX` 的使用限制

- 集群内同时只能有一个 `ADD INDEX` 任务进行分布式执行。如果在当前的 `ADD INDEX` 分布式任务还未执行完成时就提交了一个新的 `ADD INDEX` 任务,则新提交的 `ADD INDEX` 任务不会被该框架调度,而是直接通过事务的方式来执行。
- 不支持通过分布式执行框架对数据类型为 `TIMESTAMP` 的列添加索引,否则会导致索引和数据不一致的问题。

## 启用前提

如需使用分布式执行框架执行 `ADD INDEX` 任务,需要先开启 [Fast Online DDL](/system-variables.md#tidb_ddl_enable_fast_reorg-从-v630-版本开始引入) 模式。
如需使用分布式执行框架执行 [`ADD INDEX`](/sql-statements/sql-statement-add-index.md) 任务,需要先开启 [Fast Online DDL](/system-variables.md#tidb_ddl_enable_fast_reorg-从-v630-版本开始引入) 模式。

1. 调整 Fast Online DDL 相关的系统变量:

Expand Down Expand Up @@ -83,14 +82,14 @@ TiDB 采用计算存储分离架构,具有出色的扩展性和弹性的扩缩

-v7.4.0v8.0.0 及其之间的版本中,[`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入) 的可选值为 `''` 或 `background`。如果当前集群存在 `tidb_service_scope = 'background'` 的 TiDB 节点,分布式执行框架会将该任务调度到 `tidb_service_scope = 'background'` 的节点上运行。如果当前集群不存在 `tidb_service_scope = 'background'` 的节点,无论是因为故障还是正常的缩容,分布式执行框架会将任务调度到 `tidb_service_scope = ''` 的节点上运行。

-v8.1.0 起,[`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入) 可设置为任意合法值。当提交分布式任务时,该任务会绑定当前连接的 TiDB 节点的 `tidb_service_scope` 值,分布式执行框架只会将该任务调度到具有相同 `tidb_service_scope` 值的 TiDB 节点上运行。但是,为了兼容之前版本的配置,如果分布式任务是在 `tidb_service_scope = ''` 的节点上提交的,且当前集群存在 `tidb_service_scope = 'background'` 的节点,分布式执行框架会将该任务调度到 `tidb_service_scope = 'background'` 的 TiDB 节点上运行。
-v8.1.0 起,[`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入) 可设置为任意合法值。当提交分布式任务时,该任务会绑定当前连接的 TiDB 节点的 [`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入) 值,分布式执行框架只会将该任务调度到具有相同 [`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入) 值的 TiDB 节点上运行。但是,为了兼容之前版本的配置,如果分布式任务是在 `tidb_service_scope = ''` 的节点上提交的,且当前集群存在 `tidb_service_scope = 'background'` 的节点,分布式执行框架会将该任务调度到 `tidb_service_scope = 'background'` 的 TiDB 节点上运行。

如果在任务运行过程中扩容新节点,分布式执行框架会根据上述规则决定是否将任务调度到新的节点来执行。如果不希望新扩容的节点运行任务,建议提前为这些节点设置 `tidb_service_scope`
v8.1.0 起,如果在任务运行过程中扩容新节点,分布式执行框架会根据上述规则决定是否将任务调度到新的节点来执行。如果不希望新扩容的节点运行任务,建议提前为这些节点设置 [`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入),取值要和已经在运行分布式任务的 TiDB 节点不同

> **注意:**
>
> -v7.4.0v8.0.0 及其之间的版本中,对于包含多个 TiDB 节点的集群,强烈建议选择两个或更多的 TiDB 节点将 `tidb_service_scope` 设置为 `background`。若仅在单个 TiDB 节点上设置此变量,当该节点发生重启或故障时,任务会被重新调度到 `tidb_service_scope = ''` 的 TiDB 节点,会对这些 TiDB 节点的业务产生影响。
> - 在分布式任务执行过程中,修改 `tidb_service_scope` 的配置不会对当前任务生效,会从下次任务开始生效。
> -v7.4.0v8.0.0 及其之间的版本中,对于包含多个 TiDB 节点的集群,强烈建议选择两个或更多的 TiDB 节点将 [`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入) 设置为 `background`。若仅在单个 TiDB 节点上设置此变量,当该节点发生重启或故障时,任务会被重新调度到 `tidb_service_scope = ''` 的 TiDB 节点,会对这些 TiDB 节点的业务产生影响。
> - 在分布式任务执行过程中,修改 [`tidb_service_scope`](/system-variables.md#tidb_service_scope-从-v740-版本开始引入) 的配置不会对当前任务生效,会从下次任务开始生效。

## 实现原理

Expand Down
4 changes: 2 additions & 2 deletions tiproxy/tiproxy-overview.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ TiProxy 是可选组件,你也可以使用第三方的代理组件,或者直

TiProxy 示意图如下:

<img src="https://download.pingcap.com/images/docs-cn/tiproxy/tiproxy-architecture.png" alt="TiProxy 架构" width="500"></img>
<img src="https://download.pingcap.com/images/docs-cn/tiproxy/tiproxy-architecture.png" alt="TiProxy 架构" width="500" />

## 主要功能

Expand All @@ -23,7 +23,7 @@ TiProxy 在保持客户端连接不变的情况下,能将一台 TiDB server

如下图所示,原先客户端通过 TiProxy 连接到 TiDB 1 上,连接迁移之后,客户端实际连接到 TiDB 2 上。在 TiDB 1 即将下线或 TiDB 1 上的连接数比 TiDB 2 上的连接数超过设定阈值时,会触发连接迁移。连接迁移对客户端无感知。

<img src="https://download.pingcap.com/images/docs-cn/tiproxy/tiproxy-session-migration.png" alt="TiProxy 连接迁移" width="400"></img>
<img src="https://download.pingcap.com/images/docs-cn/tiproxy/tiproxy-session-migration.png" alt="TiProxy 连接迁移" width="400" />

连接迁移通常发生在以下场景:

Expand Down

0 comments on commit 4f63b5b

Please sign in to comment.