Skip to content

[Bug]: CopyGCDir records GC metadata size for copied data objects #25938

Closed

Description

@Ariznawlll

Is there an existing issue for the same bug?

  • I searched the existing open issues.

MatrixOne version

main@7f9ef5de9bb9337d8db0a9b15c44cba3b2838aa2

What happened?

backup.CopyGCDir records the GC metadata file's size for every data object referenced by that metadata file, instead of recording the copied object's actual size.

In a focused test, the copied object is 257 bytes and the GC metadata file is 506 bytes. The returned taeFile entry for the object reports 506 bytes.

These entries are serialized into tae_list, and their sizes are summed into tae_sum. Therefore both the per-object backup manifest and the aggregate backup size are incorrect. Backup/restore tooling that relies on the manifest size can also make incorrect validation or reporting decisions.

What did you expect to happen?

Each copied GC-referenced object should have its own actual file size recorded in the backup manifest.

How can we reproduce it?

  1. Create source and destination in-memory file services.
  2. Write one 257-byte object to the source file service.
  3. Write a valid GC metadata file that references the object. The resulting metadata file is 506 bytes.
  4. Call CopyGCDir.
  5. Find the returned taeFile entry for the copied object and compare its size with srcFs.StatFile(objectName).Size.

Actual result: the object entry reports 506, not 257.

Root cause

The object-entry construction in pkg/backup/tae.go uses the directory entry indexed by the GC metadata file:

filesList = append(filesList, &taeFile{
    path: object.ObjectName().String(),
    size: files[metaFile.GetIdx()].Size,
    // ...
})

files[metaFile.GetIdx()] is the GC metadata file, not the referenced data object.

Additional information

A focused white-box test reproduces the issue deterministically 3/3 times. Detailed commands and results are provided in a follow-up comment.

Activity

  1. added this to the MO-202607 milestone on Jul 21, 2026
  2. Ariznawlll commented on Jul 21, 2026

    @Ariznawlll
    CollaboratorAuthor

    最新 main 白盒验证

    • 测试基线:main@7f9ef5de9bb9337d8db0a9b15c44cba3b2838aa2
    • 测试位置:pkg/backup/gc_meta_inherit_audit_test.go
    • 测试用例:TestAuditCopyGCDirRecordsCopiedObjectSize
    • 被测函数:backup.CopyGCDir

    执行了什么

    1. 使用两个 MemoryFS 分别作为源和备份目标。
    2. 在源文件服务中写入一个真实的 257 字节对象。
    3. 使用 objectio.NewObjectWriterSpecial(objectio.WriterGC, ...) 写入一份真实 GC 元数据,并让它引用该对象;生成的 GC 元数据文件大小为 506 字节。
    4. 调用真实的 CopyGCDir 完成对象和元数据复制。
    5. 从返回的 []*taeFile 中定位该对象,断言其 size 等于 srcFS.StatFile(objectName).Size。
    6. 夹具额外断言对象大小与元数据大小不同,避免测试因为两者恰好相等而失效。

    执行命令

    go test ./pkg/backup \
      -run '^TestAuditCopyGCDirRecordsCopiedObjectSize$' \
      -count=3 -v

    测试结果

    FAIL,连续 3 次均稳定复现(3/3)。 每次结果一致:

    expected: 257
    actual  : 506
    Messages: the backup manifest must record the copied object's size, not the GC metadata size
    

    结论

    确认是 bug。对象内容实际已经复制,但 CopyGCDir 把 GC 元数据文件的 506 字节错误写成该对象的大小。该字段随后进入 tae_list,并参与 tae_sum 汇总,所以对象级清单和总大小都会错误。本次没有观察到对象内容损坏,因此结论仅限定在清单/统计及其消费方。

  3. added
    kind/bug
    on Jul 21, 2026
  4. added theissue type on Jul 21, 2026
  5. added
    severity/s0
    and removed on Jul 21, 2026
  6. LeftHandCold commented on Jul 22, 2026

    @LeftHandCold
    Collaborator

    fixed

  7. Ariznawlll commented on Jul 22, 2026

    @Ariznawlll
    CollaboratorAuthor

    已在最新 main 分支完成复验,CopyGCDir 记录错误对象大小的问题已修复。

    测试版本

    测试过程

    执行正式回归用例 TestCopyGCDirRecordsCopiedObjectSizeInManifests:

    1. 使用 MemoryFS 创建源和目标文件服务;
    2. 在源文件服务写入一个真实数据对象;
    3. 写入一份真实 GC metadata,并让它引用该对象;
    4. 保证数据对象大小和 GC metadata 文件大小不同,防止夹具误通过;
    5. 调用真实 CopyGCDir;
    6. 检查返回的 taeFile 条目以及生成的 manifest 汇总;
    7. 断言对象条目使用被复制对象的真实 StatFile.Size,而不是 GC metadata 的大小。

    执行命令:

    go test ./pkg/backup \
      -run '^TestCopyGCDirRecordsCopiedObjectSizeInManifests$' \
      -count=20 -v
    
    go test -race ./pkg/backup \
      -run '^TestCopyGCDirRecordsCopiedObjectSizeInManifests$' \
      -count=5

    实际结果

    • 普通模式:20/20 通过;
    • Race 模式:5/5 通过;
    • 返回的对象级 taeFile.size 与源对象真实大小一致;
    • manifest 中对象大小正确,汇总值不再按 GC metadata 大小重复累计;
    • 对象内容复制正常,Race detector 未报告数据竞争。

    测试结论

    CopyGCDir 已改为针对每个被引用对象读取并记录自身文件大小,tae_list 的对象级大小和相应汇总不再被 GC metadata 文件大小污染,原问题验证通过。

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

Projects

No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions