From 3a24e7efbe16be26a593b501598eaf6490e0b6a8 Mon Sep 17 00:00:00 2001 From: Andrii Vorobiov Date: Tue, 22 Feb 2022 09:53:33 +0200 Subject: [PATCH] server: add store_id to hot ranges response api This change extends HotRangesResponseV2 message to include store ID data. This information can be useful to investigate cause of hot ranges. Release note: None Release justification: bug fixes and low-risk updates to new functionality --- docs/generated/http/full.md | 1 + docs/generated/swagger/spec.json | 3 +++ pkg/server/api_v2_ranges.go | 2 ++ pkg/server/serverpb/status.proto | 6 ++++++ pkg/server/status.go | 1 + 5 files changed, 13 insertions(+) diff --git a/docs/generated/http/full.md b/docs/generated/http/full.md index 23df3b36fc2f..1031c80f9257 100644 --- a/docs/generated/http/full.md +++ b/docs/generated/http/full.md @@ -3344,6 +3344,7 @@ HotRange message describes a single hot range, ie its QPS, node ID it belongs to | replica_node_ids | [int32](#cockroach.server.serverpb.HotRangesResponseV2-int32) | repeated | replica_node_ids specifies the list of node ids that contain replicas with current hot range. | [reserved](#support-status) | | leaseholder_node_id | [int32](#cockroach.server.serverpb.HotRangesResponseV2-int32) | | leaseholder_node_id indicates the Node ID that is the current leaseholder for the given range. | [reserved](#support-status) | | schema_name | [string](#cockroach.server.serverpb.HotRangesResponseV2-string) | | schema_name provides the name of schema (if exists) for table in current range. | [reserved](#support-status) | +| store_id | [int32](#cockroach.server.serverpb.HotRangesResponseV2-int32) | | store_id indicates the Store ID where range is stored. | [reserved](#support-status) | diff --git a/docs/generated/swagger/spec.json b/docs/generated/swagger/spec.json index 9383b9d9d176..76b21ce20cef 100644 --- a/docs/generated/swagger/spec.json +++ b/docs/generated/swagger/spec.json @@ -1832,6 +1832,9 @@ "type": "string", "x-go-name": "SchemaName" }, + "store_id": { + "$ref": "#/definitions/StoreID" + }, "table_name": { "type": "string", "x-go-name": "TableName" diff --git a/pkg/server/api_v2_ranges.go b/pkg/server/api_v2_ranges.go index 206aaaec9dd6..ec20d66660c7 100644 --- a/pkg/server/api_v2_ranges.go +++ b/pkg/server/api_v2_ranges.go @@ -435,6 +435,7 @@ type hotRangeInfo struct { IndexName string `json:"index_name"` SchemaName string `json:"schema_name"` ReplicaNodeIDs []roachpb.NodeID `json:"replica_node_ids"` + StoreID roachpb.StoreID `json:"store_id"` } // swagger:operation GET /ranges/hot/ listHotRanges @@ -514,6 +515,7 @@ func (a *apiV2Server) listHotRanges(w http.ResponseWriter, r *http.Request) { IndexName: r.IndexName, ReplicaNodeIDs: r.ReplicaNodeIds, SchemaName: r.SchemaName, + StoreID: r.StoreID, } } return hotRangeInfos, nil diff --git a/pkg/server/serverpb/status.proto b/pkg/server/serverpb/status.proto index 0fb269c462dc..435dc80831f9 100644 --- a/pkg/server/serverpb/status.proto +++ b/pkg/server/serverpb/status.proto @@ -1237,6 +1237,12 @@ message HotRangesResponseV2 { ]; // schema_name provides the name of schema (if exists) for table in current range. string schema_name = 9; + // store_id indicates the Store ID where range is stored. + int32 store_id = 10 [ + (gogoproto.customname) = "StoreID", + (gogoproto.casttype) = + "github.com/cockroachdb/cockroach/pkg/roachpb.StoreID" + ]; } // Ranges contain list of hot ranges info that has highest number of QPS. repeated HotRange ranges = 1; diff --git a/pkg/server/status.go b/pkg/server/status.go index 431dfd7af97f..56feaf990a3b 100644 --- a/pkg/server/status.go +++ b/pkg/server/status.go @@ -2244,6 +2244,7 @@ func (s *statusServer) HotRangesV2( IndexName: indexName, ReplicaNodeIds: replicaNodeIDs, LeaseholderNodeID: r.LeaseholderNodeID, + StoreID: store.StoreID, }) } }