Repository navigation
[4.2.1-hotfix] fix(backup): preserve GC retention and restore history - #31886
Conversation
…ckups (matrixorigin#29504) ## What type of PR is this? - [ ] API-change - [x] BUG - [x] Improvement - [ ] Documentation - [ ] Feature - [ ] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: Related to matrixorigin#28473 on `4.2-dev`. Backports matrixorigin#28525 and corrects historical-object selection, retained references, and the incomplete GC census assumption found in this PR's reviews. This does not close the corresponding main-branch work or claim that previously missing files can be recovered. ## What this PR does / why we need it: Backup can see separate creation and deletion records for one physical object. Filtering only the deletion record still tries to copy an object already reclaimed by GC. Conversely, filtering every old deletion can omit snapshot/PITR data and publish a successful but incomplete backup. The final correction resolves lifecycle identity before physical deduplication, retains compacted checkpoint references, and requires a committed GC census before using absence to omit an old object. Shared live owners, creation epochs, object types, restore timestamp boundaries, required-copy OR, and incremental destination reuse remain part of that selection contract. A GC filename is only a recovery watermark: `CopyGCDir` can advance it without scanning the new interval. `GCWindow` now persists one bounded actual scan interval in an optional second metadata block, committed with its remaining-object set. Only complete incremental scans grant proof. Merge preserves real contiguous coverage and keeps a proven suffix across gaps; rename, replay and GC filtering cannot manufacture coverage. Backup reads candidate metadata and streams one selected remaining set. Existing block zero and restore-watermark behavior remain unchanged; old readers consume block zero, and legacy metadata provides no absence proof. Malformed proof and incomplete checkpoint/GC reads fail closed. The obsolete `softDeletes` loader argument and collection path are removed. Checkpoint row-read errors now propagate through the loader and GC collector, preventing partial input from reaching successful publication. Design: [trusted GC scan evidence](https://github.com/LeftHandCold/matrixone/blob/578ff48a76f897dec56aecd97662b01b2efe1b30/docs/design/20261003-backup-gc-scan-proof.md), produced with gpt-6.1-sol / xhigh. Final overall review: gpt-6-astra / xhigh, PASS with no material blockers, bound to commit `578ff48a76f897dec56aecd97662b01b2efe1b30`. ### Validation macOS arm64, Go 1.26.4, branch-matched thirdparty artifacts and freshly built CGo: ```sh LC_ALL=C LANG=C GOMAXPROCS=4 .agents/skills/mo-dev/scripts/mo-cgo-test \ -p 2 -vet=all -count=1 -v -timeout=10m \ ./pkg/backup ./pkg/vm/engine/tae/logtail \ ./pkg/vm/engine/tae/db/gc/v3 ./pkg/datasync ``` All four packages and vet passed (15.280 / 1.009 / 0.823 / 16.822 seconds). Focused checks additionally cover: - Two actual backups, inherited GC metadata, historical checkpoint selection, and cache-disabled physical read returning `42`, for legacy and new metadata. - Real incremental and compacted producers, retained and genuinely reclaimed objects, owner/type/epoch sharing, timestamp boundaries and required missing files. - Real GC scan publication; row-read, metadata-write and cancellation failures; empty/nonempty metadata, gap merging, filtered checkpoint types, logical adjacency, invalid order and malformed proof. - Old block-zero reader behavior and partial checkpoint reads failing before `tae_list`/`tae_sum` publication. Small fixtures are shared; no service or large dataset is added. Historical exact-base/head evidence established the repeated-backup regression; current local checks establish the corrected behavior. Updated-head CI is pending. ### Cost and remaining limits Each GC window adds two timestamps; a trusted metadata rewrite adds one tiny block. Backup inspects candidate metadata and retains the existing selected-set and lifecycle maps. There is no new worker, cache, scheduler or snapshot policy, and no measured throughput claim. Legacy or gapped evidence remains conservative: an already missing old object can still cause backup failure when no trustworthy scan covers it. The change does not repair an incomplete backup already published. An old-version rewrite may discard the proof, making re-upgrade conservative; rolling back does not fix that old binary's unsafe selector. Customer-cluster full backup/restore and current/historical read acceptance have not been run. --------- Co-authored-by: mergify[bot] <37929162+mergify[bot]@users.noreply.github.com> Co-authored-by: XuPeng-SH <[email protected]> (cherry picked from commit 6d4569b)
…atrixorigin#30744) ## What type of PR is this? - [ ] API-change - [x] BUG - [ ] Improvement - [ ] Documentation - [ ] Feature - [x] Test and CI - [ ] Code Refactoring ## Which issue(s) this PR fixes: issue matrixorigin#30738 ## What this PR does / why we need it: Backport the physical-backup table-ID history repair to `4.2-dev`. The special backup checkpoint currently loses its predecessor's history index, and copying the checkpoint directory does not copy the root-level index objects. Consequently, a fresh physical restore can fail an immediate GCKP's normal 24-hour history check despite a complete source history. - Copy and checksum the exact predecessor's real index before bulk data copying; reuse identical destination bytes and reject mismatches without overwriting. - Merge through the rewritten special checkpoint, persist its index locations, and include index bytes, sizes and checksums in the archive manifest. - Correct GCKP versus ICKP successor-boundary handling. Preserve partial legacy empty-index behavior and repeated backup archives, without claiming coverage across indexed gaps. - Clean only newly generated, unambiguously unpublished index objects on pre-publication failure. - Assert ignored GCKP errors and add the separate-WAL backup/restore/GCKP/write/restart regression, durable 24-hour history and archive-file-list checks, plus failure/legacy cases. The `4.2-dev`-specific object-retention/GC-history implementation and its existing repeated-archive backup test are preserved, not replaced by the main implementation. The new component tests use `backup_table_id_history_test.go` to avoid replacing the branch's existing `backup_history_test.go`. No new disk-format column, shorter retention, fake coverage marker or relaxed GCKP guard. The backup checkpoint response stays five fields. Existing archives that already lack the required historical objects cannot be retroactively repaired by this patch and may still need actual history accumulation. Tested with (CPU, Darwin/arm64, Go 1.26.4; repository CGo wrapper): - Complete `pkg/backup` normal and race suites, including the unchanged `TestExecBackupPreservesHistoryAcrossInheritedGCWindow` and its second-archive backup. - Complete checkpoint/logtail normal and race suites. - Existing `TestGlobalCheckpointTableIDHistoryFallbackAndFailClosed`, normal/race and 36 consecutive exact race repetitions. - Separate-WAL restore regression verifies immediate GCKP, actual archived index/checksum entries, real history coverage, LSN `4 -> 0 -> 1`, post-restore writes and a second restart's complete row/value checks. - `gofmt` and `git diff --check`. These are engine/backup-library tests, not an external mo-backup-image or production-cluster validation. No production configuration, objects or cluster lifecycle was changed. (cherry picked from commit b7d2cc7)
Qodo reviews are paused for this user.Troubleshooting steps vary by plan Learn more → On a Teams plan? Using GitHub Enterprise Server, GitLab Self-Managed, or Bitbucket Data Center? |
|
This pull request does not currently match the merge queue conditions, so it cannot be queued from here. The box comes back if it matches again. |
|
mo-bot review · Commit: Review discussion changed before publication; a fresh contextual review is queued. |
XuPeng-SH
left a comment
There was a problem hiding this comment.
独立 deep review:969680122fdebccfacdb21b7c84f40b5204878b3,base/merge-base 3391c6844e95d1bb27a647b18f48f7c3a5ba1695。未使用 subagent。结论:APPROVE,本轮未发现合并阻断问题。
设计与范围:完整审查 17 个文件及真实备份入口、GC scan→持久化→replay→对象选择、历史索引复制→checkpoint 发布→独立 WAL 恢复→GCKP→再次写入和重启。两次 cherry-pick 的 stable patch ID 与 #29504/#30744 上游一致。修复复用 GCWindow 和 TableIDLocation,没有新增 snapshot/PITR 状态机或放宽历史完整性校验;已删除无消费者的 softDeletes 参数及收集分支。
历史评论:#29504 三条阻断意见均已实质闭环:non-appendable 创建/删除重复记录、snapshot/PITR 保留对象、GC 文件名水位不能充当扫描证明。三个线程均 resolved;#30744 和当前 PR 没有行级待解决线程。旧元数据缺乏证明时继续保守保留,源文件确实缺失仍失败。
| 失败路径审计 | 结果 |
|---|---|
| 资源与发布 | 新增 window/reader/batch 有清理归属;新索引仅在明确未发布时删除,发布结果不确定时保留。 |
| 错误与取消 | checkpoint/GC 读取、校验和、Stat/Read/Delete 错误向上传播;失败不发布完成清单,无新增锁、等待队列或重试层。 |
| 增长与性能 | 临时集合随备份输入增长并随调用释放;额外成本在备份及 GC 元数据路径,普通 SQL/TP 路径无新增逐行工作。 |
本轮本地验证:Darwin/arm64,Go 1.26.4,当前分支重新构建 native artifacts,仓库 CGo wrapper,非缓存执行:
- backup、logtail、GC v3、checkpoint、db、objectio、datasync 全包 normal +
-vet=all通过;前五包全包 race 通过。 - 独立 WAL 恢复→立即 GCKP→写入/删除→再重启回归额外 17 次 race 通过;GC 扫描证明发布/读错/写错/取消回归额外 100 次 race 通过。
- 独立 review-only overlay:72 小时历史窗口 + ICKP 备份边界的完整恢复链路,以及真实 incremental scan→window merge→GC 过滤→证明落盘/重读→备份选择→禁用缓存读取存活数据,两项 race 均通过。
TestGlobalCheckpointTableIDHistoryFallbackAndFailClosedrace 通过:真实历史缺口仍拒绝,失败重试不积累未引用对象。- 7 个变更所属包的增量 golangci-lint:
0 issues;匹配 Go 版本的 gofmt、diff 检查通过。原始日志和临时挑战保留在本地/tmp/pr31886-review-evidence,没有加入提交。
分别审视增量:实现 +552/-80、测试 +1648/-2、设计文档 +71。测试覆盖持久化与真实恢复、历史引用和小型故障注入,复杂度有明确正确性收益;没有通过大数据或 sleep 制造覆盖。
边界:不修复旧归档中已经缺失的文件/历史,不保证 legacy 扫描证据缺失时备份一定成功。未跑外部 mo-backup 镜像、客户规模恢复或大规模性能基准,不能据此承诺零开销。本次本地验证不替代远端发布门禁。
|
mo-bot review · Commit: Review belongs to an older commit; it is not a review of the current head. |
|
Hotfix 复审结论:代码审查 PASS,未发现本次 backport 新增的阻断项。 审查绑定 HEAD 范围、设计与正确性完整阅读 17 个变更文件,并追踪备份入口、checkpoint loader/重写、GC scan/merge/replay、历史索引生成、元数据发布与恢复端消费者。
验证复核并复用同一 clean HEAD、同一原生构建工作树的已有终态日志:7 个相关包 normal/vet 通过,5 个包 race 通过;独立 WAL restore 回归 19 次 race、历史缺口 fail-closed 回归 36 次 race 均通过。没有把 MongoDB CI 或待完成的机器人 review 当作 backup 验收。 本轮另在相同 HEAD 独立补跑下列 3 个顶层测试(含子场景),全部通过,包执行 1.882s: LC_ALL=C LANG=C GOMAXPROCS=2 GOGC=50 GOMEMLIMIT=2GiB \
.agents/skills/mo-dev/scripts/mo-cgo-test -p 1 -vet=all -count=1 \
-json -timeout=120s \
-run '^(TestCopyBackupTableIDHistory|TestExecBackupPreservesHistoryAcrossInheritedGCWindow|TestBackupRestoreGlobalCheckpointWithFreshWAL)$' \
./pkg/backup环境:Darwin/arm64、Go 1.26.4、分支匹配的 native artifacts;完整日志 发布必须明确的边界
Incidental bug findings(非本 PR 新增)
|
e0e2308
into
matrixorigin:release/v4.2.1-hotfix-20261026
What type of PR is this?
Which issue(s) this PR fixes:
Related to #28473 and #30738 on
release/v4.2.1-hotfix-20261026.Backports #29504 and #30744. This PR does not claim to recover previously missing source objects or repair already incomplete backup archives.
What this PR does / why we need it:
Cherry-pick the two final, merged
4.2-devfixes onto the hotfix base3391c6844e95d1bb27a647b18f48f7c3a5ba1695, preserving them as separate commits:6d4569bce66acb67e6d0fe746ee537da7955bffd2bf7df8892748f7ff8fe160641b52a7acaa70d9eb7d2cc7b5644641da580dd5650a02211167a781d969680122fdebccfacdb21b7c84f40b5204878b3Both cherry-picks are conflict-free and their stable patch IDs match upstream. No unrelated
4.2-devcommits, hotfix-specific production changes, retention-policy changes or weakened GCKP checks are included.Backup object selection
CopyGCDir.Restore history
Validation
Performed on the combined hotfix head, Darwin/arm64 CPU, Go 1.26.4, with freshly built branch-matched native artifacts and the repository CGo wrapper:
-vet=all:pkg/backup,pkg/vm/engine/tae/logtail,pkg/vm/engine/tae/db/gc/v3,pkg/vm/engine/tae/db/checkpoint,pkg/vm/engine/tae/db,pkg/objectio, andpkg/datasync: PASS.TestBackupRestoreGlobalCheckpointWithFreshWAL: normal/race PASS, plus 19 consecutive race repetitions PASS. This exercises a separate restored WAL, immediate GCKP, durable 24-hour history coverage, archived checksums, LSN4 -> 0 -> 1, post-restore writes and complete row/value checks after another restart.TestGlobalCheckpointTableIDHistoryFallbackAndFailClosed: normal/race PASS, plus 36 consecutive race repetitions PASS. Missing history still rejects GCKP, and repeated rejected attempts do not accumulate unreachable objects.gofmtandgit diff --check: PASS.These are real engine/file-service integration and component tests, not an external mo-backup image, production-scale performance or production restore acceptance. No production environment was changed.
Rollout boundaries