mirror of https://github.com/milvus-io/milvus.git
Check cluster serviceable before get GetSegmentInfos for distribution (#22317)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>pull/22329/head
parent
c2c8ddd432
commit
a0e1cc4da8
|
@ -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
|
||||
|
|
|
@ -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)
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue