未验证 提交 db6ecd58 编写于 作者: S sunby 提交者: GitHub

Fix UpdateFlushSegmentsInfo bug (#11407)

issue: #7313
Signed-off-by: Nsunby <sunbingyi1992@gmail.com>
上级 a5e6b31c
......@@ -308,15 +308,13 @@ func (m *meta) UpdateFlushSegmentsInfo(segmentID UniqueID, flushed bool,
modSegments[cp.GetSegmentID()] = s
}
for id := range modSegments {
if segment := m.segments.GetSegment(id); segment != nil {
segBytes, err := proto.Marshal(segment.SegmentInfo)
if err != nil {
return fmt.Errorf("DataCoord UpdateFlushSegmentsInfo segmentID:%d, marshal failed:%w", segment.GetID(), err)
}
key := buildSegmentPath(segment.GetCollectionID(), segment.GetPartitionID(), segment.GetID())
kv[key] = string(segBytes)
for _, segment := range modSegments {
segBytes, err := proto.Marshal(segment.SegmentInfo)
if err != nil {
return fmt.Errorf("DataCoord UpdateFlushSegmentsInfo segmentID:%d, marshal failed:%w", segment.GetID(), err)
}
key := buildSegmentPath(segment.GetCollectionID(), segment.GetPartitionID(), segment.GetID())
kv[key] = string(segBytes)
}
if len(kv) == 0 {
......
......@@ -255,7 +255,7 @@ func TestUpdateFlushSegmentsInfo(t *testing.T) {
Statslogs: []*datapb.FieldBinlog{{FieldID: 1, Binlogs: []string{"statslog0", "statslog1"}}},
Deltalogs: []*datapb.DeltaLogInfo{{RecordEntries: 1, TimestampFrom: 100, TimestampTo: 200, DeltaLogSize: 1000}},
}}
assert.EqualValues(t, expected, updated)
assert.True(t, proto.Equal(expected, updated))
})
t.Run("update non-existed segment", func(t *testing.T) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册