Fix query cluster metrics (#18725)

Signed-off-by: longjiquan <jiquan.long@zilliz.com>

Signed-off-by: longjiquan <jiquan.long@zilliz.com>
pull/18290/head
Jiquan Long 2022-08-19 11:44:50 +08:00 committed by GitHub
parent e05e9cb9b4
commit cf730f6fcd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 8 deletions

View File

@ -460,8 +460,9 @@ func (c *queryNodeCluster) SyncReplicaSegments(ctx context.Context, leaderID Uni
}
type queryNodeGetMetricsResponse struct {
resp *milvuspb.GetMetricsResponse
err error
resp *milvuspb.GetMetricsResponse
err error
nodeID UniqueID // used when error occurred.
}
func (c *queryNodeCluster) GetMetrics(ctx context.Context, in *milvuspb.GetMetricsRequest) []queryNodeGetMetricsResponse {
@ -470,13 +471,15 @@ func (c *queryNodeCluster) GetMetrics(ctx context.Context, in *milvuspb.GetMetri
cnt := len(c.nodes)
wg.Add(cnt)
respChan := make(chan queryNodeGetMetricsResponse, cnt)
for _, node := range c.nodes {
for nodeID, node := range c.nodes {
nodeID := nodeID
go func(node Node) {
defer wg.Done()
resp, err := node.getMetrics(ctx, in)
respChan <- queryNodeGetMetricsResponse{
resp: resp,
err: err,
resp: resp,
err: err,
nodeID: nodeID,
}
}(node)
}

View File

@ -98,9 +98,8 @@ func getSystemInfoMetrics(
BaseComponentInfos: metricsinfo.BaseComponentInfos{
HasError: true,
ErrorReason: nodeMetrics.err.Error(),
// Name doesn't matter here because we can't get it when error occurs, using address as the Name?
Name: "",
ID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()),
Name: metricsinfo.ConstructComponentName(typeutil.QueryNodeRole, nodeMetrics.nodeID),
ID: int64(uniquegenerator.GetUniqueIntGeneratorIns().GetInt()),
},
})
continue