You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[Bug]: backup global file index selects an older timestamp lexicographically #25937
backup.LoadGlobalFileIndex can select an older global file index when the physical timestamp components have different decimal widths.
For example, when both files exist:
file_index_0-9.idx
file_index_0-10.idx
the loader selects file_index_0-9.idx, although 0-10 is newer than 0-9.
The selected index is used by incremental backup to decide whether an object was already backed up. Loading a stale index causes objects recorded only in the newer index to be copied again, defeating cross-backup deduplication and increasing backup size and duration.
What did you expect to happen?
The loader should compare MatrixOne timestamps numerically and load file_index_0-10.idx.
How can we reproduce it?
Create an in-memory file service.
Write file_index_0-9.idx containing only old-only.obj.
Write file_index_0-10.idx containing only new-only.obj.
Call LoadGlobalFileIndex.
Check which entry is loaded.
Actual result: the returned index contains old-only.obj and does not contain new-only.obj.
Root cause
pkg/backup/file_index.go extracts the timestamp as a string and chooses the maximum using lexicographic comparison:
Lexicographically, "0-9" > "0-10", which is the opposite of the numeric timestamp order.
Additional information
A focused white-box regression test reproduces the issue deterministically 3/3 times. Detailed commands and results are provided in a follow-up comment.
go test ./pkg/backup \
-run '^(TestLoadGlobalFileIndex_OrdersTimestampNumerically|TestLoadGlobalFileIndex_IgnoresInvalidTimestampNames|TestLoadGlobalFileIndex_InvalidTimestampDoesNotMaskValidIndex)$' \
-count=20 -v
go test -race ./pkg/backup \
-run '^(TestLoadGlobalFileIndex_OrdersTimestampNumerically|TestLoadGlobalFileIndex_IgnoresInvalidTimestampNames|TestLoadGlobalFileIndex_InvalidTimestampDoesNotMaskValidIndex)$' \
-count=5
实际结果
三组正式回归普通模式各运行 20 次,全部通过;
Race 模式各运行 5 次,全部通过;
0-10 能正确覆盖 0-9;
10-0 能正确覆盖 9-0;
非法时间戳文件名被忽略,且不会影响合法最新索引选择;
Race detector 未报告数据竞争。
测试结论
LoadGlobalFileIndex 已解析并按 timestamp 的 physical/logical 数值字段排序,不再依赖字符串字典序。增量备份会加载真正最新的 global index,原问题验证通过。
Activity
Ariznawlll commentedon Jul 21, 2026
最新 main 白盒验证
main@7f9ef5de9bb9337d8db0a9b15c44cba3b2838aa2pkg/backup/file_index_order_audit_test.gobackup.LoadGlobalFileIndex执行的测试用例
fileservice.NewMemoryFS创建内存文件服务。file_index_0-9.idx,内容只包含old-only.obj。file_index_0-10.idx,内容只包含new-only.obj。LoadGlobalFileIndex,不 mock 索引选择逻辑。new-only.obj,且不包含old-only.obj。执行命令
测试结果
FAIL,连续 3 次均稳定复现(3/3)。 每一次日志都显示:
实际加载了旧索引
file_index_0-9.idx,因此new-only.obj不在返回索引中。结论
确认是 bug。文件名中的时间戳使用字符串比较,位数变化时顺序错误;该旧索引随后参与增量备份的
globalIndex.Has(objName)去重判断,导致新索引已记录的对象被重复复制,增加备份空间和耗时。本次验证未观察到数据丢失,因此不扩大结论。fix(backup): select file indexes by numeric timestamp (#25970)
LeftHandCold commentedon Jul 22, 2026
fixed
Ariznawlll commentedon Jul 22, 2026
已在最新
main分支完成复验,global file index 已按 MatrixOne timestamp 数值顺序选择。测试版本
mainc0486a2446c84c6dd6bf142494fe85243877ddc5测试过程
执行以下正式回归:
TestLoadGlobalFileIndex_OrdersTimestampNumericallyTestLoadGlobalFileIndex_IgnoresInvalidTimestampNamesTestLoadGlobalFileIndex_InvalidTimestampDoesNotMaskValidIndex覆盖内容:
file_index_0-9.idx和file_index_0-10.idx,断言选择数值更新的0-10;10-0新于9-0;执行命令:
实际结果
0-10能正确覆盖0-9;10-0能正确覆盖9-0;测试结论
LoadGlobalFileIndex已解析并按 timestamp 的 physical/logical 数值字段排序,不再依赖字符串字典序。增量备份会加载真正最新的 global index,原问题验证通过。fix(backup): select file indexes by numeric timestamp (matrixorigin#2…
fix(backup): select file indexes by numeric timestamp (matrixorigin#2…
fix(backup): select file indexes by numeric timestamp (matrixorigin#2…