Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
85339: insights: crdb_internal.cluster_execution_insights r=matthewtodd a=matthewtodd

Here we introduce a new virtual table for a cluster-wide view of
"insights," a subsystem of sqlstats that is currently disabled by
default but that will identify slow- and slower-than-usual statement
executions, along with other potentially problematic behaviors we will
be building support for.

This table will back the upcoming insights UI over the new SQL-over-HTTP
endpoint.

Release note (sql change): A new `crdb_internal` virtual table,
`cluster_execution_insights`, was introduced, offering a cluster-wide view
of the same node-local information available in `node_execution_insights`.
The insights subsystem is, as of this commit, still under development
and disabled by default, so there will not yet be much to see here.

85576: storage: use block-property filters for MVCC range tombstone masking r=nicktrav,erikgrinaker a=jbowens

Use block-property filters to aid in skipping keys that are deleted by a
MVCC range tombstone.

Release note: None

85597: opt/rowexec: support range lookup joins on input columns r=DrewKimball a=DrewKimball

**opt/rowexec: support range lookup joins on input columns**

Previously, it was possible to perform lookup joins using inequality
conditions between index columns and constant values. This commit allows
lookup joins to also use inequalities between index columns and input columns.

There are restrictions on when an inequality can be used in a lookup join:
  1. The left and right sides of the inequality must have identical types.
  2. The inequality is between an index column and input column (or constant).
  3. If the index column is `DESC` and the inequality is of the form
     `idxCol < inputCol`, the column type must support `Datum.Prev` without
     any chance of failing other than for the minimum value for that type.

Condition (3) is necessary because when the index column is `DESC`, the
`idxCol < inputCol` filter will be used in forming the start key of each span.
The spans are expected to be inclusive, so the value of inputCol will have to
be decremented to the value that orders immediately before it.

Unlike the case of retrieving the next possible key (ex: `ASC` index with
`idxCol > inputCol`) it is not possible in general to directly obtain the
immediate previous key, because it would have an infinite number of `0xff`
bytes appended to it. Thus, we have to use `Datum.Prev` on the inequality
bound before adding it to the start key.

Additionally, this commit allows lookup joins to be planned without equality
filters when the following conditions are met:
  1. There is an inequality filter between an index column and an input column
     that can be used to perform lookups.
  2. Either the input has only one row or the join has a LOOKUP hint.

These restrictions ensure that planning lookup joins in more cases does not
lead to performance regressions, since the current execution logic does not
fully de-duplicate spans when inequalities are used.

Fixes #51576

Release note (performance improvement): The execution engine can now perform
lookup joins in more cases. This can significantly improve join performance
when there is a large table with an index that conforms to the join ON
conditions, as well as allow joins to halt early in the presence of a limit.

**opt: extend ExtractJoinEqualities to handle inequalities**

Previously, `ExtractJoinEqualities` would match equalities between
non-constant, non-variable expressions and project the expressions so that
the comparison would be between variables instead. This may allow rules
like `GenerateLookupJoins` to use the equalities later.

This commit modifies `ExtractJoinEqualities` (now `ExtractJoinComparisons`)
so that it also matches inequalities. This is useful because lookup joins
can now use inequalities for lookups, and converting inequalties to
reference variables instead of complex expressions increases the likelihood
that an inequality can be used in a join.

Release note: None

85718: sql: implement drop function in legacy schema changer r=ajwerner a=chengxiong-ruan

There are 5 commits:
(1) have function resolver return `ErrFunctionUndefined` error.
(2) implement drop function in legacy schema changer.
(3) support drop cascade of objects depended on by UDFs.
(4) disallow UDF usages from tables (injected the function resolver into declarative schema changer).
(5) disallow UDF usages from views and UDF.

85823: kvserver: lower priority level for mvcc gc work r=irfansharif a=irfansharif

GC could be expected to be LowPri, so that it does not impact
user-facing traffic when resources (e.g. CPU, write capacity of the
store) are scarce. However long delays in GC can slow down user-facing
traffic due to more versions in the store, and can increase write
amplification of the store since there is more live data. Ideally, we
should adjust this priority based on how far behind we are with respect
to GC-ing a particular range. Keeping the priority level static at
NormalPri proved disruptive when a large volume of MVCC GC work is
suddenly accrued (if an old protected timestamp record was just released
for ex. following a long paused backup job being completed/canceled, or
just an old, long running backup job finishing).

After dynamic priority adjustment, it's not yet clear whether we need
additional pacing mechanisms to provide better latency isolation,
similar to ongoing work for backups. MVCC GC work is CPU intensive:
\#82955. This patch is also speculative in nature and in response to
observed incidents where NormalPri proved too disruptive. Fuller
treatment would entail working off of reliable reproductions of this
behaviour.

We also added a cluster setting (kv.mvcc_gc.queue_interval)
that controls how long the MVCC GC queue waits between
processing replicas. It was previously hardcoded to 1s (which is the
default value), but changing it would've come in handy in support
incidents as a form of manual pacing of MVCC GC work (we have a similar
useful knob for the merge queue).

Release note (performance improvement): Previously if there was sudden
increase in the volume of pending MVCC GC work, there was an impact on
foreground latencies. These sudden increases commonly occurred when:
- gc.ttlseconds was reduced dramatically over tables/indexes that accrue
  a lot of MVCC garbage (think "rows being frequently deleted")
- a paused backup job from a while ago (think > 1 day) was
  canceled/failed
- a backup job that started a while ago (think > 1 day) just finished

Indicators of a large increase in the volume of pending MVCC GC work is
a steep climb in the "GC Queue" graph found in the DB console page, when
navigating to 'Metrics', and selecting the 'Queues' dashboard. With this
patch, the effect on foreground latencies as a result of this sudden
build up should be reduced.

85869: colexecbase: fix bpchar to bpchar cast r=yuzefovich a=yuzefovich

This commit fixes an identity cast between `bpchar`s or arrays of
`bpchar`s. These types require special handling of trimming trailing
whitespace which wasn't done in the "vanilla" identity cast. I believe
that these casts don't get planned by the optimizer ever, so there
should be no impact, but it fixes a test flake and addresses the
corresponding TODO.

Fixes: #85375.

Release note: None

Co-authored-by: Matthew Todd <[email protected]>
Co-authored-by: Jackson Owens <[email protected]>
Co-authored-by: DrewKimball <[email protected]>
Co-authored-by: Chengxiong Ruan <[email protected]>
Co-authored-by: irfan sharif <[email protected]>
Co-authored-by: Yahor Yuzefovich <[email protected]>
  • Loading branch information
7 people committed Aug 10, 2022
7 parents 032df5b + 4aa312a + 3a0e0e0 + 0541e8a + afe78f9 + f00b130 + 95990fb commit a3cb8aa
Show file tree
Hide file tree
Showing 101 changed files with 6,020 additions and 2,605 deletions.
1 change: 1 addition & 0 deletions docs/generated/http/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ genrule(
"//pkg/sql/pgwire/pgerror:pgerror_proto",
"//pkg/sql/schemachanger/scpb:scpb_proto",
"//pkg/sql/sessiondatapb:sessiondatapb_proto",
"//pkg/sql/sqlstats/insights:insights_proto",
"//pkg/sql/types:types_proto",
"//pkg/storage/enginepb:enginepb_proto",
"//pkg/ts/catalog:catalog_proto",
Expand Down
46 changes: 46 additions & 0 deletions docs/generated/http/full.md
Original file line number Diff line number Diff line change
Expand Up @@ -4877,6 +4877,52 @@ Support status: [reserved](#support-status)



## ListExecutionInsights



ListExecutionInsights returns potentially problematic statements cluster-wide,
along with actions we suggest the application developer might take to remedy them.

Support status: [reserved](#support-status)

#### Request Parameters







| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| node_id | [string](#cockroach.server.serverpb.ListExecutionInsightsRequest-string) | | node_id is a string so that "local" can be used to specify that no forwarding is necessary. | [reserved](#support-status) |







#### Response Parameters







| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| insights | [cockroach.sql.insights.Insight](#cockroach.server.serverpb.ListExecutionInsightsResponse-cockroach.sql.insights.Insight) | repeated | insights lists any potentially problematic statements and actions we suggest the application developer might take to remedy them. | [reserved](#support-status) |
| errors | [cockroach.errorspb.EncodedError](#cockroach.server.serverpb.ListExecutionInsightsResponse-cockroach.errorspb.EncodedError) | repeated | errors holds any errors that occurred during fan-out calls to other nodes. | [reserved](#support-status) |







## RequestCA

`GET /_join/v1/ca`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ crdb_internal cluster_contended_tables view admin NULL NULL
crdb_internal cluster_contention_events table admin NULL NULL
crdb_internal cluster_database_privileges table admin NULL NULL
crdb_internal cluster_distsql_flows table admin NULL NULL
crdb_internal cluster_execution_insights table admin NULL NULL
crdb_internal cluster_inflight_traces table admin NULL NULL
crdb_internal cluster_locks table admin NULL NULL
crdb_internal cluster_queries table admin NULL NULL
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/partial1
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[cluster] retrieving SQL data for crdb_internal.cluster_contention_events... writing output: debug/crdb_internal.cluster_contention_events.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows... writing output: debug/crdb_internal.cluster_distsql_flows.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_database_privileges... writing output: debug/crdb_internal.cluster_database_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights... writing output: debug/crdb_internal.cluster_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_locks... writing output: debug/crdb_internal.cluster_locks.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_queries... writing output: debug/crdb_internal.cluster_queries.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/partial1_excluded
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[cluster] retrieving SQL data for crdb_internal.cluster_contention_events... writing output: debug/crdb_internal.cluster_contention_events.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows... writing output: debug/crdb_internal.cluster_distsql_flows.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_database_privileges... writing output: debug/crdb_internal.cluster_database_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights... writing output: debug/crdb_internal.cluster_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_locks... writing output: debug/crdb_internal.cluster_locks.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_queries... writing output: debug/crdb_internal.cluster_queries.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/partial2
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[cluster] retrieving SQL data for crdb_internal.cluster_contention_events... writing output: debug/crdb_internal.cluster_contention_events.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows... writing output: debug/crdb_internal.cluster_distsql_flows.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_database_privileges... writing output: debug/crdb_internal.cluster_database_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights... writing output: debug/crdb_internal.cluster_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_locks... writing output: debug/crdb_internal.cluster_locks.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_queries... writing output: debug/crdb_internal.cluster_queries.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/testzip
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[cluster] retrieving SQL data for crdb_internal.cluster_contention_events... writing output: debug/crdb_internal.cluster_contention_events.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows... writing output: debug/crdb_internal.cluster_distsql_flows.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_database_privileges... writing output: debug/crdb_internal.cluster_database_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights... writing output: debug/crdb_internal.cluster_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_locks... writing output: debug/crdb_internal.cluster_locks.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_queries... writing output: debug/crdb_internal.cluster_queries.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/testdata/zip/testzip_concurrent
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,9 @@ zip
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows...
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows: done
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows: writing output: debug/crdb_internal.cluster_distsql_flows.txt...
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights...
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights: done
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights: writing output: debug/crdb_internal.cluster_execution_insights.txt...
[cluster] retrieving SQL data for crdb_internal.cluster_locks...
[cluster] retrieving SQL data for crdb_internal.cluster_locks: done
[cluster] retrieving SQL data for crdb_internal.cluster_locks: writing output: debug/crdb_internal.cluster_locks.txt...
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/testzip_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[cluster] retrieving SQL data for crdb_internal.cluster_contention_events... writing output: debug/crdb_internal.cluster_contention_events.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_distsql_flows... writing output: debug/crdb_internal.cluster_distsql_flows.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_database_privileges... writing output: debug/crdb_internal.cluster_database_privileges.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_execution_insights... writing output: debug/crdb_internal.cluster_execution_insights.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_locks... writing output: debug/crdb_internal.cluster_locks.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_queries... writing output: debug/crdb_internal.cluster_queries.txt... done
[cluster] retrieving SQL data for crdb_internal.cluster_sessions... writing output: debug/crdb_internal.cluster_sessions.txt... done
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/zip_cluster_wide.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ var debugZipTablesPerCluster = []string{
"crdb_internal.cluster_contention_events",
"crdb_internal.cluster_distsql_flows",
"crdb_internal.cluster_database_privileges",
"crdb_internal.cluster_execution_insights",
"crdb_internal.cluster_locks",
"crdb_internal.cluster_queries",
"crdb_internal.cluster_sessions",
Expand Down
1 change: 1 addition & 0 deletions pkg/kv/kvserver/gc/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ go_library(
"//pkg/storage",
"//pkg/storage/enginepb",
"//pkg/util",
"//pkg/util/admission/admissionpb",
"//pkg/util/bufalloc",
"//pkg/util/contextutil",
"//pkg/util/hlc",
Expand Down
15 changes: 15 additions & 0 deletions pkg/kv/kvserver/gc/gc.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/storage"
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
"github.com/cockroachdb/cockroach/pkg/util"
"github.com/cockroachdb/cockroach/pkg/util/admission/admissionpb"
"github.com/cockroachdb/cockroach/pkg/util/bufalloc"
"github.com/cockroachdb/cockroach/pkg/util/contextutil"
"github.com/cockroachdb/cockroach/pkg/util/hlc"
Expand Down Expand Up @@ -115,6 +116,20 @@ var MaxIntentKeyBytesPerCleanupBatch = settings.RegisterIntSetting(
settings.NonNegativeInt,
)

// AdmissionPriority determines the admission priority level to use for MVCC GC
// work.
var AdmissionPriority = settings.RegisterEnumSetting(
settings.SystemOnly,
"kv.gc.admission_priority",
"the admission priority to use for mvcc gc work",
"bulk_normal_pri",
map[int64]string{
int64(admissionpb.BulkNormalPri): "bulk_normal_pri",
int64(admissionpb.NormalPri): "normal_pri",
int64(admissionpb.UserHighPri): "user_high_pri",
},
)

// CalculateThreshold calculates the GC threshold given the policy and the
// current view of time.
func CalculateThreshold(now hlc.Timestamp, gcttl time.Duration) (threshold hlc.Timestamp) {
Expand Down
54 changes: 40 additions & 14 deletions pkg/kv/kvserver/mvcc_gc_queue.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/gc"
"github.com/cockroachdb/cockroach/pkg/kv/kvserver/intentresolver"
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/settings"
"github.com/cockroachdb/cockroach/pkg/settings/cluster"
"github.com/cockroachdb/cockroach/pkg/spanconfig"
"github.com/cockroachdb/cockroach/pkg/storage/enginepb"
Expand All @@ -35,9 +36,9 @@ import (
)

const (
// mvccGCQueueTimerDuration is the duration between MVCC GCs of queued
// replicas.
mvccGCQueueTimerDuration = 1 * time.Second
// mvccGCQueueDefaultTimerDuration is the default duration between MVCC GCs
// of queued replicas.
mvccGCQueueDefaultTimerDuration = 1 * time.Second
// mvccGCQueueTimeout is the timeout for a single MVCC GC run.
mvccGCQueueTimeout = 10 * time.Minute
// mvccGCQueueIntentBatchTimeout is the timeout for resolving a single batch
Expand All @@ -64,6 +65,16 @@ const (
largeAbortSpanBytesThreshold = 16 * (1 << 20) // 16mb
)

// mvccGCQueueInterval is a setting that controls how long the mvcc GC queue
// waits between processing replicas.
var mvccGCQueueInterval = settings.RegisterDurationSetting(
settings.SystemOnly,
"kv.mvcc_gc.queue_interval",
"how long the mvcc gc queue waits between processing replicas",
mvccGCQueueDefaultTimerDuration,
settings.NonNegativeDuration,
)

func largeAbortSpan(ms enginepb.MVCCStats) bool {
// Checks if the size of the abort span exceeds the given threshold.
// The abort span is not supposed to become that large, but it does
Expand Down Expand Up @@ -445,17 +456,32 @@ func (r *replicaGCer) send(ctx context.Context, req roachpb.GCRequest) error {
// admission control here, as we are bypassing server.Node.
var admissionHandle interface{}
if r.admissionController != nil {
pri := admissionpb.WorkPriority(gc.AdmissionPriority.Get(&r.repl.ClusterSettings().SV))
ba.AdmissionHeader = roachpb.AdmissionHeader{
// GC is currently assigned NormalPri.
// TODO(irfansharif): GC could be expected to be BulkNormalPri, so
// that it does not impact user-facing traffic when resources (e.g.
// CPU, write capacity of the store) are scarce. However long delays
// in GC can slow down user-facing traffic due to more versions in
// the store, and can increase write amplification of the store
// since there is more live data. Ideally, we should adjust this
// priority based on how far behind we are with respect to GC-ing
// data in this range. Keeping it static at NormalPri proved
// disruptive when a large volume of MVCC GC work is suddenly
// accrued (if an old protected timestamp record was just released
// for ex. following a long paused backup job being
// completed/canceled, or just an old, long running backup job
// finishing). For now, use a cluster setting that defaults to
// BulkNormalPri.
//
// TODO(kv): GC could be expected to be LowPri, so that it does not
// impact user-facing traffic when resources (e.g. CPU, write capacity
// of the store) are scarce. However long delays in GC can slow down
// user-facing traffic due to more versions in the store, and can
// increase write amplification of the store since there is more live
// data. Ideally, we should adjust this priority based on how far behind
// we are wrt GCing in this range.
Priority: int32(admissionpb.NormalPri),
// After we implement dynamic priority adjustment, it's not clear
// whether we need additional pacing mechanisms to provide better
// latency isolation similar to ongoing work for backups (since MVCC
// GC work is CPU intensive): #82955. It's also worth noting that we
// might be able to do most MVCC GC work as part of regular
// compactions (#42514) -- the CPU use by the MVCC GC queue during
// keyspace might still be worth explicitly accounting/limiting, but
// it'll be lessened overall.
Priority: int32(pri),
CreateTime: timeutil.Now().UnixNano(),
Source: roachpb.AdmissionHeader_ROOT_KV,
NoMemoryReservedAtSource: true,
Expand Down Expand Up @@ -673,8 +699,8 @@ func updateStoreMetricsWithGCInfo(metrics *StoreMetrics, info gc.Info) {

// timer returns a constant duration to space out GC processing
// for successive queued replicas.
func (*mvccGCQueue) timer(_ time.Duration) time.Duration {
return mvccGCQueueTimerDuration
func (mgcq *mvccGCQueue) timer(_ time.Duration) time.Duration {
return mvccGCQueueInterval.Get(&mgcq.store.ClusterSettings().SV)
}

// purgatoryChan returns nil.
Expand Down
1 change: 1 addition & 0 deletions pkg/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,7 @@ go_library(
"//pkg/sql/sqlliveness",
"//pkg/sql/sqlliveness/slprovider",
"//pkg/sql/sqlstats",
"//pkg/sql/sqlstats/insights",
"//pkg/sql/sqlstats/persistedsqlstats",
"//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil",
"//pkg/sql/sqlutil",
Expand Down
4 changes: 4 additions & 0 deletions pkg/server/serverpb/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,14 @@ proto_library(
"//pkg/server/diagnostics/diagnosticspb:diagnosticspb_proto",
"//pkg/server/status/statuspb:statuspb_proto",
"//pkg/sql/contentionpb:contentionpb_proto",
"//pkg/sql/sqlstats/insights:insights_proto",
"//pkg/storage/enginepb:enginepb_proto",
"//pkg/ts/catalog:catalog_proto",
"//pkg/util:util_proto",
"//pkg/util/log/logpb:logpb_proto",
"//pkg/util/metric:metric_proto",
"//pkg/util/tracing/tracingpb:tracingpb_proto",
"@com_github_cockroachdb_errors//errorspb:errorspb_proto",
"@com_github_gogo_protobuf//gogoproto:gogo_proto",
"@com_google_protobuf//:duration_proto",
"@com_google_protobuf//:timestamp_proto",
Expand Down Expand Up @@ -68,13 +70,15 @@ go_proto_library(
"//pkg/sql/contentionpb",
"//pkg/sql/execinfrapb", # keep
"//pkg/sql/pgwire/pgwirecancel", # keep
"//pkg/sql/sqlstats/insights",
"//pkg/storage/enginepb",
"//pkg/ts/catalog",
"//pkg/util",
"//pkg/util/log/logpb",
"//pkg/util/metric",
"//pkg/util/tracing/tracingpb",
"//pkg/util/uuid", # keep
"@com_github_cockroachdb_errors//errorspb",
"@com_github_gogo_protobuf//gogoproto",
# NB: The grpc-gateway compiler injects a dependency on the descriptor
# package that Gazelle isn't prepared to deal with.
Expand Down
1 change: 1 addition & 0 deletions pkg/server/serverpb/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ type SQLStatusServer interface {
TxnIDResolution(context.Context, *TxnIDResolutionRequest) (*TxnIDResolutionResponse, error)
TransactionContentionEvents(context.Context, *TransactionContentionEventsRequest) (*TransactionContentionEventsResponse, error)
NodesList(context.Context, *NodesListRequest) (*NodesListResponse, error)
ListExecutionInsights(context.Context, *ListExecutionInsightsRequest) (*ListExecutionInsightsResponse, error)
}

// OptionalNodesStatusServer is a StatusServer that is only optionally present
Expand Down
27 changes: 27 additions & 0 deletions pkg/server/serverpb/status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ package cockroach.server.serverpb;
option go_package = "serverpb";

import "build/info.proto";
import "errorspb/errors.proto";
import "gossip/gossip.proto";
import "jobs/jobspb/jobs.proto";
import "roachpb/app_stats.proto";
Expand All @@ -23,6 +24,7 @@ import "server/diagnostics/diagnosticspb/diagnostics.proto";
import "server/serverpb/index_recommendations.proto";
import "server/status/statuspb/status.proto";
import "sql/contentionpb/contention.proto";
import "sql/sqlstats/insights/insights.proto";
import "storage/enginepb/engine.proto";
import "storage/enginepb/mvcc.proto";
import "storage/enginepb/rocksdb.proto";
Expand Down Expand Up @@ -1824,6 +1826,27 @@ message TransactionContentionEventsResponse {
];
}

message ListExecutionInsightsRequest {
// node_id is a string so that "local" can be used to specify that no
// forwarding is necessary.
string node_id = 1 [
(gogoproto.customname) = "NodeID"
];
}

message ListExecutionInsightsResponse {
// insights lists any potentially problematic statements and actions we
// suggest the application developer might take to remedy them.
repeated cockroach.sql.insights.Insight insights = 1 [
(gogoproto.nullable) = false
];

// errors holds any errors that occurred during fan-out calls to other nodes.
repeated errorspb.EncodedError errors = 2 [
(gogoproto.nullable) = false
];
}

service Status {
// Certificates retrieves a copy of the TLS certificates.
rpc Certificates(CertificatesRequest) returns (CertificatesResponse) {
Expand Down Expand Up @@ -2260,4 +2283,8 @@ service Status {
get: "/_status/transactioncontentionevents"
};
}

// ListExecutionInsights returns potentially problematic statements cluster-wide,
// along with actions we suggest the application developer might take to remedy them.
rpc ListExecutionInsights(ListExecutionInsightsRequest) returns (ListExecutionInsightsResponse) {}
}
Loading

0 comments on commit a3cb8aa

Please sign in to comment.