Skip to content

restore: update the definition of the parameter --load-stats and the usage of pitr id map #20346

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

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

Leavrth
Copy link
Contributor

@Leavrth Leavrth commented May 19, 2025

First-time contributors' checklist

What is changed, added or deleted? (Required)

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.4 (TiDB 8.4 versions)
  • v8.3 (TiDB 8.3 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)
  • v6.1 (TiDB 6.1 versions)
  • v5.4 (TiDB 5.4 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

Leavrth added 2 commits May 19, 2025 10:43
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
@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 May 19, 2025
@Oreoxmt Oreoxmt added translation/doing This PR’s assignee is translating this PR. do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. v9.0-beta.2 This PR/issue applies to TiDB v9.0-beta.2. labels May 19, 2025
@ti-chi-bot ti-chi-bot bot removed the missing-translation-status This PR does not have translation status info. label May 19, 2025
@Oreoxmt Oreoxmt assigned Oreoxmt and lilin90 and unassigned Oreoxmt May 19, 2025
@Oreoxmt Oreoxmt requested a review from lilin90 May 19, 2025 03:38
Signed-off-by: Jianjun Liao <[email protected]>
Copy link

ti-chi-bot bot commented May 23, 2025

[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 ask for approval from lilin90. 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.

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 size/M Denotes a PR that changes 30-99 lines, ignoring generated files. and removed size/S Denotes a PR that changes 10-29 lines, ignoring generated files. labels May 23, 2025
Leavrth and others added 5 commits May 23, 2025 12:15
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
Signed-off-by: Jianjun Liao <[email protected]>
@lilin90 lilin90 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 May 30, 2025
@lilin90 lilin90 added the type/compatibility-or-feature-change This PR involves compatibility changes or feature behavior changes. label Jun 9, 2025
@@ -89,7 +89,11 @@ br 工具暂停 GC 的原理是通过执行 `SET config tikv gc.ratio-threshold

在第一次执行恢复并且进入日志恢复阶段时,br 工具会在恢复集群中创建 `__TiDB_BR_Temporary_Log_Restore_Checkpoint` 数据库,用于记录断点数据,以及这次恢复的上游集群 ID 和恢复的时间范围 `start-ts` 与 `restored-ts`。如果在此阶段恢复失败,重新执行恢复命令时,你需要指定与断点记录相同的 `start-ts` 和 `restored-ts` 参数,否则 br 工具会报错,并提示上游集群 ID 或恢复的时间范围与断点记录不同。如果恢复集群已被清理,你可以手动删除 `__TiDB_BR_Temporary_Log_Restore_Checkpoint` 数据库,然后使用其他备份重试。

在第一次执行恢复并且进入日志恢复阶段前,br 工具会构造出在 `restored-ts` 时间点的上下游集群库表 ID 映射关系,并将其持久化到系统表 `mysql.tidb_pitr_id_map` 中,以避免库表 ID 被重复分配。如果删除 `mysql.tidb_pitr_id_map` 中的数据,可能会导致 PITR 恢复数据不一致。
在第一次执行恢复并且进入日志恢复阶段前,br 工具会构造出在 `restored-ts` 时间点的上下游集群库表 ID 映射关系,并将其持久化到系统表 `mysql.tidb_pitr_id_map` 中,以避免库表 ID 被重复分配。**如果随意删除 `mysql.tidb_pitr_id_map` 中的数据,可能会导致 PITR 恢复数据不一致。**
Copy link
Member

Choose a reason for hiding this comment

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

  • Line 86 写到“PITR 恢复分为快照恢复和日志恢复两个阶段”,下面这三段看起来像分了三个阶段。请看下是否调整该小节开头的描述,或者这三段的逻辑和呈现?
  • 另外,从字面语义上看,“在第一次执行恢复并且进入日志恢复阶段”应该放在“在第一次执行恢复并且进入日志恢复阶段”前面?

@@ -132,8 +132,19 @@ tiup br restore full \
--storage local:///br_data/ --pd "${PD_IP}:2379" --log-file restore.log
```

> **注意:**
>
> 从 v9.0.0 起,当设置参数 `--load-stats` 为 false 时,br 将不会在表 `mysql.stats_meta` 中更新恢复的表的相关信息。你可以在恢复完成后手动执行 analyze table,更新相关统计信息。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> 从 v9.0.0 起,当设置参数 `--load-stats` false 时,br 将不会在表 `mysql.stats_meta` 中更新恢复的表的相关信息。你可以在恢复完成后手动执行 analyze table,更新相关统计信息
> 从 v9.0.0 起,当参数 `--load-stats` 设置为 `false` 时,br 不再向 `mysql.stats_meta` 表写入恢复表的统计信息。你可以在恢复完成后手动执行 `ANALYZE TABLE`,以更新相关统计信息

备份恢复功能在备份时,将统计信息通过 JSON 格式存储在 `backupmeta` 文件中。在恢复时,将 JSON 格式的统计信息导入到集群中。详情请参考 [LOAD STATS](/sql-statements/sql-statement-load-stats.md)。

从 9.0.0 起,BR 引入参数 `--fast-load-sys-tables`,默认开启。当 br 命令行工具恢复在全新集群并且上下游表和分区的 ID 都能被复用时(否则,将自动回退为逻辑导入统计信息数据),通过设置 `--fast-load-sys-tables` 会将统计信息相关表恢复到临时系统库 `__TiDB_BR_Temporary_mysql` 中,再通过 `RENAME TABLE` DDL 将恢复的统计信息表和 `mysql` 库下的表进行原子交换。示例如下:
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
9.0.0 起,BR 引入参数 `--fast-load-sys-tables`默认开启。当 br 命令行工具恢复在全新集群并且上下游表和分区的 ID 都能被复用时(否则,将自动回退为逻辑导入统计信息数据),通过设置 `--fast-load-sys-tables` 会将统计信息相关表恢复到临时系统库 `__TiDB_BR_Temporary_mysql` 中,再通过 `RENAME TABLE` DDL 将恢复的统计信息表和 `mysql` 库下的表进行原子交换。示例如下
v9.0.0 起,BR 引入参数 `--fast-load-sys-tables`该参数默认开启。在使用 br 命令行工具将数据恢复到一个全新集群,且上下游的表和分区 ID 能够复用的前提下(否则会自动回退为逻辑导入统计信息),开启 `--fast-load-sys-tables` 后,br 会先将统计信息相关表恢复至临时系统库 `__TiDB_BR_Temporary_mysql` 中,再通过 `RENAME TABLE` 语句将这些表与 `mysql` 库下的原有表进行原子性替换。使用示例如下


> **注意:**
>
> 与通过 `REPLACE INTO` SQL 写入的逻辑恢复系统表方式不同,物理恢复系统表将会完全覆盖系统表中原有的数据。
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
> 与通过 `REPLACE INTO` SQL 写入的逻辑恢复系统表方式不同,物理恢复系统表将会完全覆盖系统表中原有的数据
> 与通过 `REPLACE INTO` SQL 语句执行的逻辑恢复系统表方式不同,物理恢复系统表会完全覆盖系统表中的原有数据

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. size/M Denotes a PR that changes 30-99 lines, ignoring generated files. translation/done This PR has been translated from English into Chinese and updated to pingcap/docs-cn in a PR. type/compatibility-or-feature-change This PR involves compatibility changes or feature behavior changes. v9.0-beta.2 This PR/issue applies to TiDB v9.0-beta.2.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants