mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2025-09-23 17:13:36 +08:00
fix when two consecutive chunks with the same modified_ts_ns
fix https://github.com/seaweedfs/seaweedfs/issues/5276
This commit is contained in:
@@ -38,10 +38,10 @@ func readResolvedChunks(chunks []*filer_pb.FileChunk, startOffset int64, stopOff
|
|||||||
return int(a.ts - b.ts)
|
return int(a.ts - b.ts)
|
||||||
}
|
}
|
||||||
if a.isStart {
|
if a.isStart {
|
||||||
return -1
|
return 1
|
||||||
}
|
}
|
||||||
if b.isStart {
|
if b.isStart {
|
||||||
return 1
|
return -1
|
||||||
}
|
}
|
||||||
return 0
|
return 0
|
||||||
})
|
})
|
||||||
|
@@ -553,3 +553,18 @@ func TestViewFromVisibleIntervals3(t *testing.T) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestCompactFileChunks3(t *testing.T) {
|
||||||
|
chunks := []*filer_pb.FileChunk{
|
||||||
|
{Offset: 0, Size: 100, FileId: "abc", ModifiedTsNs: 50},
|
||||||
|
{Offset: 100, Size: 100, FileId: "ghi", ModifiedTsNs: 50},
|
||||||
|
{Offset: 200, Size: 100, FileId: "jkl", ModifiedTsNs: 100},
|
||||||
|
{Offset: 300, Size: 100, FileId: "def", ModifiedTsNs: 200},
|
||||||
|
}
|
||||||
|
|
||||||
|
compacted, _ := CompactFileChunks(nil, chunks)
|
||||||
|
|
||||||
|
if len(compacted) != 4 {
|
||||||
|
t.Fatalf("unexpected compacted: %d", len(compacted))
|
||||||
|
}
|
||||||
|
}
|
||||||
|
Reference in New Issue
Block a user