-
Notifications
You must be signed in to change notification settings - Fork 0
test0315 #10
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
base: master
Are you sure you want to change the base?
test0315 #10
Changes from all commits
f7f3815
5225442
5a4750c
38b880c
11619c3
9759b99
b8d3bc3
6519f33
cda90b0
dae2736
2af15ff
2500028
c24f569
3145a1c
d52fde6
b704d99
72c3a73
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
| @@ -0,0 +1,67 @@ | ||||||
| --- | ||||||
| title: DDL 常见问题 | ||||||
| summary: 介绍 DDL 相关的常见问题。 | ||||||
| --- | ||||||
|
|
||||||
| # DDL 常见问题 | ||||||
|
|
||||||
| 本文档介绍 TiDB 中常见的些 DDL 问题。 | ||||||
|
|
||||||
| ## TiDB DDL 是否支持 DDL 语句间并行?具体的一些运行特征是怎样地? | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句存在语法错误,"怎样地" 应改为 "怎样的"。
Suggested change
|
||||||
|
|
||||||
| 在 TiDB v6.2 之后,TiDB 提供并发 DDL(concurrent DDL) 执行的能力。 并发 DDL 主要是提供 DDL 语句间的并发执行支持。这里和以前的 DDL 执行将会发生如下变化: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够清晰,建议明确说明并发 DDL 的具体版本支持范围。
Suggested change
|
||||||
|
|
||||||
| 1. 需要判断 DDL 语句间是否有相关性,如果有相关性的 DDL 语句将会按照进入 TiDB 的顺序执行,没有相关性的 DDL 语句可以并发执行。并发判断规则: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够简洁,建议简化并明确相关性判断规则。
Suggested change
|
||||||
| 1. 相同表上的 DDL 语句之间具有相关性,需要按照进入 TiDB 的顺序执行; | ||||||
| 2. 对于 Schema 上的操作,可能会对于 schema 中的表上的 DDL 语句建立相关性,目前 Drop Schema 会对于其包含 Schema 上的 DDL 产生相关性;也需要顺序执行; | ||||||
| 2. 是否所有的 DDL 语句都会并发执行? | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够明确,建议补充说明哪些 DDL 语句不支持并发执行。
Suggested change
|
||||||
| 当前,答案是否定的,在 TiDB 中 DDL 语句被分为两类, | ||||||
| 1. 普通(general)DDL 语句,这类 DDL 语句的执行只需要修改对象的元数据,不需要操作 schema 存储的数据,通常在秒级完成;需要的计算资源相对少; | ||||||
| 2. 需要重组(reorg)DDL 语句, 这类 DDL 语句的执行不仅需要修改对象的元数据,也需要对于 schema 存储的数据进行处理,例如:加索引,需要扫描全表数据,来创建索引,需要比较多的计算资源与较长的执行时间; | ||||||
| 当前我们仅对于需要重组的 DDL 语句启动了并发执行支持。 | ||||||
| 3. 对于启动了并发 DDL 语句支持的 TiDB 集群,DDL 语句间的并发度是如何确定的? | ||||||
| 目前因为 DDL 等后台任务的执行可能会占用相当的资源,因此我们采取了一个相对保守的策略来确定 DDL 语句执行的并发度 | ||||||
| 1. 对于普通 DDL(general DDL) 语句,我们当前语句并发度为 1(后续将会提供并发执行支持); | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够清晰,建议明确说明并发度的计算方式。
Suggested change
|
||||||
| 2. 对于需要重组的 DDL(Reorg DDL)语句,我们的并发度设置规则如下(并发度不允许用户自己设置): | ||||||
| TiDB DDL owner 节点容器能够使用的 CPU 资源数量的 1/4 与 1 之间的最大值,例如 8C 规格的 TiDB DDL owner 节点,并发度将会是 2。 | ||||||
|
|
||||||
| ## TiDB DDL 的优先级如何定义? | ||||||
| 由于 DDL 语句,特别是需要重组的 DDL 语句在执行的过程中可能会占用较多计算或者存储引擎资源,从而导致对于前端用户业务的影响。通过对 DDL 任务设置 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够简洁,建议简化并明确优先级设置的目的。
Suggested change
|
||||||
| - [`tidb_ddl_reorg_priority`](/system-variables.md#tidb_ddl_reorg_priority) | ||||||
| 对与 DDL 等任务如果用户在业务高峰期间,可以将优先级调低,这样 TiDB 集群会通过优先级降低 DDL 对于集群资源的争抢。 | ||||||
| - 其他参数的设置可以参考: | ||||||
| - [`tidb_ddl_reorg_worker_cnt`](/system-variables.md#tidb_ddl_reorg_worker_cnt) | ||||||
| - [`tidb_ddl_reorg_priority`](/system-variables.md#tidb_ddl_reorg_priority) | ||||||
| - [`tidb_ddl_error_count_limit`](/system-variables.md#tidb_ddl_error_count_limit) | ||||||
| - [`tidb_ddl_reorg_batch_size`](/system-variables.md#tidb_ddl_reorg_batch_size) | ||||||
|
|
||||||
| ## 快速加索引方式的启动常见问题: | ||||||
| 从 TiDB v6.3 开始,我们为 TiDB 用户提供了 快速加索引的模式,可以相对于 v6.1 提升 10倍的速度。我们在 TiDB v6.5 快速加索引模式已经 GA。 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够清晰,建议明确说明快速加索引模式的具体版本支持范围。
Suggested change
|
||||||
| 这里说明一下从低版本升级上来,的一些检查事项: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够简洁,建议简化并明确检查事项的目的。
Suggested change
|
||||||
| **TiDB 配置参数**: | ||||||
| - [`temp-dir`](/tidb-configuration-file#temp-dir-new-in-v630) 这个参数用来指定快速加索引模式执行本地磁盘路径。 | ||||||
| - 对于 On Premises 用户, 需要用户提前挂载好 SSD 磁盘,配置好相应路径,然后进行升级操作,重启后检查 TiDB | ||||||
| ```sql | ||||||
| mysql> SHOW CONFIG WHERE type = 'tidb' AND name = 'temp-dir'; | ||||||
| +------+---------------------------------------------------------------------------------------------+----------+-----------+ | ||||||
| | Type | Instance | Name | Value | | ||||||
| +------+---------------------------------------------------------------------------------------------+----------+-----------+ | ||||||
| | tidb | tidb-2:4000 | temp-dir | /tmp/tidb | | ||||||
| | tidb | tidb-1:4000 | temp-dir | /tmp/tidb | | ||||||
| | tidb | tidb-0:4000 | temp-dir | /tmp/tidb | | ||||||
| +------+---------------------------------------------------------------------------------------------+----------+-----------+ | ||||||
| 3 rows in set (0.52 sec) | ||||||
| ``` | ||||||
| **注意:** 这个是一个配置参数,需要重启 TiDB 节点,上面 `Value` 字段查询出来值应该和用户设置的值应该一致。 | ||||||
| - 对于 Cloud 用户,我们对于能够使用快速加索引功能的使用有一些限制: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够清晰,建议明确说明 Cloud 用户使用快速加索引功能的限制条件。
Suggested change
|
||||||
|
|
||||||
| | 描述 | 供应商 | TiDB CPU 规格 | 是否支持快速索引模 | 备注 | | ||||||
| |-----------------------|-----|------------------|------------|------| | ||||||
| | TiDB cloud Dedicated | AWS | 2C vCPU, 4C vCPU | 不支持 | 成本问 | | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 备注中的描述不完整,"成本问" 应改为 "成本问题" 以保持一致性。
Suggested change
|
||||||
| | | | \>= 8C vCPU | 支持 | | | ||||||
| | | GCP | ALL | 不支持 | | | ||||||
|
|
||||||
| TiDB 系统变量设置: | ||||||
| - [`tidb_ddl_enable_fast_reorg`](/system-variables.md#tidb_ddl_enable_fast_reorg-从-v630-版本开始引入) | ||||||
| 这个系统变量在 TiDB v6.5 默认打开。 | ||||||
| - [`tidb_ddl_disk_quota`](/system-variables.md#tidb_ddl_disk_quota-从-v630-版本开始引入):这个系统变量用来控制快速加索引方式本地磁盘能够使用的限额,对于 on Premises 用户来说可以根实际情况增加这个值。 | ||||||
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -438,3 +438,46 @@ TiDB 有事务超时的机制,当事务运行超过 [`max-txn-ttl`](/tidb-conf | |||||
| > **注意:** | ||||||
| > | ||||||
| > 当同步存储生成列到 Kafka 或存储服务后,再将其写回 MySQL 时,可能会遇到 `Error 3105 (HY000): The value specified for generated column 'xx' in table 'xxx' is not allowed` 错误。为避免该错误,你可以使用 [Open Protocol](/ticdc/ticdc-open-protocol.md) 进行同步。该协议的输出包含[列的 flag 值](/ticdc/ticdc-open-protocol.md#列标志位),可以区分是否为生成列。 | ||||||
|
|
||||||
| ## 当频繁出现 `CDC:ErrMySQLDuplicateEntryCDC` 错误时,如何解决? | ||||||
|
|
||||||
| 使用 TiCDC 将数据同步到 TiDB 或 MySQL 时,如果上游以特定模式执行 SQL ,可能会遇到如下错误: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够清晰,建议明确说明上游执行 SQL 的具体模式,以便用户更好地理解问题。
Suggested change
|
||||||
|
|
||||||
| `CDC:ErrMySQLDuplicateEntryCDC` | ||||||
|
|
||||||
| 出现该错误的原因:TiDB 会将同一事务内对同一行的 `DELETE + INSERT` 操作提交为一个 `UPDATE` 行变更,当 TiCDC 以 UPDATE 的形式向下游同步数据时,尝试交换唯一键值的 `UPDATE` 操作可能会出现冲突。 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句逻辑不够清晰,建议明确说明 TiCDC 如何处理
Suggested change
|
||||||
|
|
||||||
| 以下表为例: | ||||||
|
|
||||||
| ```sql | ||||||
| CREATE TABLE data_table ( | ||||||
| id BIGINT(20) NOT NULL PRIMARY KEY, | ||||||
| value BINARY(16) NOT NULL, | ||||||
| UNIQUE KEY value_index (value) | ||||||
| ) CHARSET=utf8mb4 COLLATE=utf8mb4_bin; | ||||||
| ``` | ||||||
|
|
||||||
| 如果上游事务尝试交换该表中两行的 `value` 字段: | ||||||
|
|
||||||
| ```sql | ||||||
| DELETE FROM data_table WHERE id = 1; | ||||||
| DELETE FROM data_table WHERE id = 2; | ||||||
| INSERT INTO data_table (id, value) VALUES (1, 'v3'); | ||||||
| INSERT INTO data_table (id, value) VALUES (2, 'v1'); | ||||||
| ``` | ||||||
|
|
||||||
| TiDB 内部将会产生两条 `UPDATE` 行变更,因此 TiCDC 会将其转化成两条 `UPDATE` 语句同步到下游: | ||||||
|
|
||||||
| ```sql | ||||||
| UPDATE data_table SET value = 'v3' WHERE id = 1; | ||||||
| UPDATE data_table SET value = 'v1' WHERE id = 2; | ||||||
| ``` | ||||||
|
|
||||||
| 在执行第二条 `UPDATE` 语句时,如果下游的表中仍然存在 `v1`,会破坏 `value` 列的唯一键约束,从而导致 `CDC:ErrMySQLDuplicateEntryCDC` 错误。 | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句描述不够准确,建议明确说明
Suggested change
|
||||||
|
|
||||||
| 如果你频繁遇到 `CDC:ErrMySQLDuplicateEntryCDC` 错误,可以在 `sink-uri` 配置中设置 `safe-mode=true` 参数启用 TiCDC 安全模式: | ||||||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 该句建议补充说明启用安全模式的具体影响,以便用户权衡利弊。
Suggested change
|
||||||
|
|
||||||
| ``` | ||||||
| mysql://user:password@host:port/?safe-mode=true | ||||||
| ``` | ||||||
| 在安全模式下,TiCDC 会将 `UPDATE` 操作拆分为 `DELETE + INSERT` 进行执行,从而避免唯一键冲突错误。 | ||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
该句存在语法错误,"常见的些" 应改为 "常见的"。