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
XuanYang-cn 2022-10-10 11:33:21 +08:00 committed by GitHub
parent 3049dbb5a5
commit 2c92ce0c0e
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 1 deletions

View File

@ -768,7 +768,8 @@ func (replica *SegmentReplica) mergeFlushedSegments(seg *Segment, planID UniqueI
var inValidSegments []UniqueID var inValidSegments []UniqueID
for _, ID := range compactedFrom { 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) inValidSegments = append(inValidSegments, ID)
} }
} }

View File

@ -838,6 +838,11 @@ func TestSegmentReplica_InterfaceMethod(t *testing.T) {
collectionID: 1, collectionID: 1,
numRows: 15, numRows: 15,
}}, }},
{"segment exists but not flushed", false, false, []UniqueID{1, 4}, &Segment{
segmentID: 3,
collectionID: 1,
numRows: 15,
}},
} }
for _, test := range tests { for _, test := range tests {
@ -851,12 +856,23 @@ func TestSegmentReplica_InterfaceMethod(t *testing.T) {
sr.addFlushedSegmentWithPKs(2, 1, 0, "channel", 10, primaryKeyData) 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) { if sr.hasSegment(3, true) {
sr.removeSegments(3) sr.removeSegments(3)
} }
require.True(t, sr.hasSegment(1, true)) require.True(t, sr.hasSegment(1, true))
require.True(t, sr.hasSegment(2, true)) require.True(t, sr.hasSegment(2, true))
require.True(t, sr.hasSegment(4, false))
require.False(t, sr.hasSegment(3, true)) require.False(t, sr.hasSegment(3, true))
// tests start // tests start