add missing intervals

fix https://github.com/chrislusf/seaweedfs/issues/774
This commit is contained in:
Chris Lu 2018-11-21 16:25:13 -08:00
parent c9b3ef58de
commit e5ad2223a1
2 changed files with 19 additions and 1 deletions

View file

@ -127,6 +127,7 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb
return append(visibles, newV) return append(visibles, newV)
} }
logPrintf(" before", visibles)
for _, v := range visibles { for _, v := range visibles {
if v.start < chunk.Offset && chunk.Offset < v.stop { if v.start < chunk.Offset && chunk.Offset < v.stop {
newVisibles = append(newVisibles, newVisibleInterval( newVisibles = append(newVisibles, newVisibleInterval(
@ -145,7 +146,7 @@ func mergeIntoVisibles(visibles, newVisibles []*visibleInterval, chunk *filer_pb
v.modifiedTime, v.modifiedTime,
)) ))
} }
if chunkStop < v.start || v.stop <= chunk.Offset { if chunkStop <= v.start || v.stop <= chunk.Offset {
newVisibles = append(newVisibles, v) newVisibles = append(newVisibles, v)
} }
} }

View file

@ -166,6 +166,23 @@ func TestIntervalMerging(t *testing.T) {
{start: 11534336, stop: 14376529, fileId: "7,0299ad723803"}, {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 { for i, testcase := range testcases {