Skip to content

fix(backup): preserve table-ID history across physical restore - #30743

Merged
XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
LeftHandCold:fix/backup-table-id-history-30738
Oct 21, 2026
Merged

XuPeng-SH merged 6 commits into
matrixorigin:mainfrom
LeftHandCold:fix/backup-table-id-history-30738

Conversation

@LeftHandCold

Copy link
Copy Markdown
Collaborator

What type of PR is this?

  • API-change
  • BUG
  • Improvement
  • Documentation
  • Feature
  • Test and CI
  • Code Refactoring

Which issue(s) this PR fixes:

issue #30738

What this PR does / why we need it:

Physical backup metadata currently gives its special checkpoint an empty table-ID index. The archive also omits the root-level objects referenced by the preceding checkpoint's index. After restore, the next ICKP therefore starts a partial history at the backup boundary; an immediate GCKP fails the existing 24-hour completeness check even when the source had complete history.

This change preserves the real history instead of bypassing that check:

  • Copy the exact durable predecessor's index objects before the long data-copy phase. Verify checksums, reuse identical destination objects, and reject mismatched content without overwriting it.
  • Extend that proven history through the actual rewritten special checkpoint, persist its locations in backup metadata, and include every new index object in the archive file list with its size and checksum.
  • Respect inclusive ICKP/backup-tail versus synthetic GCKP end boundaries. Keep legacy empty-index archives partial, including repeated archive backups; do not bridge an indexed history gap.
  • Precisely clean newly generated index objects on failure before metadata publication. Never delete predecessor objects or objects whose metadata publication may already be durable.
  • Assert the formerly ignored post-restore GCKP errors in two existing tests. Add a 20-row real backup -> separate WAL-directory restore -> immediate GCKP -> append/delete -> ICKP -> restart regression, with durable metadata, history range, archive-manifest and row/value oracles. The test observes source/global/incremental LSNs 4 -> 0 -> 1.
  • Add exact-predecessor, legacy, missing/mismatched-object and cleanup-failure cases. Keep the existing true-gap GCKP fail-closed test unchanged.

No disk-format column, history-window reduction, fake coverage marker, restore-epoch exception, or GCKP guard relaxation is introduced. The five-field backup checkpoint response is unchanged.

Scope: this repairs newly generated backups made with the fixed backup path. It cannot retroactively recover history objects absent from an existing archive; such archives remain subject to the real coverage window. This is an engine/backup-library integration validation, not an execution of the external mo-backup image or a customer-cluster acceptance test.

Tested with (CPU, Darwin/arm64, Go 1.27.1; repository CGo wrapper):

  • Complete pkg/backup normal and race suites.
  • Complete pkg/vm/engine/tae/db/checkpoint and pkg/vm/engine/tae/logtail normal and race suites.
  • TestGlobalCheckpointTableIDHistoryFallbackAndFailClosed, normal/race and 29 consecutive exact race repetitions.
  • TestBackupRestoreGlobalCheckpointWithFreshWAL, normal/race and 20 consecutive exact race repetitions. The later legacy-selection cases are separately covered by the final complete normal/race Backup suites.
  • Pre-fix runs reproduce the missing-history error both in the existing test with its missing assertion restored and in the separate-WAL recovery regression.
  • gofmt and git diff --check.

The public SQL syntax/frontend are unchanged. The new integration fixture exercises the real physical-archive writer and the restore/checkpoint/restart consumer, which an ordinary SQL-only BVT cannot cover without owning a restore and a fresh WAL directory. No production resources were modified.

@qodo-code-review

Copy link
Copy Markdown

Qodo reviews are paused for this user.

Troubleshooting steps vary by plan Learn more →

On a Teams plan?
Reviews resume once this user has a paid seat and their Git account is linked in Qodo.
Link Git account →

Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center?
These require an Enterprise plan - Contact us
Contact us →

@LeftHandCold LeftHandCold left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed head: 85c884617ba68869c89f32936a6b09fd64209d7c

