Skip to content

SeaweedFS is a distributed storage system for object storage (S3), file systems, Iceberg table buckets, and Lance vector buckets, designed to handle billions of files with O(1) disk access and effortless horizontal scaling.

add missing intervals

Chris Lue5ad2223a154
diff --git a/weed/filer2/filechunks.go b/weed/filer2/filechunks.go
index 538d10afaa..3d540cc848 100644
--- a/weed/filer2/filechunks.go
+++ b/weed/filer2/filechunks.go
@@ -127,6 +127,7 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb
return append(visibles, newV)
}
+ logPrintf(" before", visibles)
for _, v := range visibles {
if v.start < chunk.Offset && chunk.Offset < v.stop {
newVisibles = append(newVisibles, newVisibleInterval(
@@ -145,7 +146,7 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb
v.modifiedTime,
))
}
- if chunkStop < v.start || v.stop <= chunk.Offset {
+ if chunkStop <= v.start || v.stop <= chunk.Offset {
newVisibles = append(newVisibles, v)
}
}
diff --git a/weed/filer2/filechunks_test.go b/weed/filer2/filechunks_test.go
index 12e495f32d..eadf4d27fb 100644
--- a/weed/filer2/filechunks_test.go
+++ b/weed/filer2/filechunks_test.go
@@ -166,6 +166,23 @@ func TestIntervalMerging(t *testing.T) {
{start: 11534336, stop: 14376529, fileId: "7,0299ad723803"},
},
},
+ // case 8: real bug
+ {
+ Chunks: []*filer_pb.FileChunk{
+ {Offset: 0, Size: 77824, FileId: "4,0b3df938e301", Mtime: 123},
+ {Offset: 471040, Size: 472225-471040, FileId: "6,0b3e0650019c", Mtime: 130},
+ {Offset: 77824, Size: 208896-77824, FileId: "4,0b3f0c7202f0", Mtime: 140},
+ {Offset: 208896, Size: 339968-208896, FileId: "2,0b4031a72689", Mtime: 150},
+ {Offset: 339968, Size: 471040-339968, FileId: "3,0b416a557362", Mtime: 160},
+ },
+ Expected: []*visibleInterval{
+ {start: 0, stop: 77824, fileId: "4,0b3df938e301"},
+ {start: 77824, stop: 208896, fileId: "4,0b3f0c7202f0"},
+ {start: 208896, stop: 339968, fileId: "2,0b4031a72689"},
+ {start: 339968, stop: 471040, fileId: "3,0b416a557362"},
+ {start: 471040, stop: 472225, fileId: "6,0b3e0650019c"},
+ },
+ },
}
for i, testcase := range testcases {