forked from cockroachdb/cockroach
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
kvclient, server: implement SpanStats for use with coalesced ranges
This commit provides a re-implementation of fetching the MVCC stats and range count for a given span. The previous implementation relied on the assumption that 1 range can contain at most 1 table/index. Since cockroachdbGH-79700, this assumption is no longer true. This re-implementation allows secondary tenants to access span stats via the serverpb.TenantStatusServer interface. If a roachpb.SpanStatsRequest has a node_id value of 0, instead of a specific node id, the response will yield cluster-wide values. To achieve this, the server does a fan-out to nodes that are known to have replicas for the span requested. The interaction between tenants is illustrated below: System Tenant +----------------------------------------------------+ | | | | | KV Node fan-out | | +----------+ | | | | | | +-------------------------------v----+ | | | | | | | | | server.systemStatusServer +-----+ | | | | | | +----------------+-------------------+ | | | | | | | | | via TenantStatusServer | | +--------------+ | | | | | | | | | | | v | | | +-----------+ | | | | | | | | | SQLServer | | | | | | | | | +-----------+ | | | | +----------------------v-----------------------------+ | | | | roachpb.SpanStatsResponse | | Secondary Tenant | +----------------------+------------------------------+ | | | | +------------v-------------+ | | | | | | | | kvtenantccl.Connector | | | | | | | +------------+-------------+ | | | | | | via TenantStatusServer | | +--------------------+ | | | | | | | | | | | | | | +-----------------v-------+ +------v------+ | | | | | | | | | server.statusServer | | SQLServer | | | | | | | | | +-------------------------+ +-------------+ | | | | | | | +-----------------------------------------------------+ Resolves cockroachdb#84105 Part of: https://cockroachlabs.atlassian.net/browse/CRDB-22711 Release note (backward-incompatible change): The SpanStatsRequest message field 'node_id' has changed from type 'string' to type 'int32'.
- Loading branch information
Showing
21 changed files
with
595 additions
and
300 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
// Copyright 2023 The Cockroach Authors. | ||
// | ||
// Use of this software is governed by the Business Source License | ||
// included in the file licenses/BSL.txt. | ||
// | ||
// As of the Change Date specified in that file, in accordance with | ||
// the Business Source License, use of this software will be governed | ||
// by the Apache License, Version 2.0, included in the file | ||
// licenses/APL.txt. | ||
|
||
syntax = "proto3"; | ||
package cockroach.roachpb; | ||
option go_package = "roachpb"; | ||
|
||
import "storage/enginepb/mvcc.proto"; | ||
import "gogoproto/gogo.proto"; | ||
import "google/api/annotations.proto"; | ||
|
||
// SpanStatsRequest is used to request a SpanStatsResponse for the given key | ||
// span and node id. A node_id value of 0 indicates that the server should | ||
// fan-out to all nodes, and the resulting SpanStatsResponse is a cumulative | ||
// result from across the cluster. | ||
message SpanStatsRequest { | ||
int32 node_id = 1 [ | ||
(gogoproto.customname) = "NodeID", | ||
(gogoproto.casttype) = "NodeID" | ||
]; | ||
bytes start_key = 2 [(gogoproto.casttype) = "RKey"]; | ||
bytes end_key = 3 [(gogoproto.casttype) = "RKey"]; | ||
} | ||
|
||
message SpanStatsResponse { | ||
// range_count measures the number of ranges that the request span falls within. | ||
// A SpanStatsResponse for a span that lies within a range, and whose start | ||
// key sorts after the range start, and whose end key sorts before the | ||
// range end, will have a range_count value of 1. | ||
int32 range_count = 2; | ||
uint64 approximate_disk_bytes = 3; | ||
cockroach.storage.enginepb.MVCCStats total_stats = 1 | ||
[(gogoproto.nullable) = false]; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.