结论:本轮代码审查未发现需要阻断合并的问题(code-review verdict: would approve)。这不是 CI 已通过或生产验收通过的声明。

重点复核:

  • 修复落在现有备份/检查点职责内,复用 SyncTableIDBatchWithHistory 与既有 TableIDLocation;没有新增恢复状态机、磁盘列格式或绕过 GCKP 历史完整性校验。
  • 精确区分 ICKP 的 inclusive end 与 GCKP 的 exclusive end,真实历史缺口仍然拒绝;旧索引文件和新生成索引都实际进入归档及带 checksum 的清单,不只是写一个引用。
  • 检查了缺失文件、目标同名但内容不一致、Stat/Read/Delete 失败,以及元数据发布前后的清理所有权。未发现误删已被引用索引的新增路径。
  • 恢复测试使用独立 WAL,校验恢复后立即 GCKP、后续写入/删除/ICKP、再次重启后的数据;没有用放宽历史窗口来掩盖问题。
  • 新开销集中在备份时的历史索引读取、校验和复制,不在常规 SQL/事务热路径。本次未做大规模备份性能基准,不把静态分析表述成性能实测。

验证方式:核对并复用本地保存的测试原始日志、相关源文件指纹和修复前失败反例;本轮仅执行格式/diff 等轻量检查,没有重复启动重型构建或 UT。checkpoint/logtail normal/race 与真实缺口 fail-closed 测试的已有证据可复用。

适用边界(非 blocker):这修复的是修复版本生成的新备份,不能补出旧归档里已缺失的历史;完整修复需要 CN/TN 两端都包含对应改动,滚动升级混合版本阶段不应承诺该边界场景已完全修复。当前部分 Linux UT/BVT/coverage/SCA CI 仍在运行,按仓库合并规则等待即可。

当前登录账号与 PR 作者相同,GitHub 不允许自审 Approve,因此提交 COMMENT 记录代码结论,不冒充正式 approval。

分支复核:与 #30744 联合检查,main 当前 head 相对原已测修复仅合入 5 个无关 Python SDK 文件,备份/检查点闭包和构建输入未变。备份包最终 normal/race 原始日志各有 60 项顶层测试通过。

@XuPeng-SH

XuPeng-SH commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

mo-bot review · mo-bot-local · done

Commit: 394af00454fbd48146de2ea4dd137c7e1bc233d7

Review completed. Read the assessment.

@mergify

mergify Bot commented Oct 21, 2026 •

Copy link
Copy Markdown
Contributor

Merge Queue Status

  • ✅ Entered queue — 2026-10-21 22:36 UTC · Rule: main · triggered by rule Automatic queue on approval for main
  • 🟠 Checks running · in-place
  • 🚫 Left the queue — 2026-10-21 23:14 UTC · at ceda268cfd4bbe20647eb8fc3a448ae9247b950b

This pull request spent 37 minutes 52 seconds in the queue, with no time running CI.

Reason

Pull request #30743 has been dequeued

Pull request from fork cannot be queued. This pull request comes from a fork, and Mergify needs the author's permission to update its branch.

The author needs to enable "Allow edits from maintainers" on this pull request.

Hint

You should look at the reason for the failure and decide if the pull request needs to be fixed or if you want to requeue it.
If you do update this pull request, it will automatically be requeued once the queue conditions match again.
If you think this was a flaky issue instead, you can requeue the pull request, without updating it, by posting a @mergifyio queue comment.

Waiting for any of
  • check-neutral = CI Required
  • check-skipped = CI Required
  • check-success = CI Required
All conditions

Tick the box to put this pull request back in the merge queue (same as @mergifyio queue).

  • Requeue this pull request

This branch was previously deployed

1 inactive deployment
ci — ceda268c Deployed Oct 22, 2026 by mergify[bot]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

dequeued kind/bug Something isn't working kind/test-ci size/L Denotes a PR that changes [500,999] lines

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants