mirror of https://github.com/milvus-io/milvus.git
Fix panic if channel not watched while getting shard leaders (#25820)
Signed-off-by: yah01 <yang.cen@zilliz.com>pull/25718/head
parent
f4e72cb170
commit
dc37b4587e
|
@ -894,6 +894,9 @@ func (s *Server) GetShardLeaders(ctx context.Context, req *querypb.GetShardLeade
|
|||
addrs := make([]string, 0, len(leaders))
|
||||
|
||||
var channelErr error
|
||||
if len(leaders) == 0 {
|
||||
channelErr = merr.WrapErrChannelLack("channel not subscribed")
|
||||
}
|
||||
|
||||
// In a replica, a shard is available, if and only if:
|
||||
// 1. The leader is online
|
||||
|
|
|
@ -1533,6 +1533,19 @@ func (suite *ServiceSuite) TestGetShardLeadersFailed() {
|
|||
suite.Equal(commonpb.ErrorCode_NoReplicaAvailable, resp.GetStatus().GetErrorCode())
|
||||
}
|
||||
|
||||
// channel not subscribed
|
||||
for _, node := range suite.nodes {
|
||||
suite.dist.LeaderViewManager.Update(node)
|
||||
}
|
||||
for _, collection := range suite.collections {
|
||||
req := &querypb.GetShardLeadersRequest{
|
||||
CollectionID: collection,
|
||||
}
|
||||
resp, err := server.GetShardLeaders(ctx, req)
|
||||
suite.NoError(err)
|
||||
suite.ErrorIs(merr.Error(resp.GetStatus()), merr.ErrChannelNotAvailable)
|
||||
}
|
||||
|
||||
// collection not loaded
|
||||
req := &querypb.GetShardLeadersRequest{
|
||||
CollectionID: -1,
|
||||
|
|
Loading…
Reference in New Issue