mirror of https://github.com/milvus-io/milvus.git
Always add the shard leader into the nodes list of shard (#16616)
Signed-off-by: yah01 <yang.cen@zilliz.com>pull/16571/head
parent
04fffb08ef
commit
5c66300408
|
@ -1072,9 +1072,10 @@ func (qc *QueryCoord) GetReplicas(ctx context.Context, req *milvuspb.GetReplicas
|
|||
|
||||
for _, replica := range replicas {
|
||||
for _, shard := range replica.ShardReplicas {
|
||||
shard.NodeIds = append(shard.NodeIds, shard.LeaderID)
|
||||
nodes := shardNodes[shard.DmChannelName]
|
||||
for _, nodeID := range replica.NodeIds {
|
||||
if _, ok := nodes[nodeID]; ok {
|
||||
if _, ok := nodes[nodeID]; ok && nodeID != shard.LeaderID {
|
||||
shard.NodeIds = append(shard.NodeIds, nodeID)
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1477,9 +1477,12 @@ func TestGetReplicas(t *testing.T) {
|
|||
assert.Nil(t, err)
|
||||
node3, err := startQueryNodeServer(ctx)
|
||||
assert.Nil(t, err)
|
||||
node4, err := startQueryNodeServer(ctx)
|
||||
assert.Nil(t, err)
|
||||
waitQueryNodeOnline(queryCoord.cluster, node1.queryNodeID)
|
||||
waitQueryNodeOnline(queryCoord.cluster, node2.queryNodeID)
|
||||
waitQueryNodeOnline(queryCoord.cluster, node3.queryNodeID)
|
||||
waitQueryNodeOnline(queryCoord.cluster, node4.queryNodeID)
|
||||
|
||||
// First, load collection with replicas
|
||||
loadCollectionReq := &querypb.LoadCollectionRequest{
|
||||
|
@ -1505,7 +1508,6 @@ func TestGetReplicas(t *testing.T) {
|
|||
assert.Equal(t, commonpb.ErrorCode_Success, resp.Status.ErrorCode)
|
||||
assert.Equal(t, 3, len(resp.Replicas))
|
||||
for i := range resp.Replicas {
|
||||
assert.Equal(t, 1, len(resp.Replicas[i].NodeIds))
|
||||
for j := 0; j < i; j++ {
|
||||
assert.NotEqual(t,
|
||||
resp.Replicas[i].NodeIds[0],
|
||||
|
@ -1521,12 +1523,11 @@ func TestGetReplicas(t *testing.T) {
|
|||
sawNodes := make(map[UniqueID]struct{})
|
||||
for i, replica := range resp.Replicas {
|
||||
addNodes := make(map[UniqueID]struct{})
|
||||
assert.Equal(t, 1, len(replica.NodeIds))
|
||||
assert.Greater(t, len(replica.NodeIds), 0)
|
||||
assert.Greater(t, len(replica.ShardReplicas), 0)
|
||||
for _, shard := range replica.ShardReplicas {
|
||||
assert.Equal(t,
|
||||
replica.NodeIds[0],
|
||||
shard.NodeIds[0],
|
||||
shard.LeaderID)
|
||||
assert.Greater(t, len(shard.NodeIds), 0)
|
||||
|
||||
|
@ -1564,6 +1565,7 @@ func TestGetReplicas(t *testing.T) {
|
|||
node1.stop()
|
||||
node2.stop()
|
||||
node3.stop()
|
||||
node4.stop()
|
||||
queryCoord.Stop()
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue