Check cluster serviceable before get GetSegmentInfos for distribution (#22317)

Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
pull/22329/head
congqixia 2023-02-22 10:16:28 +08:00 committed by GitHub
parent c2c8ddd432
commit a0e1cc4da8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 1 deletions

View File

@ -863,7 +863,14 @@ func (sc *ShardCluster) Query(ctx context.Context, req *querypb.QueryRequest, wi
}
func (sc *ShardCluster) GetSegmentInfos() []SegmentEntry {
items, version := sc.distribution.GetCurrent()
sc.mutVersion.RLock()
distribution := sc.distribution
sc.mutVersion.RUnlock()
// before setup version
if distribution == nil {
return nil
}
items, version := distribution.GetCurrent()
sc.finishUsage(version)
var result []SegmentEntry

View File

@ -2128,3 +2128,15 @@ func (suite *ShardClusterSuite) TestReleaseSegments() {
func TestShardClusterSuite(t *testing.T) {
suite.Run(t, new(ShardClusterSuite))
}
// ut for https://github.com/milvus-io/milvus/issues/22312
func TestGetSegmentInfoBeforeSetup(t *testing.T) {
sc := NewShardCluster(100, 1000, "testChannel", 0,
&mockNodeDetector{}, &mockSegmentDetector{}, buildMockQueryNode)
assert.NotPanics(t, func() {
result := sc.GetSegmentInfos()
assert.Nil(t, result)
})
}