mirror of https://github.com/milvus-io/milvus.git
Prevent datacoord from syncing unflushed segments (#19659)
See also: #19653 Signed-off-by: yangxuan <xuan.yang@zilliz.com> Signed-off-by: yangxuan <xuan.yang@zilliz.com>pull/19657/head
parent
3049dbb5a5
commit
2c92ce0c0e
|
@ -768,7 +768,8 @@ func (replica *SegmentReplica) mergeFlushedSegments(seg *Segment, planID UniqueI
|
|||
|
||||
var inValidSegments []UniqueID
|
||||
for _, ID := range compactedFrom {
|
||||
if !replica.hasSegment(ID, true) {
|
||||
// no such segments in replica or the segments are unflushed.
|
||||
if !replica.hasSegment(ID, true) || replica.hasSegment(ID, false) {
|
||||
inValidSegments = append(inValidSegments, ID)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -838,6 +838,11 @@ func TestSegmentReplica_InterfaceMethod(t *testing.T) {
|
|||
collectionID: 1,
|
||||
numRows: 15,
|
||||
}},
|
||||
{"segment exists but not flushed", false, false, []UniqueID{1, 4}, &Segment{
|
||||
segmentID: 3,
|
||||
collectionID: 1,
|
||||
numRows: 15,
|
||||
}},
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
|
@ -851,12 +856,23 @@ func TestSegmentReplica_InterfaceMethod(t *testing.T) {
|
|||
sr.addFlushedSegmentWithPKs(2, 1, 0, "channel", 10, primaryKeyData)
|
||||
}
|
||||
|
||||
if !sr.hasSegment(4, false) {
|
||||
sr.removeSegments(4)
|
||||
sr.addSegment(addSegmentReq{
|
||||
segType: datapb.SegmentType_Normal,
|
||||
segID: 4,
|
||||
collID: 1,
|
||||
partitionID: 0,
|
||||
})
|
||||
}
|
||||
|
||||
if sr.hasSegment(3, true) {
|
||||
sr.removeSegments(3)
|
||||
}
|
||||
|
||||
require.True(t, sr.hasSegment(1, true))
|
||||
require.True(t, sr.hasSegment(2, true))
|
||||
require.True(t, sr.hasSegment(4, false))
|
||||
require.False(t, sr.hasSegment(3, true))
|
||||
|
||||
// tests start
|
||||
|
|
Loading…
Reference in New Issue