未验证 提交 5c98329f 编写于 作者: C congqixia 提交者: GitHub

Return error when no replica available (#16886)

Signed-off-by: NCongqi Xia <congqi.xia@zilliz.com>
上级 000c5ff3
......@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册