fix: Report offline info in `GetDataDistribition` (#31347)

See also #31345

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/31363/head
congqixia 2024-03-18 14:51:04 +08:00 committed by GitHub
parent 26539a1b6d
commit 243e311515
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 19 additions and 1 deletions

View File

@ -236,10 +236,15 @@ func (d *distribution) AddOfflines(segmentIDs ...int64) {
updated := false
for _, segmentID := range segmentIDs {
_, ok := d.sealedSegments[segmentID]
entry, ok := d.sealedSegments[segmentID]
if !ok {
continue
}
// FIXME: remove offlie logic later
// mark segment distribution as offline, set verion to unreadable
entry.NodeID = wildcardNodeID
entry.Version = unreadableTargetVersion
d.sealedSegments[segmentID] = entry
updated = true
d.offlines.Insert(segmentID)
}

View File

@ -640,6 +640,7 @@ func (s *DistributionSuite) TestAddOfflines() {
SegmentID: 3,
},
},
offlines: []int64{4},
serviceable: true,
},
}
@ -652,6 +653,18 @@ func (s *DistributionSuite) TestAddOfflines() {
s.dist.AddDistributions(tc.input...)
s.dist.AddOfflines(tc.offlines...)
s.Equal(tc.serviceable, s.dist.Serviceable())
// current := s.dist.current.Load()
for _, offline := range tc.offlines {
// current.
s.dist.mut.RLock()
entry, ok := s.dist.sealedSegments[offline]
s.dist.mut.RUnlock()
if ok {
s.EqualValues(-1, entry.NodeID)
s.EqualValues(unreadableTargetVersion, entry.Version)
}
}
})
}
}