mirror of https://github.com/milvus-io/milvus.git
Fix return too many nodeIDs (#23397)
See also: #23396 Signed-off-by: yangxuan <xuan.yang@zilliz.com>pull/23569/head
parent
4a6c2b78a7
commit
d56771b7b7
internal/querycoordv2
|
@ -311,10 +311,10 @@ func (s *Server) tryGetNodesMetrics(ctx context.Context, req *milvuspb.GetMetric
|
||||||
}
|
}
|
||||||
|
|
||||||
func (s *Server) fillReplicaInfo(replica *meta.Replica, withShardNodes bool) (*milvuspb.ReplicaInfo, error) {
|
func (s *Server) fillReplicaInfo(replica *meta.Replica, withShardNodes bool) (*milvuspb.ReplicaInfo, error) {
|
||||||
|
nodeIDs := typeutil.NewUniqueSet(replica.GetNodes()...)
|
||||||
info := &milvuspb.ReplicaInfo{
|
info := &milvuspb.ReplicaInfo{
|
||||||
ReplicaID: replica.GetID(),
|
ReplicaID: replica.GetID(),
|
||||||
CollectionID: replica.GetCollectionID(),
|
CollectionID: replica.GetCollectionID(),
|
||||||
NodeIds: replica.GetNodes(),
|
|
||||||
ResourceGroupName: replica.GetResourceGroup(),
|
ResourceGroupName: replica.GetResourceGroup(),
|
||||||
NumOutboundNode: s.meta.GetOutgoingNodeNumByReplica(replica),
|
NumOutboundNode: s.meta.GetOutgoingNodeNumByReplica(replica),
|
||||||
}
|
}
|
||||||
|
@ -355,7 +355,8 @@ func (s *Server) fillReplicaInfo(replica *meta.Replica, withShardNodes bool) (*m
|
||||||
}
|
}
|
||||||
return 0, false
|
return 0, false
|
||||||
})
|
})
|
||||||
shard.NodeIds = append(shard.NodeIds, shardNodes...)
|
nodeIDs.Insert(shardNodes...)
|
||||||
|
shard.NodeIds = nodeIDs.Collect()
|
||||||
}
|
}
|
||||||
info.ShardReplicas = append(info.ShardReplicas, shard)
|
info.ShardReplicas = append(info.ShardReplicas, shard)
|
||||||
}
|
}
|
||||||
|
|
|
@ -1373,6 +1373,15 @@ func (suite *ServiceSuite) TestGetReplicas() {
|
||||||
suite.NoError(err)
|
suite.NoError(err)
|
||||||
suite.Equal(commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
suite.Equal(commonpb.ErrorCode_Success, resp.GetStatus().GetErrorCode())
|
||||||
suite.EqualValues(suite.replicaNumber[collection], len(resp.Replicas))
|
suite.EqualValues(suite.replicaNumber[collection], len(resp.Replicas))
|
||||||
|
|
||||||
|
// Test no dup nodeIDs in shardReplica
|
||||||
|
for _, replica := range resp.GetReplicas() {
|
||||||
|
suite.Equal(collection, replica.CollectionID)
|
||||||
|
for _, shardReplica := range replica.GetShardReplicas() {
|
||||||
|
gotNodeIDsSet := typeutil.NewUniqueSet(shardReplica.GetNodeIds()...)
|
||||||
|
suite.Equal(len(shardReplica.GetNodeIds()), gotNodeIDsSet.Len())
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Test when server is not healthy
|
// Test when server is not healthy
|
||||||
|
|
Loading…
Reference in New Issue