Skip to content

[Bug]: Backup fails with Error 20405 after restore: file restore-dev-.../data/... is not found #28473

Open

Description

@xzxiong

Is there an existing issue for the same bug?

  • I have checked the existing issues.

Related historical issues (similar 20405 file ... is not found):

Branch Name

main (mo-backup image: main-20260213-fix)

Commit ID

unknown (cluster image tag: registry.cn-hangzhou.aliyuncs.com/mocloud/mo-backup:main-20260213-fix, digest sha256:bb38ed10d2935fac0b68623c89087cf273415e7eea33eb8418bc363debf223b1)

Other Environment Information

- Cluster: freetier-01 (cn-dev)
- Namespace: freetier-01
- Host: freetier-01.cn-hangzhou.cluster.cn-dev.matrixone.tech:6001
- Backup Job/Pod: backup-260908-100944 / backup-260908-100944-7qg9x
- Backup tool: /mo_br backup
- Backup target: s3://moc-backup-dev/backup-260908-100944
- OSS endpoint: http://oss-cn-hangzhou-internal.aliyuncs.com (cn-hangzhou)
- User: dump?role=__MO_OB__
- Parallelism: 150
- Resources: cpu 2500m, memory request 4Gi / limit 10Gi

Actual Behavior

mo_br backup connects to MO successfully and finishes Preparation (including Aliyun OSS client setup), then fails in Backup From MO with:

Error 20405 (HY000): file restore-dev-20260213235245/data/01a07efd-5c71-76e3-86ff-10e8e4f867e9_00000 is not found

Pod exits with exitCode: 1, phase Failed.

Key timeline (UTC):

  • 2026-09-08 10:09:45 Connect MO / Test Connection / Preparation: success
  • 2026-09-08 10:10:14 Backup From MO: failed with 20405

Important detail:

  • The backup output filepath is backup-260908-100944/full-...
  • The missing file path is under an old restore prefix: restore-dev-20260213235245/data/...

This strongly suggests catalog/object metadata still references restore leftover object keys whose physical files are already gone (GC/cleanup/incomplete path rewrite after restore).

Relevant log excerpt:

===== Connect MO =====
Done!
===== Test Connection =====
Done!
===== Preparation =====
... new object storage {"Bucket":"moc-backup-dev", ...}
Done!
===== Backup From MO =====
ERROR backup/backup.go:94 do backup failed: Error 20405 (HY000): file restore-dev-20260213235245/data/01a07efd-5c71-76e3-86ff-10e8e4f867e9_00000 is not found
Error: Error 20405 (HY000): file restore-dev-20260213235245/data/01a07efd-5c71-76e3-86ff-10e8e4f867e9_00000 is not found

Expected Behavior

After restore, subsequent mo_br backup should succeed:

  1. Either all referenced data files remain readable, or
  2. Catalog/object metadata no longer references deleted restore-prefix files.

Backup should not fail because of stale restore-dev-... object keys.

Steps to Reproduce

1. Restore a cluster/data into an environment that uses (or previously used) a restore filepath prefix like `restore-dev-YYYYMMDDHHMMSS`.
2. Later run `mo_br backup` against the restored cluster, writing to a new S3 filepath (e.g. `backup-YYMMDD-HHMMSS`).
3. Observe backup fail in Backup From MO with:
   Error 20405 (HY000): file restore-dev-.../data/<uuid>_00000 is not found

Observed once on:

  • Job: backup-260908-100944
  • Pod: backup-260908-100944-7qg9x
  • Namespace: freetier-01

Additional information

Current analysis / suspected root cause:

  1. Not auth/connectivity/OSS credential failure (those stages succeeded).
  2. Failure happens while reading source files requested by MO metadata.
  3. Missing object is under historical restore prefix restore-dev-20260213235245, not the current backup target path.
  4. Likely metadata/object-lifecycle inconsistency after restore (stale object key retained after GC/cleanup, or restore did not fully rewrite object references).

Suggested investigation:

  1. Check whether object 01a07efd-5c71-76e3-86ff-10e8e4f867e9_00000 still exists under restore-dev-20260213235245/data/.
  2. Check why catalog/object meta still references that restore-prefix path after restore.
  3. Correlate with GC / cleanup around the 2026-02-13 restore.
  4. Confirm whether ordinary queries on the same cluster also hit intermittent 20405 for the same UUID.

Activity

  1. added
    kind/bug
    on Sep 9, 2026
  2. xzxiong commented on Sep 9, 2026

    @xzxiong
    ContributorAuthor
  3. added
    severity/s0
    and removed on Sep 9, 2026
  4. LeftHandCold commented on Sep 9, 2026

    @LeftHandCold
    Collaborator

    根因已收敛到 Backup 的 checkpoint 对象选择,GC 本身目前没有证据异常。

    • Checkpoint loader 会把带 committed DropTS 的对象导出到 BackupObject,同时记录到 softDeletes。
    • execBackup 之前对 special checkpoint 传入 nil,且即使后续收集到 softDeletes,也没有在构造 physical copy set 时使用它。因此“逻辑上已删除、物理文件已被正常 GC 收”的历史对象仍被送入 parallelCopyData。
    • fix(backup): fail on missing checkpoint objects #26290 之后,源端 404 会正确作为 20405 返回,使这条原有选择缺陷稳定暴露为备份失败。
    • Backup protection 在候选 checkpoint 构造完成后才生效;它会阻止之后的 GC,但既不能复活此前已删除的历史对象,也不能修正错误的 copy candidate。

    事故中旧 TN 已多次重启,缺少可关联的 DeleteObject 审计,故无法把该对象的实际删除者严格定为某一次 GC;但上述代码缺陷与删除者无关,并且能够解释“checkpoint 有 DropTS、源文件 404、backup 20405”的完整路径。

    已提交 main-only 修复 PR #28525:

    • 对所有 selected checkpoints(含 special checkpoint)收集 softDeletes;
    • 仅排除 checkpoint 已证明逻辑删除的对象,保留 checkpoint lifecycle metadata;
    • 不改变 GC、checkpoint 选择、backup protection 或非删除对象的 404 硬失败语义;
    • 回归测试用真实 checkpoint loader 构造 DropTS,删除源对象后验证旧路径返回 20405、新路径仅跳过该 deleted object;pkg/backup 全包与该用例 50 次重复均已通过。

    按当前决定不向 4.2 backport。

  5. LeftHandCold commented on Sep 9, 2026

    @LeftHandCold
    Collaborator

    补充修正:最初候选补丁把“checkpoint 中有 DropTS”直接作为跳过物理复制的条件,这在 special checkpoint 的 DropTS >= start 场景不安全。checkpoint rewrite 会将这类在恢复点仍可见的对象重新写为 live;若跳过文件会形成可完成但不可读的备份。

    PR #28525 已更新为按每个 BackupObject.DropTS 和 special checkpoint start 判定:仅 DropTS < start 的历史对象可跳过;DropTS == start、DropTS > start 均必须复制且仍保留 20405 缺文件硬错误。新增真实 checkpoint create=5/start=15/drop=30 的 copy -> rewrite -> live-reference + target-file 回归验证,并覆盖三个时间边界。

    因此当前修复不再依赖全局 soft-delete 名称集合;GC/protection 本身的结论不变:保护不能复活备份开始前已经被正常回收、且在恢复快照中已不可见的对象。

  6. added a commit that references this issue on Sep 9, 2026
    9475a9c
  7. added 3 commits that reference this issue on Sep 17, 2026
    2361c89
    279f8c5
    0f945b6
  8. MatrixAdventurer commented on Nov 1, 2026

    @MatrixAdventurer
    Contributor

    结论:部分修复(主线已修,4.2 线仅到 hotfix 分支)。证据:根因修复 #28525 已在本窗口前合入 main——备份校验遍历所有 selected checkpoints(含 special checkpoint)收集 softDeletes,跳过 DropTS<start 的逻辑删除对象,保留对真正缺失对象的 20405 硬错误语义(见本 issue 2026-09-09 评论及所附时间边界回归记录)。本窗口内引用本 issue 的合并 PR 仅 #31886:从 4.2-dev backport #29504/#30744 至 release/v4.2.1-hotfix-20261026(hotfix 分支,非主线,不计入核实),描述列本 issue 为 Related 且自述不恢复已缺失的历史对象。还缺:修复向 4.2 正式分支的 backport(此前决定不 backport,如口径已变请更新),以及事故集群备份在新版本上重跑通过的记录。
    本操作由LW授权的MOI智能体提交

  9. xzxiong commented on Nov 5, 2026

    @xzxiong
    ContributorAuthor

    分析结果:prod freetier-01 全量备份复现同一 20405,请求确认 4.2 backport 口径

    关联:本 issue 根因修复 #28525 仅合入 main(commit 9475a9c2),未 backport 到 4.2 线。prod 当前镜像 4.2.1-hotfix-20261030 不含该修复,daily 全量备份正持续命中。

    现象

    prod freetier-01 全量备份在 Backup From MO 阶段失败,报错与本 issue 完全同族(live data 前缀,非 restore 前缀):

    Error 20405 (HY000): file mo-20231112/data/01a14049-4f10-7969-a5b3-86d6e76ab6ad_00000 is not found
    

    环境信息

    • 集群:prod ACK unit(kubeconfig ack-prod-unit-hz),namespace freetier-01
    • MO 版本:CN/DN matrixone:4.2.1-hotfix-20261030,log v4.2.1-d2393868a-2026-08-28
    • 单 DN:default-dn-0
    • mo_br 镜像:mo-backup:main-20260213-fix,/mo_br backup,--parallelism=150
    • 备份目标:s3://mo-backup-20240201/backup-<ts>/full-...(OSS cn-hangzhou)

    诊断发现(失败时间线,UTC)

    自 2026-10-29 起反复失败,每次缺失的是不同的 data 文件 UUID,与 GC/merge 活动相关:

    Job 结果 缺失文件
    backup-261029-032805 ❌ 01a184b5-..._00000
    backup-manual-incremental-261029-044713 ❌ 01a1856d-..._00000
    backup-261030-032749 ❌ (同族)
    backup-261031~261103 ✅ 成功 —
    backup-261104-032452 ❌ (同族)
    backup-261104-102651 ❌ 01a14049-4f10-7969-a5b3-86d6e76ab6ad_00000

    成功耗时从 10-2510-28 的 46min 上升到近期 5~9min 且间歇失败。DN merge scheduler 持续活跃(merge/scheduler.go GatherStats/L0Gather 高频),失败窗口与 GC 回收时间吻合。

    代码分析

    与 #28473 / #28525 收敛的根因一致:

    • 失败发生在 parallelCopyData 阶段,源端对象 404 自 fix(backup): fail on missing checkpoint objects #26290 起正确映射为 20405。
    • 缺失对象带有 committed DropTS < start(逻辑已删、物理已被 GC 正常回收),但 4.2 线缺少 fix(backup): skip soft-deleted checkpoint objects #28525 的「按 BackupObject.DropTS 与 special checkpoint start 判定、仅跳过 DropTS < start」的选择修正,仍被送入 copy candidate。
    • Backup protection 只阻止备份开始后的 GC,无法复活备份前已回收的历史对象。

    已验证:git branch -r --contains 9475a9c2 仅命中 main 与若干 feature 分支,无任何 4.2.x 分支。4.2 线仅有 #29504「preserve historical objects」(保留而非跳过),不含对已 GC 软删对象的跳过守卫。

    根因

    prod 4.2.1-hotfix-20261030 未包含 #28525。TAE GC 在备份窗口内/前正常回收带 DropTS 的历史对象,备份的 checkpoint 对象选择仍引用这些物理已删除的对象,源端 404 → 20405,备份失败。

    影响范围

    • prod freetier-01 daily 全量备份间歇失败,10-29 起已有 6 次失败(含 1 次 manual incremental)。
    • 同 4.2.1-hotfix 线的其它 prod MO 集群若有活跃 merge/GC + 长备份窗口,存在同类风险。

    建议方案

    1. 短期(止血):将备份调度到低 merge/GC 活动窗口,或临时调大 GC 保留时间,降低备份窗口内对象被回收概率;失败任务直接重试(不同 UUID,重试常可成功,见 10-31~11-03 连续成功)。
    2. 长期(根治):请确认 4.2 backport 口径——本 issue 2026-09-09 评论决定「不向 4.2 backport」,但 prod 已在 4.2 线稳定复现同一根因。建议将 fix(backup): skip soft-deleted checkpoint objects #28525 backport 到 4.2 正式分支(prod 当前基线 4.2.1-hotfix),并在 prod 升级后重跑 daily 备份验证。

    备注

    可按需补充 prod 失败 pod 完整日志 / job yaml(与 2026-09-09 附件同格式)。本评论证据取自 prod ack-prod-unit-hz 实时诊断。

  10. xzxiong commented on Nov 5, 2026

    @xzxiong
    Author
  11. xzxiong commented on Nov 5, 2026

    @xzxiong
    ContributorAuthor

    更正 + 更新分析:prod 版本已含修复,失败机制需重新定位

    先更正前面两条评论的错误结论:prod 镜像 4.2.1-hotfix-20261030 基于 release/v4.2.1-hotfix-20261026 之后的构建,其 pkg/backup/tae.go 已包含 selectBackupObjects 的 DropTS 跳过逻辑(#28525/#29504 系修复已进入 4.2.1-hotfix 线)。此前"修复未 backport 到 4.2"的判断有误(用了 git branch --contains <main SHA> 验证,cherry-pick 后 SHA 变化导致漏判),向各位致歉。

    但 prod 仍在带修复的版本上失败,机制如下

    4.2.1-hotfix 的跳过是带条件的(pkg/backup/tae.go selectBackupObjects,约 :866-871):

    if !restoreTS.IsEmpty() && !dropTS.IsEmpty() && dropTS.LT(&restoreTS) &&
        retention != nil && !retention.end.IsEmpty() &&
        oName.CrateTS.GT(&retention.start) && dropTS.LE(&retention.end) {
        if _, retained := retention.retained[...]; !retained {
            continue   // 只有全部条件满足才跳过
        }
    }

    即跳过需同时满足:dropTS < start、落在 retention 窗口内(CrateTS > retention.start && dropTS <= retention.end)、且不在 retained 集合。而 retained 集合由 loadBackupObjectRetention(:576-667)构建,来源是当前仍存在的 checkpoint/GC 文件。

    由此推出一条仍然可行的失败路径:

    1. 对象带 committed DropTS < start,且其物理文件已被 GC 删除;
    2. 引用该对象的旧 checkpoint/GC meta 文件也被 GC 一并清掉 → retained 集合里没有它,或它已落在 retention 窗口之外(CrateTS <= retention.start);
    3. → 不满足跳过条件,NeedCopy=true 进入 parallelCopyData;
    4. → 源端 S3 404 → ErrFileNotFound 20405 → 整个备份失败。

    这解释了 prod 的现象:间歇性失败、每次缺失不同 UUID(取决于 GC 清理进度与备份枚举的相对时序)。

    仍然成立的 aggravator

    失败 job backup-261104-102651 耗时 ~40min,超过 GC backup-protection 的 20min TTL(gc/v3/checkpoint.go:1761)。protection 过期后 GC 恢复删除,进一步放大上述窗口。

    需要进一步确认的点(麻烦 @LeftHandCold)

    1. 缺失对象 01a14049-4f10-7969-a5b3-86d6e76ab6ad_00000 的 DropTS/CrateTS 与当时 retention.start/end 的关系(需要其 checkpoint 记录);若它确实落在窗口外/不在 retained,则上述路径坐实。
    2. 对"逻辑已删但不在 retained/超出窗口"的对象,copy 时 404 是否应降级为 skip+告警而非整个备份失败?目前语义是硬失败,prod 长窗口下代价较高(40min 白跑)。
    3. 备份耗时 > 20min protection TTL 是否需要调大 TTL 或支持续期。

    prod 现场信息(不变)

    • 集群:prod freetier-01(ack-prod-unit-hz),MO 4.2.1-hotfix-20261030,mo_br main-20260213-fix
    • 自 2026-10-29 起 6 次失败:Error 20405: file mo-20231112/data/<uuid>_00000 is not found(每次 UUID 不同)
    • 失败耗时 34s40min 不等,成功任务 59min
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugseverity/s0

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions