mirror of
https://gitee.com/milvus-io/milvus.git
synced 2024-11-30 02:48:45 +08:00
Return error when no replica available (#16886)
Signed-off-by: Congqi Xia <congqi.xia@zilliz.com>
This commit is contained in:
parent
000c5ff3de
commit
5c98329f7c
@ -1200,6 +1200,16 @@ func (qc *QueryCoord) GetShardLeaders(ctx context.Context, req *querypb.GetShard
|
||||
shardLeaderLists = append(shardLeaderLists, shard)
|
||||
}
|
||||
|
||||
// all replicas are not available
|
||||
if len(shardLeaderLists) == 0 {
|
||||
return &querypb.GetShardLeadersResponse{
|
||||
Status: &commonpb.Status{
|
||||
ErrorCode: commonpb.ErrorCode_UnexpectedError,
|
||||
Reason: "no replica available",
|
||||
},
|
||||
}, nil
|
||||
}
|
||||
|
||||
log.Info("GetShardLeaders finished",
|
||||
zap.String("role", typeutil.QueryCoordRole),
|
||||
zap.Int64("collectionID", req.CollectionID),
|
||||
|
@ -1683,6 +1683,14 @@ func TestGetShardLeaders(t *testing.T) {
|
||||
}
|
||||
assert.Equal(t, 0, totalLeaders%3)
|
||||
|
||||
// mock replica all down, without triggering load balance
|
||||
queryCoord.cluster.stopNode(node1.queryNodeID)
|
||||
queryCoord.cluster.stopNode(node2.queryNodeID)
|
||||
queryCoord.cluster.stopNode(node3.queryNodeID)
|
||||
resp, err = queryCoord.GetShardLeaders(ctx, getShardLeadersReq)
|
||||
assert.NoError(t, err)
|
||||
assert.Equal(t, commonpb.ErrorCode_UnexpectedError, resp.Status.ErrorCode)
|
||||
|
||||
// TODO(yah01): Disable the unit test case for now,
|
||||
// restore it after the rebalance between replicas feature is implemented
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user