Skip to content

Fix migration and Lightning doc inconsistencies - #22099

Open
doc-claw-bot wants to merge 1 commit into
pingcap:masterfrom
doc-claw-bot:docs-cn/migration-lightning-consistency-feedback-v2
Open

doc-claw-bot wants to merge 1 commit into
pingcap:masterfrom
doc-claw-bot:docs-cn/migration-lightning-consistency-feedback-v2

Conversation

@doc-claw-bot

@doc-claw-bot doc-claw-bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Collaborator

What is changed, added, or deleted? (Required)

  • 同步修复 DM 小规模 MySQL 迁移文档中的任务文件名示例,使 check-task 和 start-task 与前文创建的 task1.yaml 保持一致。
  • 同步补充 TiDB 到 TiDB 迁移文档中的切换说明,明确在暂停 changefeed 之前先确认复制已经追平。
  • 同步补充 Lightning 最佳实践中的 strict-format 和 conflict.threshold 说明,并修正物理导入模式文档中的 conflict.threshold 默认值描述。

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)
  • v9.0 (TiDB 9.0 versions)
  • v8.5 (TiDB 8.5 versions)
  • v8.1 (TiDB 8.1 versions)
  • v7.5 (TiDB 7.5 versions)
  • v7.1 (TiDB 7.1 versions)
  • v6.5 (TiDB 6.5 versions)

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

AI agent involvement

  • The changes in this PR were primarily made by an AI agent on behalf of the PR author.

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

Summary by CodeRabbit

  • 文档
    • 更新 TiDB 迁移步骤:停写后先检查 changefeed,确认 checkpoint 时间晚于停写时间,再暂停并复查状态。
    • 统一将相关迁移命令及重试说明中的任务配置文件名改为 task1.yaml。
    • 补充 Lightning 冲突阈值说明:replace 和 ignore 策略的默认值为 10000;预计冲突数较多时需显式设置,较高阈值可能影响导入性能。
    • 调整 strict-format 建议,明确适用条件包括 CSV 字段不含嵌入式换行符。

@ti-chi-bot ti-chi-bot Bot added the contribution This PR is from a community contributor. label Nov 24, 2026
@ti-chi-bot

ti-chi-bot Bot commented Nov 24, 2026

Copy link
Copy Markdown

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by:
Once this PR has been reviewed and has the lgtm label, please assign breezewish for approval. For more information see the Code Review Process.
Please ensure that each of them provides their approval before proceeding.

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

Details 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 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 Nov 24, 2026
@doc-claw-bot doc-claw-bot added type/bugfix This PR fixes a bug. area/dm area/ticdc Indicates that the Issue or PR belongs to the area of TiCDC. area/tidb-lightning Indicates that the Issue or PR belongs to the area of TiDB Lightning. translation/from-docs This PR is translated from a PR in pingcap/docs. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. ONCALL Relates to documentation oncall. and removed missing-translation-status This PR does not have translation status info. labels Nov 24, 2026
@coderabbitai

coderabbitai Bot commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor

Explain Change →

Walkthrough

本次更新涉及迁移指南和 TiDB Lightning 文档。迁移指南调整 changefeed 检查顺序,并将任务配置文件名统一改为 task1.yaml。TiDB Lightning 文档更新 strict-format 使用条件和冲突阈值说明。

Changes: TiDB 到 TiDB 迁移

Layer / File(s) Summary
停写后的 changefeed 检查
migrate-from-tidb-to-tidb.md
停写后先指定 --server 检查 checkpoint 时间,再暂停 changefeed;暂停后再次查看状态。

MySQL 到 TiDB 迁移

Layer / File(s) Summary
统一任务配置文件名
migrate-small-mysql-shards-to-tidb.md, migrate-small-mysql-to-tidb.md
配置检查、启动命令和启动失败后的重试说明均将配置文件名改为 task1.yaml。

TiDB Lightning CSV 格式建议

Layer / File(s) Summary
收窄 strict-format 建议条件
tidb-lightning/data-import-best-practices.md
仅当文件超过 256 MiB 且 CSV 字段不含嵌入式换行符(包括引号包裹的值)时,才建议启用 strict-format。

TiDB Lightning 冲突阈值

Layer / File(s) Summary
更新默认阈值说明
tidb-lightning/data-import-best-practices.md, tidb-lightning/tidb-lightning-physical-import-mode-usage.md
说明 replace 或 ignore 策略的默认 conflict.threshold 为 10000。预计冲突数超过该值时需显式设置;设置更高的值可能降低导入性能。

Estimated code review effort: 2 (Simple) | ~8 minutes

Change: Other

Suggested reviewers: qiancai, lyzx2001

Merge Risk: Moderate · up to 8690f

The TiDB-to-TiDB migration guide can lead users to pause replication before it has caught up, which risks missing data after cutover. The Lightning docs also describe an ignore conflict strategy that physical import mode rejects. Fix the cutover instructions and the Lightning wording before merging.

Pre-merge checks: Passed 4

Check name Status Explanation
Title check Passed 标题“Fix migration and Lightning doc inconsistencies”描述了本 PR 的主要内容:修正迁移文档与 Lightning 文档之间的不一致。变更涵盖 DM 小规模 MySQL 迁移的文件名、TiDB 到 TiDB 迁移的切换顺序,以及 Lightning 的 strict-format 与 conflict.threshold 说明。标题与变更集相关,但…
Description check Passed 描述基本完整。已填写变更内容、适用版本(master 与 v8.5)、相关 PR 与参考链接,并勾选 AI 代理参与选项。模板中的首次贡献者检查项与 CLA 复选框可视为可选内容。描述中未列出迁移文档、Lightning 文档的具体修改位置,但主要信息已提供。
Linked Issues check Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check Passed Check skipped because no linked issues were found for this pull request.
Full details: Title check

Explanation

标题“Fix migration and Lightning doc inconsistencies”描述了本 PR 的主要内容:修正迁移文档与 Lightning 文档之间的不一致。变更涵盖 DM 小规模 MySQL 迁移的文件名、TiDB 到 TiDB 迁移的切换顺序,以及 Lightning 的 strict-format 与 conflict.threshold 说明。标题与变更集相关,但较为宽泛,未具体说明任何一项修改。

Finishing Touches

Generate unit tests (beta)

  • Create a new PR
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

Share

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Actionable comments posted: 5

Review info

Run configuration

Commits

Reviewing files that changed from the base of the PR and between ae522e7 and 8690fb3.

Files selected for processing: 5

  • migrate-from-tidb-to-tidb.md
  • migrate-small-mysql-shards-to-tidb.md
  • migrate-small-mysql-to-tidb.md
  • tidb-lightning/data-import-best-practices.md
  • tidb-lightning/tidb-lightning-physical-import-mode-usage.md

Included review availability: This review used your included allowance. Your plan provides up to 4 included reviews per hour; 3 remain after this review.

通过 TiCDC 创建上下游的同步链路后,原集群的写入数据会以非常低的延迟同步到新集群,此时可以逐步将读流量迁移到新集群了。观察一段时间,如果新集群表现稳定,就可以将写流量接入新集群,步骤如下:

1. 停止上游集群的写业务。确认上游数据已全部同步到下游后,停止上游到下游集群的 changefeed。
1. 停止上游集群的写业务。停写后,先查看 changefeed 状态,确认 `checkpoint` 时间晚于停写时间,再停止上游到下游集群的 changefeed。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Data Integrity & Integration · Quick win

使用上游 TSO 判断同步进度

如果停写时间取自与上游 PD 时钟不一致的机器,checkpoint 看似晚于停写时间,也可能仍有数据未同步。切换后,上下游数据会不一致。

请在停写后获取上游 TSO,并按 TiCDC FAQ 的方法比较同步进度。(raw.githubusercontent.com) As per coding guidelines,“优先保证技术事实准确”;“涉及风险、限制、兼容性、数据丢失、性能影响时,必须明确说明影响范围和触发条件”。

Source: Coding guidelines


```shell
# 查看 changefeed 状态,并确认 checkpoint 时间晚于停写时间
tiup cdc cli changefeed list --server=http://172.16.6.122:8300

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Major · Data Integrity & Integration · Quick win

将检查命令与暂停命令分开放置。

第 1 个代码块同时包含 list、pause 和第二次 list。用户复制整个块时,第一次 list 返回后 shell 会立即执行 pause,不会等待用户确认 checkpoint。如果同步尚未追平,暂停后切换写流量可能导致上游未复制的数据在下游缺失。

将查询、暂停和复查放入独立代码块。在暂停命令前说明需确认 checkpoint 时间晚于停写时间。

建议修改

--- "a/migrate-from-tidb-to-tidb.md"
+++ "b/migrate-from-tidb-to-tidb.md"
@@ -276,16 +276,21 @@
 
 1. 停止上游集群的写业务。停写后,先查看 changefeed 状态,确认 `checkpoint` 时间晚于停写时间,再停止上游到下游集群的 changefeed。
 
     ```shell
-    # 查看 changefeed 状态,并确认 checkpoint 时间晚于停写时间
     tiup cdc cli changefeed list --server=http://172.16.6.122:8300
-
-    # 停止旧集群到新集群的 changefeed
-    tiup cdc cli changefeed pause -c "upstream-to-downstream" --server=http://172.16.6.122:8300
-
-    # 再次查看 changefeed 状态
-    tiup cdc cli changefeed list --server=http://172.16.6.122:8300
     ```
+
+    确认 `checkpoint` 时间晚于停写时间后,再停止旧集群到新集群的 changefeed:
+
+    ```shell
+    tiup cdc cli changefeed pause -c "upstream-to-downstream" --server=http://172.16.6.122:8300
+    ```
+
+    暂停后,再次查看 changefeed 状态:
+
+    ```shell
+    tiup cdc cli changefeed list --server=http://172.16.6.122:8300
+    ```
 
     ```
     [

- 在给多个 TiDB Lightning 实例分配要导入的源文件时,尽量避免多个源文件之间存在重叠的主键或非空唯一索引的情况。如果生成文件是全局有序,可以按照范围划分不同的文件给不同 TiDB Lightning 实例进行导入,达到最佳导入效果。
- 在生成文件时,每个文件尽量控制在 96 MiB 以下。
- 如果文件特别大,超过 256 MiB,需要开启 [`strict-format`](/migrate-from-csv-files-to-tidb.md#第-4-步导入性能优化可选)。
- 如果文件特别大,超过 256 MiB,且 CSV 字段中不包含嵌入式换行符(包括被引号包裹的值),需要开启 [`strict-format`](/migrate-from-csv-files-to-tidb.md#第-4-步导入性能优化可选)。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Data Integrity & Integration · Quick win

条件需要覆盖任务中的所有 CSV 文件。

第 81 行只按单个文件描述条件。strict-format 是任务级配置,会作用于任务中所有超过 256 MiB 的 CSV 大文件。如果任务中另一个大 CSV 文件的字段内含换行符,该文件可能被错误切分,导致解析失败或静默导入损坏的数据。请修改条件,明确要求检查任务中的所有 CSV 文件。

建议修改

--- "a/tidb-lightning/data-import-best-practices.md"
+++ "b/tidb-lightning/data-import-best-practices.md"
@@ -78,7 +78,7 @@
 - 在生成文件时,在单个文件内尽量按照主键排序;如果表定义没有主键,可以添加一个自增主键,此时对文件内容顺序无要求。
 - 在给多个 TiDB Lightning 实例分配要导入的源文件时,尽量避免多个源文件之间存在重叠的主键或非空唯一索引的情况。如果生成文件是全局有序,可以按照范围划分不同的文件给不同 TiDB Lightning 实例进行导入,达到最佳导入效果。
 - 在生成文件时,每个文件尽量控制在 96 MiB 以下。
-- 如果文件特别大,超过 256 MiB,且 CSV 字段中不包含嵌入式换行符(包括被引号包裹的值),需要开启 [`strict-format`](/migrate-from-csv-files-to-tidb.md#第-4-步导入性能优化可选)。
+- 如果任务中存在超过 256 MiB 的 CSV 大文件,且该任务中的所有 CSV 文件都不包含嵌入式换行符(包括被引号包裹的值),需要开启 [`strict-format`](/migrate-from-csv-files-to-tidb.md#第-4-步导入性能优化可选)。
 
 ## 预估存储空间
 
Committable suggestion

IMPORTANT
Review the replacement and indentation, then test before committing.

Suggested change
- 如果文件特别大,超过 256 MiB,且 CSV 字段中不包含嵌入式换行符(包括被引号包裹的值),需要开启 [`strict-format`](/migrate-from-csv-files-to-tidb.md#第-4-步导入性能优化可选)。
- 如果任务中存在超过 256 MiB 的 CSV 大文件,且该任务中的所有 CSV 文件都不包含嵌入式换行符(包括被引号包裹的值),需要开启 [`strict-format`](/migrate-from-csv-files-to-tidb.md#第-4-步导入性能优化可选)。

1. 排查源数据是否有主键、唯一键冲突,解决冲突后再重新导入。根据以往经验,主键和唯一键冲突是导致该报错的主要原因。
2. 表的主键、唯一键定义是否合理。如果不合理,更改表定义后重新导入。
3. 如果按上述两个步骤操作后仍未解决问题,需要进一步判断源数据中是否有少量(低于 10%)不可预期的冲突数据。如果需要 TiDB Lightning 帮助检测、解决冲突数据,需要开启[冲突检测功能](/tidb-lightning/tidb-lightning-physical-import-mode-usage.md#冲突数据检测)。
3. 如果按上述两个步骤操作后仍未解决问题,需要进一步判断源数据中是否有少量(低于 10%)不可预期的冲突数据。如果需要 TiDB Lightning 帮助检测、解决冲突数据,需要开启[冲突检测功能](/tidb-lightning/tidb-lightning-physical-import-mode-usage.md#冲突数据检测)。当 `conflict.strategy` 为 `"replace"` 或 `"ignore"` 时,[`conflict.threshold`](/tidb-lightning/tidb-lightning-configuration.md#tidb-lightning-任务配置) 的默认值为 `10000`。如果预计冲突数会超过该值,需要显式设置 `conflict.threshold`。取值大于 `10000` 可能会降低导入性能。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

限定 ignore 策略的导入模式

本文介绍物理导入模式,但新增说明将 "ignore" 与 "replace" 并列。物理导入模式不支持 "ignore";用户选择该策略后会遇到配置错误。请删除此处的 "ignore",或说明它仅适用于逻辑导入模式。(raw.githubusercontent.com)

As per coding guidelines,“站在用户角度写作,优先说明用户关心的前提、步骤、结果、限制和风险”。

Source: Coding guidelines

> 由于 TiDB Lightning 内部并发处理以及实现限制,物理导入模式下的冲突检测效果不会与 SQL 语句完全一致。

配置为 `"error"` 时,遇到冲突数据时,TiDB Lightning 会报错并退出。配置为 `"replace"` 时,冲突数据被视作[冲突错误 (Conflict error)](/tidb-lightning/tidb-lightning-error-resolution.md#冲突错误-conflict-error)。配置了大于 `0` 的 [`conflict.threshold`](/tidb-lightning/tidb-lightning-configuration.md#tidb-lightning-任务配置) 后,TiDB Lightning 可以容忍一定数目的冲突错误,默认值为 `9223372036854775807`,意味着几乎能容忍全部错误。详见[可容忍错误](/tidb-lightning/tidb-lightning-error-resolution.md)功能介绍。
配置为 `"error"` 时,遇到冲突数据时,TiDB Lightning 会报错并退出。配置为 `"replace"` 时,冲突数据被视作[冲突错误 (Conflict error)](/tidb-lightning/tidb-lightning-error-resolution.md#冲突错误-conflict-error)。配置了大于 `0` 的 [`conflict.threshold`](/tidb-lightning/tidb-lightning-configuration.md#tidb-lightning-任务配置) 后,TiDB Lightning 可以容忍一定数目的冲突错误。当 `conflict.strategy` 为 `"replace"` 或 `"ignore"` 时,其默认值为 `10000`。详见[可容忍错误](/tidb-lightning/tidb-lightning-error-resolution.md)功能介绍。

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Minor · Functional Correctness · Quick win

区分物理导入模式支持的策略

本段将 "ignore" 与 "replace" 并列,容易让用户认为物理导入模式支持 "ignore"。但配置参考和 v8.5 源码均说明 "ignore" 仅适用于逻辑导入模式。请在本段删除 "ignore",或明确说明其适用范围。(github.com)

As per coding guidelines,“涉及风险、限制、兼容性、数据丢失、性能影响时,必须明确说明影响范围和触发条件”。

Source: Coding guidelines

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/dm area/ticdc Indicates that the Issue or PR belongs to the area of TiCDC. area/tidb-lightning Indicates that the Issue or PR belongs to the area of TiDB Lightning. contribution This PR is from a community contributor. needs-cherry-pick-release-8.5 Should cherry pick this PR to release-8.5 branch. ONCALL Relates to documentation oncall. size/S Denotes a PR that changes 10-29 lines, ignoring generated files. translation/from-docs This PR is translated from a PR in pingcap/docs. type/bugfix This PR fixes a bug.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant