Repository navigation
Description
Description
CopyGCDir uses the length of the original metaFiles slice when deciding whether the current entry is the last successfully copyable GC metadata file.
GC metadata whose referenced objects cannot be copied is intentionally omitted from copyFiles. Therefore copyFiles can be shorter than metaFiles. In that case the last entry in copyFiles does not satisfy i == len(metaFiles)-1, so its filename is not rewritten to inherit the checkpoint minimum timestamp.
Affected code
pkg/backup/tae.go:
for i, metaFile := range copyFiles {
name := metaFile.GetName()
if i == len(metaFiles)-1 {
if !min.IsEmpty() && metaFile.GetEnd().LT(&min) {
name = ioutil.InheritGCMetadataName(name, metaFile.GetEnd(), &min)
}
}
// copy metadata file using name
}The loop iterates over copyFiles, so the last-entry comparison must use the same filtered slice.
Tested version
- Branch:
main - Commit:
7f9ef5de9bb9337d8db0a9b15c44cba3b2838aa2 - The same code was verified directly in the current
mainraw source.
Reproduction
A focused white-box test uses real GC metadata files and the production CopyGCDir path:
- Write GC meta
gc_1-0_10-0.ckpreferencing an object that does not exist, so this meta is skipped. - Write GC meta
gc_11-0_20-0.ckpreferencing an object that exists, so this meta is copied successfully. - Call
CopyGCDirwith checkpoint minimum timestamp30-0. - Verify that the last successful meta is written as
gc_20-0_30-0.ckp.
Run:
go test ./pkg/backup -run '^TestAuditCopyGCDirInheritsLastSuccessfulMetaWatermark$' -count=3 -vActual behavior
All three runs fail. The destination contains only the original name:
[Backup] copy file ... failed
[]string{"gc_11-0_20-0.ckp"} does not contain "gc_20-0_30-0.ckp"
CopyGCDir returns no error, but the last successful GC metadata file keeps the stale end timestamp.
Expected behavior
After uncopyable metadata is filtered out, the last entry of copyFiles must inherit minTs when its end timestamp is lower than minTs.
Impact
The production comment explains that restore relies on the last GC metadata filename to raise the GC watermark when GC consumption lags behind the checkpoint. Under a partial/meta-object-missing backup, the stale filename can leave the restored GC state unable to find the required checkpoint.
Root cause
The loop iterates over the filtered copyFiles slice but compares its index against len(metaFiles)-1, which refers to the pre-filter slice.
Activity
Ariznawlll commentedon Jul 21, 2026
最新 main 白盒验证
main@7f9ef5de9bb9337d8db0a9b15c44cba3b2838aa2pkg/backup.CopyGCDir的 GC meta 部分失败过滤与恢复水位文件名继承,不涉及 txn/2PC。minTs。测试过程/用例
测试
TestAuditCopyGCDirInheritsLastSuccessfulMetaWatermark使用真实生产格式和 MemoryFS:objectio.NewObjectWriterSpecial(WriterGC, ...)写入第一份真实 GC meta:gc_1-0_10-0.ckp;CopyGCDir会记录复制失败并过滤该 meta;gc_11-0_20-0.ckp,并在源 FS 写入它引用的对象,使该 meta 可以完整复制;CopyGCDir(ctx, srcFS, dstFS, "gc", emptyBackupTS, minTS=30-0);gc_20-0_30-0.ckp。执行命令
实际结果
FAIL 3/3,稳定复现。 每次第一份 meta 都按预期因对象缺失被过滤,但第二份保留了旧文件名:
根因对照
过滤后:
metaFiles长度为 2;copyFiles长度为 1;copyFiles,最后一个元素下标为 0;i == len(metaFiles)-1,即0 == 1,条件不成立。因此
InheritGCMetadataName(lastMeta, end=20-0, min=30-0)永远没有执行。结论
确认是 backup/restore GC 元数据水位处理的确定性 bug;最新 main 3/3 稳定复现,不是文件服务或时序抖动。
fix(backup): preserve GC metadata watermarks and sizes (#25972)
LeftHandCold commentedon Jul 22, 2026
fixed
Ariznawlll commentedon Jul 22, 2026
已在最新
main分支完成复验,GC metadata 过滤后的 watermark 继承问题已修复。测试版本
mainc0486a2446c84c6dd6bf142494fe85243877ddc5测试过程
执行正式回归用例
TestCopyGCDirInheritsLastCopiedMetadataWatermark:CopyGCDir尝试复制时,该 metadata 因引用对象缺失而被过滤;minTs设置为高于第二份 metadata 的 end timestamp;CopyGCDir;copyFiles中最后一个成功 metadata 被重命名,并继承 checkpoint 最小水位。执行命令:
实际结果
minTs;测试结论
CopyGCDir已使用过滤后的copyFiles长度判断最后一个成功条目。即使前面的 GC metadata 无法复制,最终成功复制的 metadata 仍能正确抬升恢复所需的 GC watermark,原问题验证通过。fix(backup): preserve GC metadata watermarks and sizes (matrixorigin#…
fix(backup): preserve GC metadata watermarks and sizes (matrixorigin#…
fix(backup): preserve GC metadata watermarks and sizes (matrixorigin#…