From 1e1cbbc2db01f7730c82fba3e41dfa6cc89033bb Mon Sep 17 00:00:00 2001 From: Nick Travers Date: Fri, 22 Jul 2022 07:20:13 -0700 Subject: [PATCH 1/7] storage: panic on iterator close when encountering corruption In #84449, the behavior of the `pebbleIterator` was altered to ignore all errors when closing an iterator. This was done to avoid panic-ing when the iterator encounters an ephemeral (i.e. retriable) error that remains pinned to the iterator until it is closed (see #84396 for the motivation). Partially address the TODO added in #84449 by panic-ing on errors that are known to be fatal (such as corruption). Addressing the TODO in its entirety would likely require enumerating known ephemeral errors and allowing such errors to be ignored on close, as well as implementing cockroachdb/pebble#1811 to avoid pinning errors to the iterator even after they have been handled. Fix #84479. Release note: None. --- pkg/storage/BUILD.bazel | 1 + pkg/storage/pebble_iterator.go | 19 ++++--- pkg/storage/pebble_iterator_test.go | 77 +++++++++++++++++++++++++++++ 3 files changed, 89 insertions(+), 8 deletions(-) create mode 100644 pkg/storage/pebble_iterator_test.go diff --git a/pkg/storage/BUILD.bazel b/pkg/storage/BUILD.bazel index 5a744bdaa868..0b94700f0f49 100644 --- a/pkg/storage/BUILD.bazel +++ b/pkg/storage/BUILD.bazel @@ -120,6 +120,7 @@ go_test( "mvcc_test.go", "mvcc_value_test.go", "pebble_file_registry_test.go", + "pebble_iterator_test.go", "pebble_mvcc_scanner_test.go", "pebble_test.go", "read_as_of_iterator_test.go", diff --git a/pkg/storage/pebble_iterator.go b/pkg/storage/pebble_iterator.go index 8bed090e0f00..ead381987548 100644 --- a/pkg/storage/pebble_iterator.go +++ b/pkg/storage/pebble_iterator.go @@ -899,17 +899,20 @@ func (p *pebbleIterator) destroy() { // surfaced through Valid(), but wants to close the iterator (eg, // potentially through a defer) and so we don't want to re-surface the // error. - _ = p.iter.Close() - - // TODO(jackson): In addition to errors accumulated during iteration, - // Close also returns errors encountered during the act of closing the - // iterator. Currently, these errors are swallowed. The error returned - // by iter.Close() may be an ephemeral error, or it may a misuse of the + // + // TODO(jackson): In addition to errors accumulated during iteration, Close + // also returns errors encountered during the act of closing the iterator. + // Currently, most of these errors are swallowed. The error returned by + // iter.Close() may be an ephemeral error, or it may a misuse of the // Iterator or corruption. Only swallow ephemeral errors (eg, - // DeadlineExceeded, etc), panic-ing on Close errors that are not known - // to be ephemeral/retriable. + // DeadlineExceeded, etc), panic-ing on Close errors that are not known to + // be ephemeral/retriable. While these ephemeral error types are enumerated, + // we panic on the error types we know to be NOT ephemeral. // // See cockroachdb/pebble#1811. + if err := p.iter.Close(); errors.Is(err, pebble.ErrCorruption) { + panic(err) + } p.iter = nil } // Reset all fields except for the key and option buffers. Holding onto their diff --git a/pkg/storage/pebble_iterator_test.go b/pkg/storage/pebble_iterator_test.go new file mode 100644 index 000000000000..198a7bb3844d --- /dev/null +++ b/pkg/storage/pebble_iterator_test.go @@ -0,0 +1,77 @@ +// Copyright 2022 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. + +package storage + +import ( + "context" + "io/fs" + "os" + "path/filepath" + "strings" + "testing" + + "github.com/cockroachdb/cockroach/pkg/util/leaktest" + "github.com/cockroachdb/errors" + "github.com/cockroachdb/pebble" + "github.com/stretchr/testify/require" +) + +func TestPebbleIterator_Corruption(t *testing.T) { + defer leaktest.AfterTest(t)() + + // Create a Pebble DB that can be used to back a pebbleIterator. + dir := t.TempDir() + dataDir := filepath.Join(dir, "data") + p, err := Open(context.Background(), Filesystem(dataDir)) + require.NoError(t, err) + defer p.Close() + + // Insert some data into the DB and flush to create an SST. + ek := engineKey("foo", 0) + require.NoError(t, p.PutEngineKey(ek, nil)) + require.NoError(t, p.Flush()) + + // Corrupt the SSTs in the DB. + err = filepath.Walk(dataDir, func(path string, info fs.FileInfo, err error) error { + if err != nil { + return err + } + if !strings.HasSuffix(info.Name(), ".sst") { + return nil + } + file, err := os.OpenFile(path, os.O_WRONLY, 0600) + if err != nil { + return err + } + _, err = file.WriteAt([]byte("uh oh"), 0) + if err != nil { + return err + } + _ = file.Close() + return nil + }) + require.NoError(t, err) + + // Construct a pebbleIterator over the DB. + iterOpts := IterOptions{ + LowerBound: []byte("a"), + UpperBound: []byte("z"), + } + iter := newPebbleIterator(p.db, iterOpts, StandardDurability, false /* range keys */) + + // Seeking into the table catches the corruption. + ok, err := iter.SeekEngineKeyGE(ek) + require.False(t, ok) + require.True(t, errors.Is(err, pebble.ErrCorruption)) + + // Closing the iter results in a panic due to the corruption. + require.Panics(t, func() { iter.Close() }) +} From accba7da075b2a7bbd57468120482639d5bac375 Mon Sep 17 00:00:00 2001 From: Matthew Todd Date: Fri, 22 Jul 2022 18:27:23 -0400 Subject: [PATCH 2/7] outliers: rename to insights The UI design that includes outliers also features other insights about sql execution. We will expand this outliers subsystem to support making those insights as well (probably with more detectors, changing the signature / return type of `isOutlier`). Renaming now is the first step in that direction. Release note: None --- pkg/BUILD.bazel | 14 ++++---- .../testdata/logic_test/crdb_internal_tenant | 2 +- pkg/cli/testdata/zip/partial1 | 10 +++--- pkg/cli/testdata/zip/partial1_excluded | 4 +-- pkg/cli/testdata/zip/partial2 | 4 +-- pkg/cli/testdata/zip/testzip | 2 +- pkg/cli/testdata/zip/testzip_concurrent | 18 +++++------ pkg/cli/testdata/zip/testzip_tenant | 2 +- pkg/cli/zip_per_node.go | 2 +- pkg/gen/protobuf.bzl | 2 +- pkg/sql/BUILD.bazel | 2 +- pkg/sql/conn_executor.go | 16 +++++----- pkg/sql/crdb_internal.go | 12 +++---- .../testdata/logic_test/crdb_internal | 2 +- .../testdata/logic_test/create_statements | 4 +-- .../logictest/testdata/logic_test/grant_table | 2 +- .../testdata/logic_test/information_schema | 10 +++--- .../logictest/testdata/logic_test/pg_catalog | 10 +++--- pkg/sql/logictest/testdata/logic_test/table | 2 +- pkg/sql/pgwire/server.go | 2 +- pkg/sql/sem/catconstants/constants.go | 2 +- pkg/sql/sqlstats/BUILD.bazel | 2 +- .../{outliers => insights}/BUILD.bazel | 22 ++++++------- .../{outliers => insights}/detector.go | 2 +- .../{outliers => insights}/detector_test.go | 2 +- .../outliers.go => insights/insights.go} | 27 ++++++++-------- .../insights.proto} | 6 ++-- .../integration/BUILD.bazel | 4 +-- .../integration/insights_test.go} | 16 +++++----- .../{outliers => insights}/registry.go | 8 ++--- .../{outliers => insights}/registry_test.go | 32 +++++++++---------- pkg/sql/sqlstats/sslocal/BUILD.bazel | 4 +-- pkg/sql/sqlstats/sslocal/sql_stats.go | 19 ++++++----- pkg/sql/sqlstats/sslocal/sql_stats_test.go | 6 ++-- pkg/sql/sqlstats/sslocal/sslocal_provider.go | 6 ++-- pkg/sql/sqlstats/ssmemstorage/BUILD.bazel | 2 +- .../sqlstats/ssmemstorage/ss_mem_storage.go | 6 ++-- .../sqlstats/ssmemstorage/ss_mem_writer.go | 6 ++-- pkg/sql/sqlstats/ssprovider.go | 4 +-- pkg/ts/catalog/chart_catalog.go | 8 ++--- 40 files changed, 152 insertions(+), 154 deletions(-) rename pkg/sql/sqlstats/{outliers => insights}/BUILD.bazel (84%) rename pkg/sql/sqlstats/{outliers => insights}/detector.go (99%) rename pkg/sql/sqlstats/{outliers => insights}/detector_test.go (99%) rename pkg/sql/sqlstats/{outliers/outliers.go => insights/insights.go} (86%) rename pkg/sql/sqlstats/{outliers/outliers.proto => insights/insights.proto} (94%) rename pkg/sql/sqlstats/{outliers => insights}/integration/BUILD.bazel (89%) rename pkg/sql/sqlstats/{outliers/integration/outliers_test.go => insights/integration/insights_test.go} (86%) rename pkg/sql/sqlstats/{outliers => insights}/registry.go (94%) rename pkg/sql/sqlstats/{outliers => insights}/registry_test.go (88%) diff --git a/pkg/BUILD.bazel b/pkg/BUILD.bazel index 7ea3b0edf366..ab54b1af0a96 100644 --- a/pkg/BUILD.bazel +++ b/pkg/BUILD.bazel @@ -419,8 +419,8 @@ ALL_TESTS = [ "//pkg/sql/sqlinstance/instancestorage:instancestorage_test", "//pkg/sql/sqlliveness/slinstance:slinstance_test", "//pkg/sql/sqlliveness/slstorage:slstorage_test", - "//pkg/sql/sqlstats/outliers/integration:integration_test", - "//pkg/sql/sqlstats/outliers:outliers_test", + "//pkg/sql/sqlstats/insights/integration:integration_test", + "//pkg/sql/sqlstats/insights:insights_test", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil:sqlstatsutil_test", "//pkg/sql/sqlstats/persistedsqlstats:persistedsqlstats_test", "//pkg/sql/sqlstats/sslocal:sslocal_test", @@ -1582,9 +1582,9 @@ GO_TARGETS = [ "//pkg/sql/sqlliveness/slstorage:slstorage_test", "//pkg/sql/sqlliveness/sqllivenesstestutils:sqllivenesstestutils", "//pkg/sql/sqlliveness:sqlliveness", - "//pkg/sql/sqlstats/outliers/integration:integration_test", - "//pkg/sql/sqlstats/outliers:outliers", - "//pkg/sql/sqlstats/outliers:outliers_test", + "//pkg/sql/sqlstats/insights/integration:integration_test", + "//pkg/sql/sqlstats/insights:insights", + "//pkg/sql/sqlstats/insights:insights_test", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil:sqlstatsutil", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil:sqlstatsutil_test", "//pkg/sql/sqlstats/persistedsqlstats:persistedsqlstats", @@ -2551,8 +2551,8 @@ GET_X_DATA_TARGETS = [ "//pkg/sql/sqlliveness/slstorage:get_x_data", "//pkg/sql/sqlliveness/sqllivenesstestutils:get_x_data", "//pkg/sql/sqlstats:get_x_data", - "//pkg/sql/sqlstats/outliers:get_x_data", - "//pkg/sql/sqlstats/outliers/integration:get_x_data", + "//pkg/sql/sqlstats/insights:get_x_data", + "//pkg/sql/sqlstats/insights/integration:get_x_data", "//pkg/sql/sqlstats/persistedsqlstats:get_x_data", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil:get_x_data", "//pkg/sql/sqlstats/sslocal:get_x_data", diff --git a/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant b/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant index fc0ac5d08c22..9b80cf000c7a 100644 --- a/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant +++ b/pkg/ccl/logictestccl/testdata/logic_test/crdb_internal_tenant @@ -75,7 +75,7 @@ crdb_internal lost_descriptors_with_data table NULL NULL NULL crdb_internal node_build_info table NULL NULL NULL crdb_internal node_contention_events table NULL NULL NULL crdb_internal node_distsql_flows table NULL NULL NULL -crdb_internal node_execution_outliers table NULL NULL NULL +crdb_internal node_execution_insights table NULL NULL NULL crdb_internal node_inflight_trace_spans table NULL NULL NULL crdb_internal node_metrics table NULL NULL NULL crdb_internal node_queries table NULL NULL NULL diff --git a/pkg/cli/testdata/zip/partial1 b/pkg/cli/testdata/zip/partial1 index 992f2921c146..3081e23a6725 100644 --- a/pkg/cli/testdata/zip/partial1 +++ b/pkg/cli/testdata/zip/partial1 @@ -82,7 +82,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 1] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/1/crdb_internal.node_build_info.txt... done [node 1] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/1/crdb_internal.node_contention_events.txt... done [node 1] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/1/crdb_internal.node_distsql_flows.txt... done -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/1/crdb_internal.node_execution_outliers.txt... done +[node 1] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/1/crdb_internal.node_execution_insights.txt... done [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/1/crdb_internal.node_inflight_trace_spans.txt... done [node 1] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/1/crdb_internal.node_metrics.txt... done [node 1] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/1/crdb_internal.node_queries.txt... done @@ -190,9 +190,9 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 2] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/2/crdb_internal.node_distsql_flows.txt... [node 2] retrieving SQL data for crdb_internal.node_distsql_flows: last request failed: failed to connect to ... [node 2] retrieving SQL data for crdb_internal.node_distsql_flows: creating error output: debug/nodes/2/crdb_internal.node_distsql_flows.txt.err.txt... done -[node 2] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/2/crdb_internal.node_execution_outliers.txt... -[node 2] retrieving SQL data for crdb_internal.node_execution_outliers: last request failed: failed to connect to ... -[node 2] retrieving SQL data for crdb_internal.node_execution_outliers: creating error output: debug/nodes/2/crdb_internal.node_execution_outliers.txt.err.txt... done +[node 2] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/2/crdb_internal.node_execution_insights.txt... +[node 2] retrieving SQL data for crdb_internal.node_execution_insights: last request failed: failed to connect to ... +[node 2] retrieving SQL data for crdb_internal.node_execution_insights: creating error output: debug/nodes/2/crdb_internal.node_execution_insights.txt.err.txt... done [node 2] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/2/crdb_internal.node_inflight_trace_spans.txt... [node 2] retrieving SQL data for crdb_internal.node_inflight_trace_spans: last request failed: failed to connect to ... [node 2] retrieving SQL data for crdb_internal.node_inflight_trace_spans: creating error output: debug/nodes/2/crdb_internal.node_inflight_trace_spans.txt.err.txt... done @@ -264,7 +264,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null [node 3] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/3/crdb_internal.node_build_info.txt... done [node 3] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/3/crdb_internal.node_contention_events.txt... done [node 3] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/3/crdb_internal.node_distsql_flows.txt... done -[node 3] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/3/crdb_internal.node_execution_outliers.txt... done +[node 3] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/3/crdb_internal.node_execution_insights.txt... done [node 3] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/3/crdb_internal.node_inflight_trace_spans.txt... done [node 3] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/3/crdb_internal.node_metrics.txt... done [node 3] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/3/crdb_internal.node_queries.txt... done diff --git a/pkg/cli/testdata/zip/partial1_excluded b/pkg/cli/testdata/zip/partial1_excluded index 2e72b855c33c..8bca312e1578 100644 --- a/pkg/cli/testdata/zip/partial1_excluded +++ b/pkg/cli/testdata/zip/partial1_excluded @@ -82,7 +82,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 1] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/1/crdb_internal.node_build_info.txt... done [node 1] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/1/crdb_internal.node_contention_events.txt... done [node 1] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/1/crdb_internal.node_distsql_flows.txt... done -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/1/crdb_internal.node_execution_outliers.txt... done +[node 1] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/1/crdb_internal.node_execution_insights.txt... done [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/1/crdb_internal.node_inflight_trace_spans.txt... done [node 1] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/1/crdb_internal.node_metrics.txt... done [node 1] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/1/crdb_internal.node_queries.txt... done @@ -173,7 +173,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0 [node 3] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/3/crdb_internal.node_build_info.txt... done [node 3] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/3/crdb_internal.node_contention_events.txt... done [node 3] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/3/crdb_internal.node_distsql_flows.txt... done -[node 3] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/3/crdb_internal.node_execution_outliers.txt... done +[node 3] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/3/crdb_internal.node_execution_insights.txt... done [node 3] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/3/crdb_internal.node_inflight_trace_spans.txt... done [node 3] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/3/crdb_internal.node_metrics.txt... done [node 3] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/3/crdb_internal.node_queries.txt... done diff --git a/pkg/cli/testdata/zip/partial2 b/pkg/cli/testdata/zip/partial2 index 41cd214da2ac..c8af3ab08cf4 100644 --- a/pkg/cli/testdata/zip/partial2 +++ b/pkg/cli/testdata/zip/partial2 @@ -82,7 +82,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 1] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/1/crdb_internal.node_build_info.txt... done [node 1] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/1/crdb_internal.node_contention_events.txt... done [node 1] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/1/crdb_internal.node_distsql_flows.txt... done -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/1/crdb_internal.node_execution_outliers.txt... done +[node 1] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/1/crdb_internal.node_execution_insights.txt... done [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/1/crdb_internal.node_inflight_trace_spans.txt... done [node 1] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/1/crdb_internal.node_metrics.txt... done [node 1] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/1/crdb_internal.node_queries.txt... done @@ -172,7 +172,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null [node 3] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/3/crdb_internal.node_build_info.txt... done [node 3] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/3/crdb_internal.node_contention_events.txt... done [node 3] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/3/crdb_internal.node_distsql_flows.txt... done -[node 3] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/3/crdb_internal.node_execution_outliers.txt... done +[node 3] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/3/crdb_internal.node_execution_insights.txt... done [node 3] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/3/crdb_internal.node_inflight_trace_spans.txt... done [node 3] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/3/crdb_internal.node_metrics.txt... done [node 3] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/3/crdb_internal.node_queries.txt... done diff --git a/pkg/cli/testdata/zip/testzip b/pkg/cli/testdata/zip/testzip index c86f8076db43..44e22b86e737 100644 --- a/pkg/cli/testdata/zip/testzip +++ b/pkg/cli/testdata/zip/testzip @@ -85,7 +85,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [node 1] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/1/crdb_internal.node_build_info.txt... done [node 1] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/1/crdb_internal.node_contention_events.txt... done [node 1] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/1/crdb_internal.node_distsql_flows.txt... done -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/1/crdb_internal.node_execution_outliers.txt... done +[node 1] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/1/crdb_internal.node_execution_insights.txt... done [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/1/crdb_internal.node_inflight_trace_spans.txt... done [node 1] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/1/crdb_internal.node_metrics.txt... done [node 1] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/1/crdb_internal.node_queries.txt... done diff --git a/pkg/cli/testdata/zip/testzip_concurrent b/pkg/cli/testdata/zip/testzip_concurrent index 34b40929bc81..b5d92d314119 100644 --- a/pkg/cli/testdata/zip/testzip_concurrent +++ b/pkg/cli/testdata/zip/testzip_concurrent @@ -304,9 +304,9 @@ zip [node 1] retrieving SQL data for crdb_internal.node_distsql_flows... [node 1] retrieving SQL data for crdb_internal.node_distsql_flows: done [node 1] retrieving SQL data for crdb_internal.node_distsql_flows: writing output: debug/nodes/1/crdb_internal.node_distsql_flows.txt... -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers... -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers: done -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers: writing output: debug/nodes/1/crdb_internal.node_execution_outliers.txt... +[node 1] retrieving SQL data for crdb_internal.node_execution_insights... +[node 1] retrieving SQL data for crdb_internal.node_execution_insights: done +[node 1] retrieving SQL data for crdb_internal.node_execution_insights: writing output: debug/nodes/1/crdb_internal.node_execution_insights.txt... [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans... [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans: done [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans: writing output: debug/nodes/1/crdb_internal.node_inflight_trace_spans.txt... @@ -622,9 +622,9 @@ zip [node 2] retrieving SQL data for crdb_internal.node_distsql_flows... [node 2] retrieving SQL data for crdb_internal.node_distsql_flows: done [node 2] retrieving SQL data for crdb_internal.node_distsql_flows: writing output: debug/nodes/2/crdb_internal.node_distsql_flows.txt... -[node 2] retrieving SQL data for crdb_internal.node_execution_outliers... -[node 2] retrieving SQL data for crdb_internal.node_execution_outliers: done -[node 2] retrieving SQL data for crdb_internal.node_execution_outliers: writing output: debug/nodes/2/crdb_internal.node_execution_outliers.txt... +[node 2] retrieving SQL data for crdb_internal.node_execution_insights... +[node 2] retrieving SQL data for crdb_internal.node_execution_insights: done +[node 2] retrieving SQL data for crdb_internal.node_execution_insights: writing output: debug/nodes/2/crdb_internal.node_execution_insights.txt... [node 2] retrieving SQL data for crdb_internal.node_inflight_trace_spans... [node 2] retrieving SQL data for crdb_internal.node_inflight_trace_spans: done [node 2] retrieving SQL data for crdb_internal.node_inflight_trace_spans: writing output: debug/nodes/2/crdb_internal.node_inflight_trace_spans.txt... @@ -940,9 +940,9 @@ zip [node 3] retrieving SQL data for crdb_internal.node_distsql_flows... [node 3] retrieving SQL data for crdb_internal.node_distsql_flows: done [node 3] retrieving SQL data for crdb_internal.node_distsql_flows: writing output: debug/nodes/3/crdb_internal.node_distsql_flows.txt... -[node 3] retrieving SQL data for crdb_internal.node_execution_outliers... -[node 3] retrieving SQL data for crdb_internal.node_execution_outliers: done -[node 3] retrieving SQL data for crdb_internal.node_execution_outliers: writing output: debug/nodes/3/crdb_internal.node_execution_outliers.txt... +[node 3] retrieving SQL data for crdb_internal.node_execution_insights... +[node 3] retrieving SQL data for crdb_internal.node_execution_insights: done +[node 3] retrieving SQL data for crdb_internal.node_execution_insights: writing output: debug/nodes/3/crdb_internal.node_execution_insights.txt... [node 3] retrieving SQL data for crdb_internal.node_inflight_trace_spans... [node 3] retrieving SQL data for crdb_internal.node_inflight_trace_spans: done [node 3] retrieving SQL data for crdb_internal.node_inflight_trace_spans: writing output: debug/nodes/3/crdb_internal.node_inflight_trace_spans.txt... diff --git a/pkg/cli/testdata/zip/testzip_tenant b/pkg/cli/testdata/zip/testzip_tenant index 470c8e37817e..07191d2eef3b 100644 --- a/pkg/cli/testdata/zip/testzip_tenant +++ b/pkg/cli/testdata/zip/testzip_tenant @@ -107,7 +107,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null [node 1] retrieving SQL data for crdb_internal.node_build_info... writing output: debug/nodes/1/crdb_internal.node_build_info.txt... done [node 1] retrieving SQL data for crdb_internal.node_contention_events... writing output: debug/nodes/1/crdb_internal.node_contention_events.txt... done [node 1] retrieving SQL data for crdb_internal.node_distsql_flows... writing output: debug/nodes/1/crdb_internal.node_distsql_flows.txt... done -[node 1] retrieving SQL data for crdb_internal.node_execution_outliers... writing output: debug/nodes/1/crdb_internal.node_execution_outliers.txt... done +[node 1] retrieving SQL data for crdb_internal.node_execution_insights... writing output: debug/nodes/1/crdb_internal.node_execution_insights.txt... done [node 1] retrieving SQL data for crdb_internal.node_inflight_trace_spans... writing output: debug/nodes/1/crdb_internal.node_inflight_trace_spans.txt... done [node 1] retrieving SQL data for crdb_internal.node_metrics... writing output: debug/nodes/1/crdb_internal.node_metrics.txt... done [node 1] retrieving SQL data for crdb_internal.node_queries... writing output: debug/nodes/1/crdb_internal.node_queries.txt... done diff --git a/pkg/cli/zip_per_node.go b/pkg/cli/zip_per_node.go index 3875994b1e83..4a2ac2581a56 100644 --- a/pkg/cli/zip_per_node.go +++ b/pkg/cli/zip_per_node.go @@ -70,7 +70,7 @@ var debugZipTablesPerNode = []string{ "crdb_internal.node_build_info", "crdb_internal.node_contention_events", "crdb_internal.node_distsql_flows", - "crdb_internal.node_execution_outliers", + "crdb_internal.node_execution_insights", "crdb_internal.node_inflight_trace_spans", "crdb_internal.node_metrics", "crdb_internal.node_queries", diff --git a/pkg/gen/protobuf.bzl b/pkg/gen/protobuf.bzl index e01772ec51d4..b215a51ab17e 100644 --- a/pkg/gen/protobuf.bzl +++ b/pkg/gen/protobuf.bzl @@ -47,7 +47,7 @@ PROTOBUF_SRCS = [ "//pkg/sql/rowenc/rowencpb:rowencpb_go_proto", "//pkg/sql/schemachanger/scpb:scpb_go_proto", "//pkg/sql/sessiondatapb:sessiondatapb_go_proto", - "//pkg/sql/sqlstats/outliers:outliers_go_proto", + "//pkg/sql/sqlstats/insights:insights_go_proto", "//pkg/sql/sqlstats/persistedsqlstats:persistedsqlstats_go_proto", "//pkg/sql/stats:stats_go_proto", "//pkg/sql/types:types_go_proto", diff --git a/pkg/sql/BUILD.bazel b/pkg/sql/BUILD.bazel index 64857a456b40..94a820f79aee 100644 --- a/pkg/sql/BUILD.bazel +++ b/pkg/sql/BUILD.bazel @@ -417,7 +417,7 @@ go_library( "//pkg/sql/sqlinstance", "//pkg/sql/sqlliveness", "//pkg/sql/sqlstats", - "//pkg/sql/sqlstats/outliers", + "//pkg/sql/sqlstats/insights", "//pkg/sql/sqlstats/persistedsqlstats", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil", "//pkg/sql/sqlstats/sslocal", diff --git a/pkg/sql/conn_executor.go b/pkg/sql/conn_executor.go index e3b4d43eea93..f3e29396ca03 100644 --- a/pkg/sql/conn_executor.go +++ b/pkg/sql/conn_executor.go @@ -51,7 +51,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sessionphase" "github.com/cockroachdb/cockroach/pkg/sql/sqlerrors" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/sslocal" "github.com/cockroachdb/cockroach/pkg/sql/stmtdiagnostics" @@ -276,7 +276,7 @@ type Server struct { // reportedStatsController. reportedStatsController *sslocal.Controller - outliers outliers.Registry + insights insights.Registry reCache *tree.RegexpCache @@ -341,8 +341,8 @@ type ServerMetrics struct { // subsystem. ContentionSubsystemMetrics txnidcache.Metrics - // OutliersMetrics contains metrics related to outlier detection. - OutliersMetrics outliers.Metrics + // InsightsMetrics contains metrics related to outlier detection. + InsightsMetrics insights.Metrics } // NewServer creates a new Server. Start() needs to be called before the Server @@ -350,7 +350,7 @@ type ServerMetrics struct { func NewServer(cfg *ExecutorConfig, pool *mon.BytesMonitor) *Server { metrics := makeMetrics(false /* internal */) serverMetrics := makeServerMetrics(cfg) - outliersRegistry := outliers.New(cfg.Settings, serverMetrics.OutliersMetrics) + outliersRegistry := insights.New(cfg.Settings, serverMetrics.InsightsMetrics) reportedSQLStats := sslocal.New( cfg.Settings, sqlstats.MaxMemReportedSQLStatsStmtFingerprints, @@ -383,7 +383,7 @@ func NewServer(cfg *ExecutorConfig, pool *mon.BytesMonitor) *Server { pool: pool, reportedStats: reportedSQLStats, reportedStatsController: reportedSQLStatsController, - outliers: outliersRegistry, + insights: outliersRegistry, reCache: tree.NewRegexpCache(512), indexUsageStats: idxusage.NewLocalIndexUsageStats(&idxusage.Config{ ChannelSize: idxusage.DefaultChannelSize, @@ -488,7 +488,7 @@ func makeServerMetrics(cfg *ExecutorConfig) ServerMetrics { ), }, ContentionSubsystemMetrics: txnidcache.NewMetrics(), - OutliersMetrics: outliers.NewMetrics(), + InsightsMetrics: insights.NewMetrics(), } } @@ -507,7 +507,7 @@ func (s *Server) Start(ctx context.Context, stopper *stop.Stopper) { // Usually it is telemetry's reporter's job to clear the reporting SQL Stats. s.reportedStats.Start(ctx, stopper) - s.outliers.Start(ctx, stopper) + s.insights.Start(ctx, stopper) s.txnIDCache.Start(ctx, stopper) } diff --git a/pkg/sql/crdb_internal.go b/pkg/sql/crdb_internal.go index d5fbfb37cf0f..20fa28e47ead 100644 --- a/pkg/sql/crdb_internal.go +++ b/pkg/sql/crdb_internal.go @@ -65,7 +65,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sqlliveness" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/sslocal" @@ -142,7 +142,7 @@ var crdbInternal = virtualSchema{ catconstants.CrdbInternalLocalTransactionsTableID: crdbInternalLocalTxnsTable, catconstants.CrdbInternalLocalSessionsTableID: crdbInternalLocalSessionsTable, catconstants.CrdbInternalLocalMetricsTableID: crdbInternalLocalMetricsTable, - catconstants.CrdbInternalNodeExecutionOutliersTableID: crdbInternalNodeExecutionOutliersTable, + catconstants.CrdbInternalNodeExecutionInsightsTableID: crdbInternalNodeExecutionInsightsTable, catconstants.CrdbInternalNodeStmtStatsTableID: crdbInternalNodeStmtStatsTable, catconstants.CrdbInternalNodeTxnStatsTableID: crdbInternalNodeTxnStatsTable, catconstants.CrdbInternalPartitionsTableID: crdbInternalPartitionsTable, @@ -6204,17 +6204,17 @@ func populateClusterLocksWithFilter( return matched, err } -var crdbInternalNodeExecutionOutliersTable = virtualSchemaTable{ +var crdbInternalNodeExecutionInsightsTable = virtualSchemaTable{ schema: ` -CREATE TABLE crdb_internal.node_execution_outliers ( +CREATE TABLE crdb_internal.node_execution_insights ( session_id STRING NOT NULL, transaction_id UUID NOT NULL, statement_id STRING NOT NULL, statement_fingerprint_id BYTES NOT NULL );`, populate: func(ctx context.Context, p *planner, db catalog.DatabaseDescriptor, addRow func(...tree.Datum) error) (err error) { - p.extendedEvalCtx.statsProvider.IterateOutliers(ctx, func( - ctx context.Context, o *outliers.Outlier, + p.extendedEvalCtx.statsProvider.IterateInsights(ctx, func( + ctx context.Context, o *insights.Insight, ) { err = errors.CombineErrors(err, addRow( tree.NewDString(hex.EncodeToString(o.Session.ID.GetBytes())), diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal b/pkg/sql/logictest/testdata/logic_test/crdb_internal index 0e8d86da3d5c..f0539bfe679a 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal @@ -55,7 +55,7 @@ crdb_internal lost_descriptors_with_data table NULL NULL NULL crdb_internal node_build_info table NULL NULL NULL crdb_internal node_contention_events table NULL NULL NULL crdb_internal node_distsql_flows table NULL NULL NULL -crdb_internal node_execution_outliers table NULL NULL NULL +crdb_internal node_execution_insights table NULL NULL NULL crdb_internal node_inflight_trace_spans table NULL NULL NULL crdb_internal node_metrics table NULL NULL NULL crdb_internal node_queries table NULL NULL NULL diff --git a/pkg/sql/logictest/testdata/logic_test/create_statements b/pkg/sql/logictest/testdata/logic_test/create_statements index 96a07d1759ec..9e5219eb0e2f 100644 --- a/pkg/sql/logictest/testdata/logic_test/create_statements +++ b/pkg/sql/logictest/testdata/logic_test/create_statements @@ -889,12 +889,12 @@ CREATE TABLE crdb_internal.node_distsql_flows ( since TIMESTAMPTZ NOT NULL, status STRING NOT NULL ) {} {} -CREATE TABLE crdb_internal.node_execution_outliers ( +CREATE TABLE crdb_internal.node_execution_insights ( session_id STRING NOT NULL, transaction_id UUID NOT NULL, statement_id STRING NOT NULL, statement_fingerprint_id BYTES NOT NULL -) CREATE TABLE crdb_internal.node_execution_outliers ( +) CREATE TABLE crdb_internal.node_execution_insights ( session_id STRING NOT NULL, transaction_id UUID NOT NULL, statement_id STRING NOT NULL, diff --git a/pkg/sql/logictest/testdata/logic_test/grant_table b/pkg/sql/logictest/testdata/logic_test/grant_table index 6066d584d1d4..4da62a62a2b3 100644 --- a/pkg/sql/logictest/testdata/logic_test/grant_table +++ b/pkg/sql/logictest/testdata/logic_test/grant_table @@ -68,7 +68,7 @@ test crdb_internal lost_descriptors_with_data public test crdb_internal node_build_info public SELECT false test crdb_internal node_contention_events public SELECT false test crdb_internal node_distsql_flows public SELECT false -test crdb_internal node_execution_outliers public SELECT false +test crdb_internal node_execution_insights public SELECT false test crdb_internal node_inflight_trace_spans public SELECT false test crdb_internal node_metrics public SELECT false test crdb_internal node_queries public SELECT false diff --git a/pkg/sql/logictest/testdata/logic_test/information_schema b/pkg/sql/logictest/testdata/logic_test/information_schema index a7b50cb30f84..adbebfb05374 100644 --- a/pkg/sql/logictest/testdata/logic_test/information_schema +++ b/pkg/sql/logictest/testdata/logic_test/information_schema @@ -439,7 +439,7 @@ crdb_internal lost_descriptors_with_data crdb_internal node_build_info crdb_internal node_contention_events crdb_internal node_distsql_flows -crdb_internal node_execution_outliers +crdb_internal node_execution_insights crdb_internal node_inflight_trace_spans crdb_internal node_metrics crdb_internal node_queries @@ -763,7 +763,7 @@ lost_descriptors_with_data node_build_info node_contention_events node_distsql_flows -node_execution_outliers +node_execution_insights node_inflight_trace_spans node_metrics node_queries @@ -1126,7 +1126,7 @@ system crdb_internal lost_descriptors_with_data SYSTEM system crdb_internal node_build_info SYSTEM VIEW NO 1 system crdb_internal node_contention_events SYSTEM VIEW NO 1 system crdb_internal node_distsql_flows SYSTEM VIEW NO 1 -system crdb_internal node_execution_outliers SYSTEM VIEW NO 1 +system crdb_internal node_execution_insights SYSTEM VIEW NO 1 system crdb_internal node_inflight_trace_spans SYSTEM VIEW NO 1 system crdb_internal node_metrics SYSTEM VIEW NO 1 system crdb_internal node_queries SYSTEM VIEW NO 1 @@ -2766,7 +2766,7 @@ NULL public system crdb_internal lost_descriptors_with_data NULL public system crdb_internal node_build_info SELECT NO YES NULL public system crdb_internal node_contention_events SELECT NO YES NULL public system crdb_internal node_distsql_flows SELECT NO YES -NULL public system crdb_internal node_execution_outliers SELECT NO YES +NULL public system crdb_internal node_execution_insights SELECT NO YES NULL public system crdb_internal node_inflight_trace_spans SELECT NO YES NULL public system crdb_internal node_metrics SELECT NO YES NULL public system crdb_internal node_queries SELECT NO YES @@ -3330,7 +3330,7 @@ NULL public system crdb_internal lost_descriptors_with_data NULL public system crdb_internal node_build_info SELECT NO YES NULL public system crdb_internal node_contention_events SELECT NO YES NULL public system crdb_internal node_distsql_flows SELECT NO YES -NULL public system crdb_internal node_execution_outliers SELECT NO YES +NULL public system crdb_internal node_execution_insights SELECT NO YES NULL public system crdb_internal node_inflight_trace_spans SELECT NO YES NULL public system crdb_internal node_metrics SELECT NO YES NULL public system crdb_internal node_queries SELECT NO YES diff --git a/pkg/sql/logictest/testdata/logic_test/pg_catalog b/pkg/sql/logictest/testdata/logic_test/pg_catalog index 305a109b2f1b..4924683c4cf5 100644 --- a/pkg/sql/logictest/testdata/logic_test/pg_catalog +++ b/pkg/sql/logictest/testdata/logic_test/pg_catalog @@ -1944,7 +1944,7 @@ oid typname typnamespace typowner typ 4294967255 node_sessions 194902141 3233629770 -1 false c 4294967256 node_transactions 194902141 3233629770 -1 false c 4294967257 node_queries 194902141 3233629770 -1 false c -4294967258 node_execution_outliers 194902141 3233629770 -1 false c +4294967258 node_execution_insights 194902141 3233629770 -1 false c 4294967259 node_distsql_flows 194902141 3233629770 -1 false c 4294967260 node_contention_events 194902141 3233629770 -1 false c 4294967261 leases 194902141 3233629770 -1 false c @@ -2336,7 +2336,7 @@ oid typname typcategory typispreferred 4294967255 node_sessions C false true , 4294967255 0 0 4294967256 node_transactions C false true , 4294967256 0 0 4294967257 node_queries C false true , 4294967257 0 0 -4294967258 node_execution_outliers C false true , 4294967258 0 0 +4294967258 node_execution_insights C false true , 4294967258 0 0 4294967259 node_distsql_flows C false true , 4294967259 0 0 4294967260 node_contention_events C false true , 4294967260 0 0 4294967261 leases C false true , 4294967261 0 0 @@ -2728,7 +2728,7 @@ oid typname typinput typoutput 4294967255 node_sessions record_in record_out record_recv record_send 0 0 0 4294967256 node_transactions record_in record_out record_recv record_send 0 0 0 4294967257 node_queries record_in record_out record_recv record_send 0 0 0 -4294967258 node_execution_outliers record_in record_out record_recv record_send 0 0 0 +4294967258 node_execution_insights record_in record_out record_recv record_send 0 0 0 4294967259 node_distsql_flows record_in record_out record_recv record_send 0 0 0 4294967260 node_contention_events record_in record_out record_recv record_send 0 0 0 4294967261 leases record_in record_out record_recv record_send 0 0 0 @@ -3120,7 +3120,7 @@ oid typname typalign typstorage typnotn 4294967255 node_sessions NULL NULL false 0 -1 4294967256 node_transactions NULL NULL false 0 -1 4294967257 node_queries NULL NULL false 0 -1 -4294967258 node_execution_outliers NULL NULL false 0 -1 +4294967258 node_execution_insights NULL NULL false 0 -1 4294967259 node_distsql_flows NULL NULL false 0 -1 4294967260 node_contention_events NULL NULL false 0 -1 4294967261 leases NULL NULL false 0 -1 @@ -3512,7 +3512,7 @@ oid typname typndims typcollation typde 4294967255 node_sessions 0 0 NULL NULL NULL 4294967256 node_transactions 0 0 NULL NULL NULL 4294967257 node_queries 0 0 NULL NULL NULL -4294967258 node_execution_outliers 0 0 NULL NULL NULL +4294967258 node_execution_insights 0 0 NULL NULL NULL 4294967259 node_distsql_flows 0 0 NULL NULL NULL 4294967260 node_contention_events 0 0 NULL NULL NULL 4294967261 leases 0 0 NULL NULL NULL diff --git a/pkg/sql/logictest/testdata/logic_test/table b/pkg/sql/logictest/testdata/logic_test/table index 95b9151387ea..4b0633ab1b92 100644 --- a/pkg/sql/logictest/testdata/logic_test/table +++ b/pkg/sql/logictest/testdata/logic_test/table @@ -593,7 +593,7 @@ lost_descriptors_with_data NULL node_build_info NULL node_contention_events NULL node_distsql_flows NULL -node_execution_outliers NULL +node_execution_insights NULL node_inflight_trace_spans NULL node_metrics NULL node_queries NULL diff --git a/pkg/sql/pgwire/server.go b/pkg/sql/pgwire/server.go index 18f93bcc7d9d..a8f2be94b145 100644 --- a/pkg/sql/pgwire/server.go +++ b/pkg/sql/pgwire/server.go @@ -433,7 +433,7 @@ func (s *Server) Metrics() (res []interface{}) { &s.SQLServer.InternalMetrics.GuardrailMetrics, &s.SQLServer.ServerMetrics.StatsMetrics, &s.SQLServer.ServerMetrics.ContentionSubsystemMetrics, - &s.SQLServer.ServerMetrics.OutliersMetrics, + &s.SQLServer.ServerMetrics.InsightsMetrics, } } diff --git a/pkg/sql/sem/catconstants/constants.go b/pkg/sql/sem/catconstants/constants.go index 1a5139ea6e99..c41074df33bf 100644 --- a/pkg/sql/sem/catconstants/constants.go +++ b/pkg/sql/sem/catconstants/constants.go @@ -124,7 +124,7 @@ const ( CrdbInternalLeasesTableID CrdbInternalLocalContentionEventsTableID CrdbInternalLocalDistSQLFlowsTableID - CrdbInternalNodeExecutionOutliersTableID + CrdbInternalNodeExecutionInsightsTableID CrdbInternalLocalQueriesTableID CrdbInternalLocalTransactionsTableID CrdbInternalLocalSessionsTableID diff --git a/pkg/sql/sqlstats/BUILD.bazel b/pkg/sql/sqlstats/BUILD.bazel index ae1fb3ae7c74..298f139315a2 100644 --- a/pkg/sql/sqlstats/BUILD.bazel +++ b/pkg/sql/sqlstats/BUILD.bazel @@ -17,7 +17,7 @@ go_library( "//pkg/sql/execstats", "//pkg/sql/sem/tree", "//pkg/sql/sessionphase", - "//pkg/sql/sqlstats/outliers", + "//pkg/sql/sqlstats/insights", "//pkg/util/stop", "//pkg/util/uuid", ], diff --git a/pkg/sql/sqlstats/outliers/BUILD.bazel b/pkg/sql/sqlstats/insights/BUILD.bazel similarity index 84% rename from pkg/sql/sqlstats/outliers/BUILD.bazel rename to pkg/sql/sqlstats/insights/BUILD.bazel index fdab2049c7b2..341b7db46fed 100644 --- a/pkg/sql/sqlstats/outliers/BUILD.bazel +++ b/pkg/sql/sqlstats/insights/BUILD.bazel @@ -4,14 +4,14 @@ load("@io_bazel_rules_go//proto:def.bzl", "go_proto_library") load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test") go_library( - name = "outliers", + name = "insights", srcs = [ "detector.go", - "outliers.go", + "insights.go", "registry.go", ], - embed = [":outliers_go_proto"], - importpath = "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers", + embed = [":insights_go_proto"], + importpath = "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights", visibility = ["//visibility:public"], deps = [ "//pkg/roachpb", @@ -28,12 +28,12 @@ go_library( ) go_test( - name = "outliers_test", + name = "insights_test", srcs = [ "detector_test.go", "registry_test.go", ], - embed = [":outliers"], + embed = [":insights"], deps = [ "//pkg/roachpb", "//pkg/settings/cluster", @@ -44,18 +44,18 @@ go_test( ) proto_library( - name = "outliers_proto", - srcs = ["outliers.proto"], + name = "insights_proto", + srcs = ["insights.proto"], strip_import_prefix = "/pkg", visibility = ["//visibility:public"], deps = ["@com_github_gogo_protobuf//gogoproto:gogo_proto"], ) go_proto_library( - name = "outliers_go_proto", + name = "insights_go_proto", compilers = ["//pkg/cmd/protoc-gen-gogoroach:protoc-gen-gogoroach_compiler"], - importpath = "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers", - proto = ":outliers_proto", + importpath = "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights", + proto = ":insights_proto", visibility = ["//visibility:public"], deps = [ "//pkg/util/uuid", # keep diff --git a/pkg/sql/sqlstats/outliers/detector.go b/pkg/sql/sqlstats/insights/detector.go similarity index 99% rename from pkg/sql/sqlstats/outliers/detector.go rename to pkg/sql/sqlstats/insights/detector.go index e61e7c3ac778..e31ca74e8b7d 100644 --- a/pkg/sql/sqlstats/outliers/detector.go +++ b/pkg/sql/sqlstats/insights/detector.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package outliers +package insights import ( "container/list" diff --git a/pkg/sql/sqlstats/outliers/detector_test.go b/pkg/sql/sqlstats/insights/detector_test.go similarity index 99% rename from pkg/sql/sqlstats/outliers/detector_test.go rename to pkg/sql/sqlstats/insights/detector_test.go index cbc72919f5cc..f811f2852751 100644 --- a/pkg/sql/sqlstats/outliers/detector_test.go +++ b/pkg/sql/sqlstats/insights/detector_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package outliers +package insights import ( "context" diff --git a/pkg/sql/sqlstats/outliers/outliers.go b/pkg/sql/sqlstats/insights/insights.go similarity index 86% rename from pkg/sql/sqlstats/outliers/outliers.go rename to pkg/sql/sqlstats/insights/insights.go index e71354b3f523..c243f0c17a7e 100644 --- a/pkg/sql/sqlstats/outliers/outliers.go +++ b/pkg/sql/sqlstats/insights/insights.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package outliers +package insights import ( "context" @@ -29,7 +29,7 @@ import ( // more statistically interesting, see #79451. var LatencyThreshold = settings.RegisterDurationSetting( settings.TenantWritable, - "sql.stats.outliers.experimental.latency_threshold", + "sql.stats.insights.experimental.latency_threshold", "amount of time after which an executing statement is considered an outlier. Use 0 to disable.", 0, ) @@ -40,7 +40,7 @@ var LatencyThreshold = settings.RegisterDurationSetting( // 100ms. var LatencyQuantileDetectorEnabled = settings.RegisterBoolSetting( settings.TenantWritable, - "sql.stats.outliers.experimental.latency_quantile_detection.enabled", + "sql.stats.insights.experimental.latency_quantile_detection.enabled", "enable per-fingerprint latency recording and outlier detection", false, ) @@ -53,7 +53,7 @@ var LatencyQuantileDetectorEnabled = settings.RegisterBoolSetting( // threshold to be reported (this is a UX optimization, removing noise). var LatencyQuantileDetectorInterestingThreshold = settings.RegisterDurationSetting( settings.TenantWritable, - "sql.stats.outliers.experimental.latency_quantile_detection.interesting_threshold", + "sql.stats.insights.experimental.latency_quantile_detection.interesting_threshold", "statements must surpass this threshold to trigger outlier detection and identification", 100*time.Millisecond, settings.NonNegativeDuration, @@ -65,7 +65,7 @@ var LatencyQuantileDetectorInterestingThreshold = settings.RegisterDurationSetti // churn. var LatencyQuantileDetectorMemoryCap = settings.RegisterByteSizeSetting( settings.TenantWritable, - "sql.stats.outliers.experimental.latency_quantile_detection.memory_limit", + "sql.stats.insights.experimental.latency_quantile_detection.memory_limit", "the maximum amount of memory allowed for tracking statement latencies", 1024*1024, settings.NonNegativeInt, @@ -94,21 +94,21 @@ var _ metric.Struct = Metrics{} func NewMetrics() Metrics { return Metrics{ Fingerprints: metric.NewGauge(metric.Metadata{ - Name: "sql.stats.outliers.latency_quantile_detector.fingerprints", + Name: "sql.stats.insights.latency_quantile_detector.fingerprints", Help: "Current number of statement fingerprints being monitored for outlier detection", Measurement: "Fingerprints", Unit: metric.Unit_COUNT, MetricType: prometheus.MetricType_GAUGE, }), Memory: metric.NewGauge(metric.Metadata{ - Name: "sql.stats.outliers.latency_quantile_detector.memory", + Name: "sql.stats.insights.latency_quantile_detector.memory", Help: "Current memory used to support outlier detection", Measurement: "Memory", Unit: metric.Unit_BYTES, MetricType: prometheus.MetricType_GAUGE, }), Evictions: metric.NewCounter(metric.Metadata{ - Name: "sql.stats.outliers.latency_quantile_detector.evictions", + Name: "sql.stats.insights.latency_quantile_detector.evictions", Help: "Evictions of fingerprint latency summaries due to memory pressure", Measurement: "Evictions", Unit: metric.Unit_COUNT, @@ -117,15 +117,14 @@ func NewMetrics() Metrics { } } -// Reader offers read-only access to the currently retained set of outliers. +// Reader offers read-only access to the currently retained set of insights. type Reader interface { - // IterateOutliers calls visitor with each of the currently retained set of outliers. - IterateOutliers(context.Context, func(context.Context, *Outlier)) + // IterateInsights calls visitor with each of the currently retained set of insights. + IterateInsights(context.Context, func(context.Context, *Insight)) } -// Registry is the central object in the outliers subsystem. It observes -// statement execution to determine which statements are outliers and -// exposes the set of currently retained outliers. +// Registry is the central object in the insights subsystem. It observes +// statement execution, looking for suggestions we may expose to the user. type Registry interface { Start(ctx context.Context, stopper *stop.Stopper) diff --git a/pkg/sql/sqlstats/outliers/outliers.proto b/pkg/sql/sqlstats/insights/insights.proto similarity index 94% rename from pkg/sql/sqlstats/outliers/outliers.proto rename to pkg/sql/sqlstats/insights/insights.proto index 28becb347fb0..04a2b4a8bd4c 100644 --- a/pkg/sql/sqlstats/outliers/outliers.proto +++ b/pkg/sql/sqlstats/insights/insights.proto @@ -9,8 +9,8 @@ // licenses/APL.txt. syntax = "proto3"; -package cockroach.sql.outliers; -option go_package = "outliers"; +package cockroach.sql.insights; +option go_package = "insights"; import "gogoproto/gogo.proto"; @@ -35,7 +35,7 @@ message Statement { double latency_in_seconds = 3; } -message Outlier { +message Insight { Session session = 1; Transaction transaction = 2; Statement statement = 3; diff --git a/pkg/sql/sqlstats/outliers/integration/BUILD.bazel b/pkg/sql/sqlstats/insights/integration/BUILD.bazel similarity index 89% rename from pkg/sql/sqlstats/outliers/integration/BUILD.bazel rename to pkg/sql/sqlstats/insights/integration/BUILD.bazel index 6fe13167839a..346c8f748dec 100644 --- a/pkg/sql/sqlstats/outliers/integration/BUILD.bazel +++ b/pkg/sql/sqlstats/insights/integration/BUILD.bazel @@ -3,14 +3,14 @@ load("@io_bazel_rules_go//go:def.bzl", "go_test") go_test( name = "integration_test", - srcs = ["outliers_test.go"], + srcs = ["insights_test.go"], deps = [ "//pkg/base", "//pkg/security/securityassets", "//pkg/security/securitytest", "//pkg/server", "//pkg/settings/cluster", - "//pkg/sql/sqlstats/outliers", + "//pkg/sql/sqlstats/insights", "//pkg/testutils", "//pkg/testutils/serverutils", "//pkg/testutils/testcluster", diff --git a/pkg/sql/sqlstats/outliers/integration/outliers_test.go b/pkg/sql/sqlstats/insights/integration/insights_test.go similarity index 86% rename from pkg/sql/sqlstats/outliers/integration/outliers_test.go rename to pkg/sql/sqlstats/insights/integration/insights_test.go index e11821ea7293..1791cc286b17 100644 --- a/pkg/sql/sqlstats/outliers/integration/outliers_test.go +++ b/pkg/sql/sqlstats/insights/integration/insights_test.go @@ -22,7 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/security/securitytest" "github.com/cockroachdb/cockroach/pkg/server" "github.com/cockroachdb/cockroach/pkg/settings/cluster" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/testutils" "github.com/cockroachdb/cockroach/pkg/testutils/serverutils" "github.com/cockroachdb/cockroach/pkg/testutils/testcluster" @@ -37,7 +37,7 @@ func TestMain(m *testing.M) { os.Exit(m.Run()) } -func TestOutliersIntegration(t *testing.T) { +func TestInsightsIntegration(t *testing.T) { defer leaktest.AfterTest(t)() defer log.Scope(t).Close(t) @@ -49,13 +49,13 @@ func TestOutliersIntegration(t *testing.T) { defer tc.Stopper().Stop(ctx) conn := tc.ServerConn(0) - // Enable outlier detection by setting a latencyThreshold > 0. + // Enable detection by setting a latencyThreshold > 0. latencyThreshold := 250 * time.Millisecond - outliers.LatencyThreshold.Override(ctx, &settings.SV, latencyThreshold) + insights.LatencyThreshold.Override(ctx, &settings.SV, latencyThreshold) - // See no recorded outliers. + // See no recorded insights. var count int - row := conn.QueryRowContext(ctx, "SELECT count(*) FROM crdb_internal.node_execution_outliers") + row := conn.QueryRowContext(ctx, "SELECT count(*) FROM crdb_internal.node_execution_insights") err := row.Scan(&count) require.NoError(t, err) require.Equal(t, 0, count) @@ -64,9 +64,9 @@ func TestOutliersIntegration(t *testing.T) { _, err = conn.ExecContext(ctx, "SELECT pg_sleep($1)", 2*latencyThreshold.Seconds()) require.NoError(t, err) - // Eventually see one recorded outlier. + // Eventually see one recorded insight. testutils.SucceedsWithin(t, func() error { - row = conn.QueryRowContext(ctx, "SELECT count(*) FROM crdb_internal.node_execution_outliers") + row = conn.QueryRowContext(ctx, "SELECT count(*) FROM crdb_internal.node_execution_insights") if err = row.Scan(&count); err != nil { return err } diff --git a/pkg/sql/sqlstats/outliers/registry.go b/pkg/sql/sqlstats/insights/registry.go similarity index 94% rename from pkg/sql/sqlstats/outliers/registry.go rename to pkg/sql/sqlstats/insights/registry.go index 5a3e31964700..067ba88cdd87 100644 --- a/pkg/sql/sqlstats/outliers/registry.go +++ b/pkg/sql/sqlstats/insights/registry.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package outliers +package insights import ( "context" @@ -93,7 +93,7 @@ func (r *registry) ObserveTransaction(sessionID clusterunique.ID, transaction *T if hasOutlier { for _, s := range statements { - r.mu.outliers.Add(s.ID, &Outlier{ + r.mu.outliers.Add(s.ID, &Insight{ Session: &Session{ID: sessionID}, Transaction: transaction, Statement: s, @@ -102,11 +102,11 @@ func (r *registry) ObserveTransaction(sessionID clusterunique.ID, transaction *T } } -func (r *registry) IterateOutliers(ctx context.Context, visitor func(context.Context, *Outlier)) { +func (r *registry) IterateInsights(ctx context.Context, visitor func(context.Context, *Insight)) { r.mu.RLock() defer r.mu.RUnlock() r.mu.outliers.Do(func(e *cache.Entry) { - visitor(ctx, e.Value.(*Outlier)) + visitor(ctx, e.Value.(*Insight)) }) } diff --git a/pkg/sql/sqlstats/outliers/registry_test.go b/pkg/sql/sqlstats/insights/registry_test.go similarity index 88% rename from pkg/sql/sqlstats/outliers/registry_test.go rename to pkg/sql/sqlstats/insights/registry_test.go index 624b6223f634..06ff1d19ce1e 100644 --- a/pkg/sql/sqlstats/outliers/registry_test.go +++ b/pkg/sql/sqlstats/insights/registry_test.go @@ -8,7 +8,7 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. -package outliers +package insights import ( "bytes" @@ -42,16 +42,16 @@ func TestRegistry(t *testing.T) { registry.ObserveStatement(session.ID, statement) registry.ObserveTransaction(session.ID, transaction) - expected := []*Outlier{{ + expected := []*Insight{{ Session: session, Transaction: transaction, Statement: statement, }} - var actual []*Outlier + var actual []*Insight - registry.IterateOutliers( + registry.IterateInsights( context.Background(), - func(ctx context.Context, o *Outlier) { + func(ctx context.Context, o *Insight) { actual = append(actual, o) }, ) @@ -66,10 +66,10 @@ func TestRegistry(t *testing.T) { registry.ObserveStatement(session.ID, statement) registry.ObserveTransaction(session.ID, transaction) - var actual []*Outlier - registry.IterateOutliers( + var actual []*Insight + registry.IterateInsights( context.Background(), - func(ctx context.Context, o *Outlier) { + func(ctx context.Context, o *Insight) { actual = append(actual, o) }, ) @@ -88,10 +88,10 @@ func TestRegistry(t *testing.T) { registry.ObserveStatement(session.ID, statement2) registry.ObserveTransaction(session.ID, transaction) - var actual []*Outlier - registry.IterateOutliers( + var actual []*Insight + registry.IterateInsights( context.Background(), - func(ctx context.Context, o *Outlier) { + func(ctx context.Context, o *Insight) { actual = append(actual, o) }, ) @@ -115,7 +115,7 @@ func TestRegistry(t *testing.T) { registry.ObserveTransaction(session.ID, transaction) registry.ObserveTransaction(otherSession.ID, otherTransaction) - expected := []*Outlier{{ + expected := []*Insight{{ Session: session, Transaction: transaction, Statement: statement, @@ -124,15 +124,15 @@ func TestRegistry(t *testing.T) { Transaction: otherTransaction, Statement: otherStatement, }} - var actual []*Outlier - registry.IterateOutliers( + var actual []*Insight + registry.IterateInsights( context.Background(), - func(ctx context.Context, o *Outlier) { + func(ctx context.Context, o *Insight) { actual = append(actual, o) }, ) - // IterateOutliers doesn't specify its iteration order, so we sort here for a stable test. + // IterateInsights doesn't specify its iteration order, so we sort here for a stable test. sort.Slice(actual, func(i, j int) bool { return bytes.Compare(actual[i].Session.ID.GetBytes(), actual[j].Session.ID.GetBytes()) < 0 }) diff --git a/pkg/sql/sqlstats/sslocal/BUILD.bazel b/pkg/sql/sqlstats/sslocal/BUILD.bazel index 8e490a70a249..687d98001f77 100644 --- a/pkg/sql/sqlstats/sslocal/BUILD.bazel +++ b/pkg/sql/sqlstats/sslocal/BUILD.bazel @@ -23,7 +23,7 @@ go_library( "//pkg/settings/cluster", "//pkg/sql/sessionphase", "//pkg/sql/sqlstats", - "//pkg/sql/sqlstats/outliers", + "//pkg/sql/sqlstats/insights", "//pkg/sql/sqlstats/ssmemstorage", "//pkg/sql/sqlutil", "//pkg/util/log", @@ -58,7 +58,7 @@ go_test( "//pkg/sql/sessiondata", "//pkg/sql/sessionphase", "//pkg/sql/sqlstats", - "//pkg/sql/sqlstats/outliers", + "//pkg/sql/sqlstats/insights", "//pkg/sql/sqlstats/persistedsqlstats", "//pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil", "//pkg/sql/tests", diff --git a/pkg/sql/sqlstats/sslocal/sql_stats.go b/pkg/sql/sqlstats/sslocal/sql_stats.go index c6800386fdde..a5b6ff1cb6c9 100644 --- a/pkg/sql/sqlstats/sslocal/sql_stats.go +++ b/pkg/sql/sqlstats/sslocal/sql_stats.go @@ -19,7 +19,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/ssmemstorage" "github.com/cockroachdb/cockroach/pkg/util/metric" "github.com/cockroachdb/cockroach/pkg/util/mon" @@ -67,7 +67,7 @@ type SQLStats struct { knobs *sqlstats.TestingKnobs - outliers outliers.Registry + insights insights.Registry } func newSQLStats( @@ -76,7 +76,7 @@ func newSQLStats( uniqueTxnFingerprintLimit *settings.IntSetting, curMemBytesCount *metric.Gauge, maxMemBytesHist *metric.Histogram, - outliersRegistry outliers.Registry, + outliersRegistry insights.Registry, parentMon *mon.BytesMonitor, flushTarget Sink, knobs *sqlstats.TestingKnobs, @@ -96,7 +96,7 @@ func newSQLStats( uniqueTxnFingerprintLimit: uniqueTxnFingerprintLimit, flushTarget: flushTarget, knobs: knobs, - outliers: outliersRegistry, + insights: outliersRegistry, } s.mu.apps = make(map[string]*ssmemstorage.Container) s.mu.mon = monitor @@ -134,7 +134,7 @@ func (s *SQLStats) getStatsForApplication(appName string) *ssmemstorage.Containe s.mu.mon, appName, s.knobs, - s.outliers, + s.insights, ) s.mu.apps[appName] = a return a @@ -191,10 +191,9 @@ func (s *SQLStats) resetAndMaybeDumpStats(ctx context.Context, target Sink) (err return err } -// IterateOutliers calls visitor with each of the currently retained set of -// execution outliers. -func (s *SQLStats) IterateOutliers( - ctx context.Context, visitor func(context.Context, *outliers.Outlier), +// IterateInsights calls visitor with each of the currently retained set of insights. +func (s *SQLStats) IterateInsights( + ctx context.Context, visitor func(context.Context, *insights.Insight), ) { - s.outliers.IterateOutliers(ctx, visitor) + s.insights.IterateInsights(ctx, visitor) } diff --git a/pkg/sql/sqlstats/sslocal/sql_stats_test.go b/pkg/sql/sqlstats/sslocal/sql_stats_test.go index 641cb636e4da..ce2615da5870 100644 --- a/pkg/sql/sqlstats/sslocal/sql_stats_test.go +++ b/pkg/sql/sqlstats/sslocal/sql_stats_test.go @@ -27,7 +27,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/sessionphase" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/sslocal" @@ -444,7 +444,7 @@ func TestExplicitTxnFingerprintAccounting(t *testing.T) { sqlstats.MaxMemSQLStatsTxnFingerprints, nil, /* curMemoryBytesCount */ nil, /* maxMemoryBytesHist */ - outliers.New(st, outliers.NewMetrics()), + insights.New(st, insights.NewMetrics()), monitor, nil, /* reportingSink */ nil, /* knobs */ @@ -554,7 +554,7 @@ func TestAssociatingStmtStatsWithTxnFingerprint(t *testing.T) { sqlstats.MaxMemSQLStatsTxnFingerprints, nil, nil, - outliers.New(st, outliers.NewMetrics()), + insights.New(st, insights.NewMetrics()), monitor, nil, nil, diff --git a/pkg/sql/sqlstats/sslocal/sslocal_provider.go b/pkg/sql/sqlstats/sslocal/sslocal_provider.go index 670546c61781..12a98ba55ec0 100644 --- a/pkg/sql/sqlstats/sslocal/sslocal_provider.go +++ b/pkg/sql/sqlstats/sslocal/sslocal_provider.go @@ -20,7 +20,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/settings" "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/ssmemstorage" "github.com/cockroachdb/cockroach/pkg/sql/sqlutil" "github.com/cockroachdb/cockroach/pkg/util/log" @@ -38,7 +38,7 @@ func New( maxTxnFingerprints *settings.IntSetting, curMemoryBytesCount *metric.Gauge, maxMemoryBytesHist *metric.Histogram, - outliersRegistry outliers.Registry, + outliersRegistry insights.Registry, pool *mon.BytesMonitor, reportingSink Sink, knobs *sqlstats.TestingKnobs, @@ -108,7 +108,7 @@ func (s *SQLStats) GetApplicationStats(appName string) sqlstats.ApplicationStats s.mu.mon, appName, s.knobs, - s.outliers, + s.insights, ) s.mu.apps[appName] = a return a diff --git a/pkg/sql/sqlstats/ssmemstorage/BUILD.bazel b/pkg/sql/sqlstats/ssmemstorage/BUILD.bazel index 0c7bd6ae32a2..a115c50818aa 100644 --- a/pkg/sql/sqlstats/ssmemstorage/BUILD.bazel +++ b/pkg/sql/sqlstats/ssmemstorage/BUILD.bazel @@ -18,7 +18,7 @@ go_library( "//pkg/settings/cluster", "//pkg/sql/execstats", "//pkg/sql/sqlstats", - "//pkg/sql/sqlstats/outliers", + "//pkg/sql/sqlstats/insights", "//pkg/util", "//pkg/util/log", "//pkg/util/mon", diff --git a/pkg/sql/sqlstats/ssmemstorage/ss_mem_storage.go b/pkg/sql/sqlstats/ssmemstorage/ss_mem_storage.go index 5a2ea3d2ea33..34f1aab192fa 100644 --- a/pkg/sql/sqlstats/ssmemstorage/ss_mem_storage.go +++ b/pkg/sql/sqlstats/ssmemstorage/ss_mem_storage.go @@ -28,7 +28,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/settings/cluster" "github.com/cockroachdb/cockroach/pkg/sql/execstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/util/log" "github.com/cockroachdb/cockroach/pkg/util/mon" "github.com/cockroachdb/cockroach/pkg/util/syncutil" @@ -120,7 +120,7 @@ type Container struct { mon *mon.BytesMonitor knobs *sqlstats.TestingKnobs - outliersRegistry outliers.Registry + outliersRegistry insights.Registry } var _ sqlstats.ApplicationStats = &Container{} @@ -135,7 +135,7 @@ func New( mon *mon.BytesMonitor, appName string, knobs *sqlstats.TestingKnobs, - outliersRegistry outliers.Registry, + outliersRegistry insights.Registry, ) *Container { s := &Container{ st: st, diff --git a/pkg/sql/sqlstats/ssmemstorage/ss_mem_writer.go b/pkg/sql/sqlstats/ssmemstorage/ss_mem_writer.go index 9691c0cc194b..631ced0b3088 100644 --- a/pkg/sql/sqlstats/ssmemstorage/ss_mem_writer.go +++ b/pkg/sql/sqlstats/ssmemstorage/ss_mem_writer.go @@ -18,7 +18,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/sql/execstats" "github.com/cockroachdb/cockroach/pkg/sql/sqlstats" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/util" "github.com/cockroachdb/errors" ) @@ -160,7 +160,7 @@ func (s *Container) RecordStatement( } } - s.outliersRegistry.ObserveStatement(value.SessionID, &outliers.Statement{ + s.outliersRegistry.ObserveStatement(value.SessionID, &insights.Statement{ ID: value.StatementID, FingerprintID: stmtFingerprintID, LatencyInSeconds: value.ServiceLatency, @@ -274,7 +274,7 @@ func (s *Container) RecordTransaction( stats.mu.data.ExecStats.MaxDiskUsage.Record(stats.mu.data.ExecStats.Count, float64(value.ExecStats.MaxDiskUsage)) } - s.outliersRegistry.ObserveTransaction(value.SessionID, &outliers.Transaction{ID: value.TransactionID}) + s.outliersRegistry.ObserveTransaction(value.SessionID, &insights.Transaction{ID: value.TransactionID}) return nil } diff --git a/pkg/sql/sqlstats/ssprovider.go b/pkg/sql/sqlstats/ssprovider.go index 791c717ec2c5..33a1617ae929 100644 --- a/pkg/sql/sqlstats/ssprovider.go +++ b/pkg/sql/sqlstats/ssprovider.go @@ -22,7 +22,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/execstats" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sessionphase" - "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/outliers" + "github.com/cockroachdb/cockroach/pkg/sql/sqlstats/insights" "github.com/cockroachdb/cockroach/pkg/util/stop" "github.com/cockroachdb/cockroach/pkg/util/uuid" ) @@ -169,7 +169,7 @@ type StatsCollector interface { type Storage interface { Reader - outliers.Reader + insights.Reader // GetLastReset returns the last time when the sqlstats is being reset. GetLastReset() time.Time diff --git a/pkg/ts/catalog/chart_catalog.go b/pkg/ts/catalog/chart_catalog.go index 78fb52616baf..8d58080cc226 100644 --- a/pkg/ts/catalog/chart_catalog.go +++ b/pkg/ts/catalog/chart_catalog.go @@ -2192,19 +2192,19 @@ var charts = []sectionDescription{ }, }, }, { - Organization: [][]string{{SQLLayer, "SQL Stats", "Outliers"}}, + Organization: [][]string{{SQLLayer, "SQL Stats", "Insights"}}, Charts: []chartDescription{ { Title: "Number of statement fingerprints being monitored for outlier detection", - Metrics: []string{"sql.stats.outliers.latency_quantile_detector.fingerprints"}, + Metrics: []string{"sql.stats.insights.latency_quantile_detector.fingerprints"}, }, { Title: "Current memory used to support outlier detection", - Metrics: []string{"sql.stats.outliers.latency_quantile_detector.memory"}, + Metrics: []string{"sql.stats.insights.latency_quantile_detector.memory"}, }, { Title: "Evictions of fingerprint latency summaries due to memory pressure", - Metrics: []string{"sql.stats.outliers.latency_quantile_detector.evictions"}, + Metrics: []string{"sql.stats.insights.latency_quantile_detector.evictions"}, }, }, }, From 8fd521323d0e5d1e64304f6606249c3b0e533046 Mon Sep 17 00:00:00 2001 From: Oleg Afanasyev Date: Mon, 25 Jul 2022 12:41:16 +0100 Subject: [PATCH 3/7] kvserver: send range GC requests when point requests are absent Previously range GC requests were not sent if point GC keys were not requested as well. This patch fixes the problem by checking that any of parameters could be specified. Release note: None --- pkg/kv/kvserver/mvcc_gc_queue.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/kv/kvserver/mvcc_gc_queue.go b/pkg/kv/kvserver/mvcc_gc_queue.go index 421c5be31986..25f4b636b552 100644 --- a/pkg/kv/kvserver/mvcc_gc_queue.go +++ b/pkg/kv/kvserver/mvcc_gc_queue.go @@ -486,7 +486,7 @@ func (r *replicaGCer) SetGCThreshold(ctx context.Context, thresh gc.Threshold) e func (r *replicaGCer) GC( ctx context.Context, keys []roachpb.GCRequest_GCKey, rangeKeys []roachpb.GCRequest_GCRangeKey, ) error { - if len(keys) == 0 { + if len(keys) == 0 && len(rangeKeys) == 0 { return nil } req := r.template() From efb99b36e35866b7a81d8298b65ab39f5b6d6203 Mon Sep 17 00:00:00 2001 From: Ricky Stewart Date: Mon, 18 Jul 2022 11:29:29 -0500 Subject: [PATCH 4/7] *: upgrade to go 1.18.4 * [ ] Adjust the Pebble tests to run in new version. * [x] Adjust version in Docker image ([source](./builder/Dockerfile)). * [x] Adjust version in the TeamCity agent image ([setup script](./packer/teamcity-agent.sh)) * [ ] Rebuild and push the Docker image (following [Basic Process](#basic-process)) * [x] Download ALL the archives (`.tar.gz`, `.zip`) for the new Go version from https://golang.org/dl/ and mirror them in the `public-bazel-artifacts` bucket in the `Bazel artifacts` project in GCP (sub-directory `go`, next to the other Go SDK's). * [x] Bump the version in `WORKSPACE` under `go_download_sdk`. You may need to bump [rules_go](https://github.com/bazelbuild/rules_go/releases). Also edit the filenames listed in `sdks` and update all the hashes to match what you mirrored in the step above. * [x] Run `./dev generate bazel` to refresh `distdir_files.bzl`, then `bazel fetch @distdir//:archives` to ensure you've updated all hashes to the correct value. * [x] Bump the version in `builder.sh` accordingly ([source](./builder.sh#L6)). * [x] Bump the version in `go-version-check.sh` ([source](./go-version-check.sh)), unless bumping to a new patch release. * [ ] Bump the go version in `go.mod`. You may also need to rerun `make vendor_rebuild` if vendoring has changed. * [x] Bump the default installed version of Go in `bootstrap-debian.sh` ([source](./bootstrap/bootstrap-debian.sh)). * [x] Replace other mentions of the older version of go (grep for `golang:` and `go`). * [ ] Update the `builder.dockerImage` parameter in the TeamCity [`Cockroach`](https://teamcity.cockroachdb.com/admin/editProject.html?projectId=Cockroach&tab=projectParams) and [`Internal`](https://teamcity.cockroachdb.com/admin/editProject.html?projectId=Internal&tab=projectParams) projects. * [ ] Ask the Developer Infrastructure team to deploy new TeamCity agent images according to [packer/README.md](./packer/README.md) Release note (build change): Upgrade to golang 1.18.4 --- BUILD.bazel | 1 + DEPS.bzl | 28 +++++--- WORKSPACE | 32 ++++----- build/bazelutil/distdir_files.bzl | 23 +++--- build/bazelutil/nogo_config.json | 71 +++++++++++++++++++ build/bazelutil/staticcheckanalyzers/def.bzl | 6 ++ .../staticcheckanalyzers/sa4028/BUILD.bazel | 13 ++++ .../staticcheckanalyzers/sa4028/analyzer.go | 24 +++++++ .../staticcheckanalyzers/sa4029/BUILD.bazel | 13 ++++ .../staticcheckanalyzers/sa4029/analyzer.go | 24 +++++++ .../staticcheckanalyzers/sa4030/BUILD.bazel | 13 ++++ .../staticcheckanalyzers/sa4030/analyzer.go | 24 +++++++ .../staticcheckanalyzers/sa4031/BUILD.bazel | 13 ++++ .../staticcheckanalyzers/sa4031/analyzer.go | 24 +++++++ .../staticcheckanalyzers/sa9007/BUILD.bazel | 13 ++++ .../staticcheckanalyzers/sa9007/analyzer.go | 24 +++++++ .../staticcheckanalyzers/sa9008/BUILD.bazel | 13 ++++ .../staticcheckanalyzers/sa9008/analyzer.go | 24 +++++++ build/bootstrap/bootstrap-debian.sh | 4 +- build/builder.sh | 2 +- build/builder/Dockerfile | 4 +- build/go-version-check.sh | 2 +- build/packer/teamcity-agent.sh | 4 +- build/teamcity-verify-archive.sh | 2 +- go.mod | 7 +- go.sum | 14 ++-- pkg/BUILD.bazel | 2 + pkg/acceptance/compose/gss/psql/Dockerfile | 2 +- pkg/blobs/client_test.go | 5 +- pkg/ccl/backupccl/backup_job.go | 2 +- pkg/ccl/changefeedccl/changefeed_stmt.go | 2 +- pkg/cmd/roachprod/docker/Dockerfile | 2 +- pkg/cmd/roachtest/tests/go_helpers.go | 4 +- pkg/cmd/roachvet/BUILD.bazel | 1 + pkg/cmd/roachvet/main.go | 2 + .../kvclient/rangecache/range_cache_test.go | 6 +- pkg/kv/kvserver/asim/state/split_decider.go | 4 +- .../client_atomic_membership_change_test.go | 4 +- .../kvserver/deprecated_store_rebalancer.go | 3 +- pkg/kv/kvserver/gc/data_distribution_test.go | 3 +- .../reports/constraint_stats_report.go | 4 +- pkg/kv/kvserver/store_rebalancer.go | 3 +- pkg/sql/colexec/colexechash/hash_utils.go | 4 +- .../colexec/colexechash/hash_utils_test.go | 5 +- pkg/sql/colexec/columnarizer.go | 5 +- pkg/sql/colexec/sort_test.go | 6 +- pkg/sql/crdb_internal.go | 14 ++-- pkg/sql/gcjob/gc_job.go | 3 +- pkg/sql/opt/memo/statistics_builder.go | 1 - pkg/sql/opt/optgen/lang/BUILD.bazel | 6 +- pkg/sql/opt/optgen/lang/expr.go | 5 +- .../opt/optgen/lang/langbootstrap/BUILD.bazel | 6 +- pkg/sql/opt/xform/scan_funcs.go | 1 + pkg/sql/parser/BUILD.bazel | 2 + pkg/sql/parser/help.go | 4 +- pkg/sql/sem/builtins/BUILD.bazel | 2 + pkg/sql/sem/builtins/builtins.go | 4 +- pkg/sql/sem/builtins/generator_builtins.go | 4 +- pkg/sql/sem/tree/overload.go | 4 +- .../sqlstatsutil/BUILD.bazel | 2 + .../sqlstatsutil/json_encoding.go | 5 +- pkg/testutils/lint/lint_test.go | 4 +- pkg/testutils/lint/passes/fmtsafe/BUILD.bazel | 2 + .../lint/passes/fmtsafe/functions.go | 12 +++- .../lint/passes/generics/BUILD.bazel | 15 ++++ .../lint/passes/generics/generics.go | 42 +++++++++++ .../lint/passes/staticcheck/BUILD.bazel | 2 +- .../lint/passes/staticcheck/staticcheck.go | 8 +-- pkg/util/contextutil/context_test.go | 3 + pkg/util/goschedstats/BUILD.bazel | 4 +- pkg/util/goschedstats/runnable.go | 2 +- .../goschedstats/runtime_deferpool_go1.17.go | 19 ----- .../goschedstats/runtime_deferpool_go1.18.go | 19 ----- .../{runtime_go1.17.go => runtime_go1.18.go} | 14 ++-- pkg/util/json/json.go | 8 +-- pkg/util/json/json_test.go | 4 +- pkg/util/log/gen/BUILD.bazel | 2 + pkg/util/log/gen/main.go | 5 +- pkg/util/netutil/net.go | 2 + .../timeutil/lowercase_timezones_generated.go | 1 + pkg/util/ulid/ulid_test.go | 3 +- vendor | 2 +- 82 files changed, 540 insertions(+), 187 deletions(-) create mode 100644 build/bazelutil/staticcheckanalyzers/sa4028/BUILD.bazel create mode 100644 build/bazelutil/staticcheckanalyzers/sa4028/analyzer.go create mode 100644 build/bazelutil/staticcheckanalyzers/sa4029/BUILD.bazel create mode 100644 build/bazelutil/staticcheckanalyzers/sa4029/analyzer.go create mode 100644 build/bazelutil/staticcheckanalyzers/sa4030/BUILD.bazel create mode 100644 build/bazelutil/staticcheckanalyzers/sa4030/analyzer.go create mode 100644 build/bazelutil/staticcheckanalyzers/sa4031/BUILD.bazel create mode 100644 build/bazelutil/staticcheckanalyzers/sa4031/analyzer.go create mode 100644 build/bazelutil/staticcheckanalyzers/sa9007/BUILD.bazel create mode 100644 build/bazelutil/staticcheckanalyzers/sa9007/analyzer.go create mode 100644 build/bazelutil/staticcheckanalyzers/sa9008/BUILD.bazel create mode 100644 build/bazelutil/staticcheckanalyzers/sa9008/analyzer.go create mode 100644 pkg/testutils/lint/passes/generics/BUILD.bazel create mode 100644 pkg/testutils/lint/passes/generics/generics.go delete mode 100644 pkg/util/goschedstats/runtime_deferpool_go1.17.go delete mode 100644 pkg/util/goschedstats/runtime_deferpool_go1.18.go rename pkg/util/goschedstats/{runtime_go1.17.go => runtime_go1.18.go} (91%) diff --git a/BUILD.bazel b/BUILD.bazel index 301938b45cc8..f24c0bbabefd 100644 --- a/BUILD.bazel +++ b/BUILD.bazel @@ -185,6 +185,7 @@ nogo( "//pkg/testutils/lint/passes/errcmp", "//pkg/testutils/lint/passes/errwrap", "//pkg/testutils/lint/passes/fmtsafe", + "//pkg/testutils/lint/passes/generics", "//pkg/testutils/lint/passes/grpcclientconnclose", "//pkg/testutils/lint/passes/grpcstatuswithdetails", "//pkg/testutils/lint/passes/hash", diff --git a/DEPS.bzl b/DEPS.bzl index c09c96386c26..fe3a30eebfc7 100644 --- a/DEPS.bzl +++ b/DEPS.bzl @@ -24,10 +24,10 @@ def go_deps(): name = "co_honnef_go_tools", build_file_proto_mode = "disable_global", importpath = "honnef.co/go/tools", - sha256 = "b327a6e9565db3b835f2b224b9023f5dd9fb236e94285f002f0ac740ad2ac43b", - strip_prefix = "honnef.co/go/tools@v0.2.1", + sha256 = "9cc6be802987a1ad579e7a1d90bde4c50b9832ce9213eab302bf8916ab3dc2b7", + strip_prefix = "honnef.co/go/tools@v0.3.2", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/honnef.co/go/tools/co_honnef_go_tools-v0.2.1.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/honnef.co/go/tools/co_honnef_go_tools-v0.3.2.zip", ], ) go_repository( @@ -9276,6 +9276,16 @@ def go_deps(): "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/exp/org_golang_x_exp-v0.0.0-20220104160115-025e73f80486.zip", ], ) + go_repository( + name = "org_golang_x_exp_typeparams", + build_file_proto_mode = "disable_global", + importpath = "golang.org/x/exp/typeparams", + sha256 = "27a9b60bc717c7882d812a302cc6e64df1617789eac7c740e331eb09877a416f", + strip_prefix = "golang.org/x/exp/typeparams@v0.0.0-20220713135740-79cabaa25d75", + urls = [ + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/exp/typeparams/org_golang_x_exp_typeparams-v0.0.0-20220713135740-79cabaa25d75.zip", + ], + ) go_repository( name = "org_golang_x_image", build_file_proto_mode = "disable_global", @@ -9310,10 +9320,10 @@ def go_deps(): name = "org_golang_x_mod", build_file_proto_mode = "disable_global", importpath = "golang.org/x/mod", - sha256 = "6e5454f23b4ebc6c18c8db07bc168c71938269deb92c22c9ce4810903680fccb", - strip_prefix = "golang.org/x/mod@v0.6.0-dev.0.20211013180041-c96bc1413d57", + sha256 = "2b7471ed34a349f91055527c5328acd40e9aba006b644e51d40a8627efa76a92", + strip_prefix = "golang.org/x/mod@v0.6.0-dev.0.20220419223038-86c51ed26bb4", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/mod/org_golang_x_mod-v0.6.0-dev.0.20211013180041-c96bc1413d57.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/mod/org_golang_x_mod-v0.6.0-dev.0.20220419223038-86c51ed26bb4.zip", ], ) go_repository( @@ -9400,10 +9410,10 @@ def go_deps(): name = "org_golang_x_tools", build_file_proto_mode = "disable_global", importpath = "golang.org/x/tools", - sha256 = "8d3aeece881c1c57d4d1e3c5c2620d3586e71b20d37c5e4665666febb9f367f0", - strip_prefix = "golang.org/x/tools@v0.1.9", + sha256 = "ed841ca9fe976973656ae79236a78806b225ddf92137205c149de36ec4c71cf4", + strip_prefix = "golang.org/x/tools@v0.1.11", urls = [ - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/tools/org_golang_x_tools-v0.1.9.zip", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/tools/org_golang_x_tools-v0.1.11.zip", ], ) go_repository( diff --git a/WORKSPACE b/WORKSPACE index 3155189dd286..6bad3e04ddd5 100644 --- a/WORKSPACE +++ b/WORKSPACE @@ -17,12 +17,12 @@ load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") # Load go bazel tools. This gives us access to the go bazel SDK/toolchains. http_archive( name = "io_bazel_rules_go", - sha256 = "5c30bd2e086ba5e8b6265599c090cac97afac91062c84beb5c36b62961016ba9", - strip_prefix = "cockroachdb-rules_go-7336768", + sha256 = "72f7456307988b1ee4f2d32bae8ac88b50c857b126b164f667f94427d85fb705", + strip_prefix = "cockroachdb-rules_go-5a4682c", urls = [ - # cockroachdb/rules_go as of 7336768b31d5af41cd46d5defb58560a93b3ba98 - # (upstream release-0.32 plus a few patches). - "https://storage.googleapis.com/public-bazel-artifacts/bazel/cockroachdb-rules_go-v0.27.0-118-g7336768.tar.gz", + # cockroachdb/rules_go as of 5a4682cd1eda7e7308107f3ff4adb981a81a953c + # (upstream release-0.33 plus a few patches). + "https://storage.googleapis.com/public-bazel-artifacts/bazel/cockroachdb-rules_go-v0.27.0-130-g5a4682c.tar.gz", ], ) @@ -140,11 +140,11 @@ http_archive( "@io_bazel_rules_go//third_party:go_googleapis-gazelle.patch", "@com_github_cockroachdb_cockroach//build/patches:go_googleapis.patch", ], - sha256 = "e8b434794608a9af0c0721cfaeedebe37d3676a4ee9dbeed868e5e2982b5abcc", - strip_prefix = "googleapis-10c88bb5c489c8ad1edb0e7f6a17cdd07147966e", - # master, as of 2022-05-09 + sha256 = "9181bb36a1df4f397375ec5aa480db797b882073518801e3a20b0e46418f2f90", + strip_prefix = "googleapis-530ca55953b470ab3b37dc9de37fcfa59410b741", + # master, as of 2022-06-05 urls = [ - "https://storage.googleapis.com/public-bazel-artifacts/bazel/10c88bb5c489c8ad1edb0e7f6a17cdd07147966e.zip", + "https://storage.googleapis.com/public-bazel-artifacts/bazel/530ca55953b470ab3b37dc9de37fcfa59410b741.zip", ], ) @@ -165,15 +165,15 @@ load( go_download_sdk( name = "go_sdk", sdks = { - "darwin_amd64": ("go1.17.11.darwin-amd64.tar.gz", "4f924c534230de8f0e1c7369f611c0310efd21fc2d9438b13bc2703af9dda25a"), - "darwin_arm64": ("go1.17.11.darwin-arm64.tar.gz", "b8e1ab009c2ff8dea462c7a1263d1f3f38e90ab5262e74c76d70e41a4db320be"), - "freebsd_amd64": ("go1.17.11.freebsd-amd64.tar.gz", "da78bcd5efa24cfa8ca3ccf0d222f7d66b755c4200d404869984ebdcfc7b6aa7"), - "linux_amd64": ("go1.17.11.linux-amd64.tar.gz", "d69a4fe2694f795d8e525c72b497ededc209cb7185f4c3b62d7a98dd6227b3fe"), - "linux_arm64": ("go1.17.11.linux-arm64.tar.gz", "adefa7412c6798f9cad02d1e8336fc2242f5bade30c5b32781759181e01961b7"), - "windows_amd64": ("go1.17.11.windows-amd64.zip", "88e60b92069d8e0932ca5d8bd8227d1693b9570fa2afbedadcc680749c428d54"), + "darwin_amd64": ("go1.18.4.darwin-amd64.tar.gz", "315e1a2b21a827c68da1b7f492b5dcbe81d8df8a79ebe50922df9588893f87f0"), + "darwin_arm64": ("go1.18.4.darwin-arm64.tar.gz", "04eed623d5143ffa44965b618b509e0beccccfd3a4a1bfebc0cdbcf906046769"), + "freebsd_amd64": ("go1.18.4.freebsd-amd64.tar.gz", "fb00f8aaffcc80e0a2bd39db1d8e8e21ef0a691c564f7b7601383dd6adad4042"), + "linux_amd64": ("go1.18.4.linux-amd64.tar.gz", "c9b099b68d93f5c5c8a8844a89f8db07eaa58270e3a1e01804f17f4cf8df02f5"), + "linux_arm64": ("go1.18.4.linux-arm64.tar.gz", "35014d92b50d97da41dade965df7ebeb9a715da600206aa59ce1b2d05527421f"), + "windows_amd64": ("go1.18.4.windows-amd64.zip", "dfb93c517e050ba0cfc066802b38a8e7cda2ef666efd634859356b33f543cc49"), }, urls = ["https://storage.googleapis.com/public-bazel-artifacts/go/{}"], - version = "1.17.11", + version = "1.18.4", ) # To point to a local SDK path, use the following instead. We'll call the diff --git a/build/bazelutil/distdir_files.bzl b/build/bazelutil/distdir_files.bzl index 04c1b4992892..62242c8c0740 100644 --- a/build/bazelutil/distdir_files.bzl +++ b/build/bazelutil/distdir_files.bzl @@ -862,10 +862,11 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/arch/org_golang_x_arch-v0.0.0-20180920145803-b19384d3c130.zip": "9f67b677a3fefc503111d9aa7df8bacd2677411b0fcb982eb1654aa6d14cc3f8", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/crypto/org_golang_x_crypto-v0.0.0-20220518034528-6f7dac969898.zip": "81dbe3648b3bb1f191ac7584626106bf0a8ceccd62e1cd33dbb0e4bd266d1340", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/exp/org_golang_x_exp-v0.0.0-20220104160115-025e73f80486.zip": "50e096afbb8e0f073519dd05f6573aefe410a829c87a7c1b64efb8c4a3948c50", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/exp/typeparams/org_golang_x_exp_typeparams-v0.0.0-20220713135740-79cabaa25d75.zip": "27a9b60bc717c7882d812a302cc6e64df1617789eac7c740e331eb09877a416f", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/image/org_golang_x_image-v0.0.0-20190802002840-cff245a6509b.zip": "4a44b498934a95e8f84e8374530de0cab38d81fcd558898d4880c3c5ce1efe47", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/lint/org_golang_x_lint-v0.0.0-20210508222113-6edffad5e616.zip": "0a4a5ebd2b1d79e7f480cbf5a54b45a257ae1ec9d11f01688efc5c35268d4603", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/mobile/org_golang_x_mobile-v0.0.0-20201217150744-e6ae53a27f4f.zip": "1fd2f665cdb7f64b80e2e1224941d1ecad10bd99327c6fc8906183d2ef3816df", - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/mod/org_golang_x_mod-v0.6.0-dev.0.20211013180041-c96bc1413d57.zip": "6e5454f23b4ebc6c18c8db07bc168c71938269deb92c22c9ce4810903680fccb", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/mod/org_golang_x_mod-v0.6.0-dev.0.20220419223038-86c51ed26bb4.zip": "2b7471ed34a349f91055527c5328acd40e9aba006b644e51d40a8627efa76a92", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/net/org_golang_x_net-v0.0.0-20220524220425-1d687d428aca.zip": "b3d53182e3eb8aa90a0105e84dc8fe58aaa8e37168d2302e70165a1039b5548f", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/oauth2/org_golang_x_oauth2-v0.0.0-20220411215720-9780585627b5.zip": "81f60a99f4f3bcb34993ca5831386d8399c472a0ca4dc6f1e3659a071d002029", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/perf/org_golang_x_perf-v0.0.0-20180704124530-6e6d33e29852.zip": "a2c7d02cc94c4ba767b6322f70ddcba4941cb5f60fed1bada3aa7a4d3a8128f1", @@ -874,7 +875,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/term/org_golang_x_term-v0.0.0-20210927222741-03fcf44c2211.zip": "3adf713afa49fe26580ffe4adb1f4fb2f4921c945301aa5a9fb6d34031fa30cd", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/text/org_golang_x_text-v0.3.7.zip": "e1a9115e61a38da8bdc893d0ba83b65f89cc1114f152a98eb572c5ea6551e8d4", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/time/org_golang_x_time-v0.0.0-20210723032227-1f47c861a9ac.zip": "e5d8ade42804ec7d96a632c031dde7db087e8bc4cd5dfd6f38df03ce4f16d9b6", - "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/tools/org_golang_x_tools-v0.1.9.zip": "8d3aeece881c1c57d4d1e3c5c2620d3586e71b20d37c5e4665666febb9f367f0", + "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/tools/org_golang_x_tools-v0.1.11.zip": "ed841ca9fe976973656ae79236a78806b225ddf92137205c149de36ec4c71cf4", "https://storage.googleapis.com/cockroach-godeps/gomod/golang.org/x/xerrors/org_golang_x_xerrors-v0.0.0-20220517211312-f3a8303e98df.zip": "bc395a1480bac68c5444a29926b9bc5ecea88f5fcec7451c1946dec6bd9a051f", "https://storage.googleapis.com/cockroach-godeps/gomod/gonum.org/v1/gonum/org_gonum_v1_gonum-v0.8.2.zip": "57ecefd9c1ab5a40ed9e37e824597e523e85e78022cd8a4fc5533ff785f49863", "https://storage.googleapis.com/cockroach-godeps/gomod/gonum.org/v1/netlib/org_gonum_v1_netlib-v0.0.0-20190331212654-76723241ea4e.zip": "ed4dca5026c9ab5410d23bbe21c089433ca58a19bd2902311c6a91791142a687", @@ -922,7 +923,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/gorm.io/gorm/io_gorm_gorm-v1.21.4.zip": "4048b3c1d2cd0b8372755fcf9bc33d621c1e532e4e2b791c17036e02ac9b0694", "https://storage.googleapis.com/cockroach-godeps/gomod/gotest.tools/tools_gotest-v2.2.0+incompatible.zip": "55fab831b2660201183b54d742602563d4e17e7125ee75788a309a4f6cb7285e", "https://storage.googleapis.com/cockroach-godeps/gomod/gotest.tools/v3/tools_gotest_v3-v3.0.3.zip": "9c1e4b8a1477c52441aafc2025a4b4e8bc300a9817c5549c0dc7fffef34bdaef", - "https://storage.googleapis.com/cockroach-godeps/gomod/honnef.co/go/tools/co_honnef_go_tools-v0.2.1.zip": "b327a6e9565db3b835f2b224b9023f5dd9fb236e94285f002f0ac740ad2ac43b", + "https://storage.googleapis.com/cockroach-godeps/gomod/honnef.co/go/tools/co_honnef_go_tools-v0.3.2.zip": "9cc6be802987a1ad579e7a1d90bde4c50b9832ce9213eab302bf8916ab3dc2b7", "https://storage.googleapis.com/cockroach-godeps/gomod/k8s.io/api/io_k8s_api-v0.22.1.zip": "f7bdf8655b5078d05124dacb2eeaf2e2dc356334f174b623d3afa9130517e272", "https://storage.googleapis.com/cockroach-godeps/gomod/k8s.io/apiextensions-apiserver/io_k8s_apiextensions_apiserver-v0.17.3.zip": "f3be44b21eaea21dbc2655f207f838a94e4ed63b24e5ce4f1d688c329b53c9ff", "https://storage.googleapis.com/cockroach-godeps/gomod/k8s.io/apimachinery/io_k8s_apimachinery-v0.22.1.zip": "2097d287ef9b837b18951bea7cca7cab8bdd3d25fd4c30210fc8cb8fcbbf2ca0", @@ -964,7 +965,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/cockroach-godeps/gomod/sigs.k8s.io/structured-merge-diff/v4/io_k8s_sigs_structured_merge_diff_v4-v4.1.2.zip": "b32af97dadd79179a8f62aaf4ef1e0562e051be77053a60c7a4e724a5cbd00ce", "https://storage.googleapis.com/cockroach-godeps/gomod/sigs.k8s.io/yaml/io_k8s_sigs_yaml-v1.2.0.zip": "55ed08c5df448a033bf7e2c2912d4daa85b856a05c854b0c87ccc85c7f3fbfc7", "https://storage.googleapis.com/cockroach-godeps/gomod/sourcegraph.com/sourcegraph/appdash/com_sourcegraph_sourcegraph_appdash-v0.0.0-20190731080439-ebfcffb1b5c0.zip": "bd2492d9db05362c2fecd0b3d0f6002c89a6d90d678fb93b4158298ab883736f", - "https://storage.googleapis.com/public-bazel-artifacts/bazel/10c88bb5c489c8ad1edb0e7f6a17cdd07147966e.zip": "e8b434794608a9af0c0721cfaeedebe37d3676a4ee9dbeed868e5e2982b5abcc", + "https://storage.googleapis.com/public-bazel-artifacts/bazel/530ca55953b470ab3b37dc9de37fcfa59410b741.zip": "9181bb36a1df4f397375ec5aa480db797b882073518801e3a20b0e46418f2f90", "https://storage.googleapis.com/public-bazel-artifacts/bazel/88ef31b429631b787ceb5e4556d773b20ad797c8.zip": "92a89a2bbe6c6db2a8b87da4ce723aff6253656e8417f37e50d362817c39b98b", "https://storage.googleapis.com/public-bazel-artifacts/bazel/bazel-gazelle-v0.25.0.tar.gz": "5982e5463f171da99e3bdaeff8c0f48283a7a5f396ec5282910b9e8a49c0dd7e", "https://storage.googleapis.com/public-bazel-artifacts/bazel/bazel-skylib-1.0.3.tar.gz": "1c531376ac7e5a180e0237938a2536de0c54d93f5c278634818e0efc952dd56c", @@ -972,7 +973,7 @@ DISTDIR_FILES = { "https://storage.googleapis.com/public-bazel-artifacts/bazel/bmatcuk-doublestar-v4.0.1-0-gf7a8118.tar.gz": "d11c3b3a45574f89d6a6b2f50e53feea50df60407b35f36193bf5815d32c79d1", "https://storage.googleapis.com/public-bazel-artifacts/bazel/cockroachdb-protobuf-3f5d91f.tar.gz": "6d4e7fe1cbd958dee69ce9becbf8892d567f082b6782d3973a118d0aa00807a8", "https://storage.googleapis.com/public-bazel-artifacts/bazel/cockroachdb-rules_foreign_cc-6f7f1b1.tar.gz": "272ac2cde4efd316c8d7c0140dee411c89da104466701ac179286ef5a89c7b58", - "https://storage.googleapis.com/public-bazel-artifacts/bazel/cockroachdb-rules_go-v0.27.0-118-g7336768.tar.gz": "5c30bd2e086ba5e8b6265599c090cac97afac91062c84beb5c36b62961016ba9", + "https://storage.googleapis.com/public-bazel-artifacts/bazel/cockroachdb-rules_go-v0.27.0-130-g5a4682c.tar.gz": "72f7456307988b1ee4f2d32bae8ac88b50c857b126b164f667f94427d85fb705", "https://storage.googleapis.com/public-bazel-artifacts/bazel/cockroachdb-rules_nodejs-5.5.0-1-g59a92cc.tar.gz": "7f3f747db3f924547b9ffdf86da6c604335ad95e09d4e5a69fdcfdb505099421", "https://storage.googleapis.com/public-bazel-artifacts/bazel/google-starlark-go-e043a3d.tar.gz": "a35c6468e0e0921833a63290161ff903295eaaf5915200bbce272cbc8dfd1c1c", "https://storage.googleapis.com/public-bazel-artifacts/bazel/platforms-0.0.4.tar.gz": "079945598e4b6cc075846f7fd6a9d0857c33a7afc0de868c2ccb96405225135d", @@ -999,12 +1000,12 @@ DISTDIR_FILES = { "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.macos.20220708-170245.tar.gz": "fd342ce3e99d9df6de8fcdf09ff9735887d7025d88ba9814b4c73cff24691b26", "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.macosarm.20220708-170245.tar.gz": "6394f40dbc799909ee239e42c25d08b5b2af0ad0c8aa30f37553e936f1c1dc4e", "https://storage.googleapis.com/public-bazel-artifacts/c-deps/20220708-170245/libproj_foreign.windows.20220708-170245.tar.gz": "233c6cecef5e826bd1aea7c7c603fb86fc78299d2016c4d3afcb0c1509eff001", - "https://storage.googleapis.com/public-bazel-artifacts/go/go1.17.11.darwin-amd64.tar.gz": "4f924c534230de8f0e1c7369f611c0310efd21fc2d9438b13bc2703af9dda25a", - "https://storage.googleapis.com/public-bazel-artifacts/go/go1.17.11.darwin-arm64.tar.gz": "b8e1ab009c2ff8dea462c7a1263d1f3f38e90ab5262e74c76d70e41a4db320be", - "https://storage.googleapis.com/public-bazel-artifacts/go/go1.17.11.freebsd-amd64.tar.gz": "da78bcd5efa24cfa8ca3ccf0d222f7d66b755c4200d404869984ebdcfc7b6aa7", - "https://storage.googleapis.com/public-bazel-artifacts/go/go1.17.11.linux-amd64.tar.gz": "d69a4fe2694f795d8e525c72b497ededc209cb7185f4c3b62d7a98dd6227b3fe", - "https://storage.googleapis.com/public-bazel-artifacts/go/go1.17.11.linux-arm64.tar.gz": "adefa7412c6798f9cad02d1e8336fc2242f5bade30c5b32781759181e01961b7", - "https://storage.googleapis.com/public-bazel-artifacts/go/go1.17.11.windows-amd64.zip": "88e60b92069d8e0932ca5d8bd8227d1693b9570fa2afbedadcc680749c428d54", + "https://storage.googleapis.com/public-bazel-artifacts/go/go1.18.4.darwin-amd64.tar.gz": "315e1a2b21a827c68da1b7f492b5dcbe81d8df8a79ebe50922df9588893f87f0", + "https://storage.googleapis.com/public-bazel-artifacts/go/go1.18.4.darwin-arm64.tar.gz": "04eed623d5143ffa44965b618b509e0beccccfd3a4a1bfebc0cdbcf906046769", + "https://storage.googleapis.com/public-bazel-artifacts/go/go1.18.4.freebsd-amd64.tar.gz": "fb00f8aaffcc80e0a2bd39db1d8e8e21ef0a691c564f7b7601383dd6adad4042", + "https://storage.googleapis.com/public-bazel-artifacts/go/go1.18.4.linux-amd64.tar.gz": "c9b099b68d93f5c5c8a8844a89f8db07eaa58270e3a1e01804f17f4cf8df02f5", + "https://storage.googleapis.com/public-bazel-artifacts/go/go1.18.4.linux-arm64.tar.gz": "35014d92b50d97da41dade965df7ebeb9a715da600206aa59ce1b2d05527421f", + "https://storage.googleapis.com/public-bazel-artifacts/go/go1.18.4.windows-amd64.zip": "dfb93c517e050ba0cfc066802b38a8e7cda2ef666efd634859356b33f543cc49", "https://storage.googleapis.com/public-bazel-artifacts/gomod/github.com/bazelbuild/buildtools/v0.0.0-20200718160251-b1667ff58f71/buildtools-v0.0.0-20200718160251-b1667ff58f71.tar.gz": "a9ef5103739dfb5ed2a5b47ab1654842a89695812e4af09e57d7015a5caf97e0", "https://storage.googleapis.com/public-bazel-artifacts/java/railroad/rr-1.63-java8.zip": "d2791cd7a44ea5be862f33f5a9b3d40aaad9858455828ebade7007ad7113fb41", "https://storage.googleapis.com/public-bazel-artifacts/js/node/v16.13.0/node-v16.13.0-darwin-arm64.tar.gz": "46d83fc0bd971db5050ef1b15afc44a6665dee40bd6c1cbaec23e1b40fa49e6d", diff --git a/build/bazelutil/nogo_config.json b/build/bazelutil/nogo_config.json index b17463c08e64..be0c8326323a 100644 --- a/build/bazelutil/nogo_config.json +++ b/build/bazelutil/nogo_config.json @@ -77,6 +77,11 @@ "cockroach/pkg/.*$": "first-party code" } }, + "generics": { + "only_files": { + "cockroach/pkg/.*$": "first-party code" + } + }, "grpcconnclose": { "exclude_files": { "cockroach/pkg/.*\\.eg\\.go$": "generated code", @@ -1189,6 +1194,50 @@ "cockroach/pkg/.*$": "first-party code" } }, + "SA4028": { + "exclude_files": { + "cockroach/pkg/.*\\.eg\\.go$": "generated code", + ".*\\.pb\\.go$": "generated code", + ".*\\.pb\\.gw\\.go$": "generated code", + "cockroach/pkg/.*_generated\\.go$": "generated code" + }, + "only_files": { + "cockroach/pkg/.*$": "first-party code" + } + }, + "SA4029": { + "exclude_files": { + "cockroach/pkg/.*\\.eg\\.go$": "generated code", + ".*\\.pb\\.go$": "generated code", + ".*\\.pb\\.gw\\.go$": "generated code", + "cockroach/pkg/.*_generated\\.go$": "generated code" + }, + "only_files": { + "cockroach/pkg/.*$": "first-party code" + } + }, + "SA4030": { + "exclude_files": { + "cockroach/pkg/.*\\.eg\\.go$": "generated code", + ".*\\.pb\\.go$": "generated code", + ".*\\.pb\\.gw\\.go$": "generated code", + "cockroach/pkg/.*_generated\\.go$": "generated code" + }, + "only_files": { + "cockroach/pkg/.*$": "first-party code" + } + }, + "SA4031": { + "exclude_files": { + "cockroach/pkg/.*\\.eg\\.go$": "generated code", + ".*\\.pb\\.go$": "generated code", + ".*\\.pb\\.gw\\.go$": "generated code", + "cockroach/pkg/.*_generated\\.go$": "generated code" + }, + "only_files": { + "cockroach/pkg/.*$": "first-party code" + } + }, "SA5000": { "exclude_files": { "cockroach/pkg/.*\\.eg\\.go$": "generated code", @@ -1443,6 +1492,28 @@ "cockroach/pkg/.*$": "first-party code" } }, + "SA9007": { + "exclude_files": { + "cockroach/pkg/.*\\.eg\\.go$": "generated code", + ".*\\.pb\\.go$": "generated code", + ".*\\.pb\\.gw\\.go$": "generated code", + "cockroach/pkg/.*_generated\\.go$": "generated code" + }, + "only_files": { + "cockroach/pkg/.*$": "first-party code" + } + }, + "SA9008": { + "exclude_files": { + "cockroach/pkg/.*\\.eg\\.go$": "generated code", + ".*\\.pb\\.go$": "generated code", + ".*\\.pb\\.gw\\.go$": "generated code", + "cockroach/pkg/.*_generated\\.go$": "generated code" + }, + "only_files": { + "cockroach/pkg/.*$": "first-party code" + } + }, "ST1000": { "exclude_files": { "cockroach/pkg/.*$": "skipped in default staticcheck config", diff --git a/build/bazelutil/staticcheckanalyzers/def.bzl b/build/bazelutil/staticcheckanalyzers/def.bzl index 5c0201144b5e..ff33ac1d628f 100644 --- a/build/bazelutil/staticcheckanalyzers/def.bzl +++ b/build/bazelutil/staticcheckanalyzers/def.bzl @@ -97,6 +97,10 @@ STATICCHECK_CHECKS = [ "//build/bazelutil/staticcheckanalyzers/sa4025", "//build/bazelutil/staticcheckanalyzers/sa4026", "//build/bazelutil/staticcheckanalyzers/sa4027", + "//build/bazelutil/staticcheckanalyzers/sa4028", + "//build/bazelutil/staticcheckanalyzers/sa4029", + "//build/bazelutil/staticcheckanalyzers/sa4030", + "//build/bazelutil/staticcheckanalyzers/sa4031", "//build/bazelutil/staticcheckanalyzers/sa5000", "//build/bazelutil/staticcheckanalyzers/sa5001", "//build/bazelutil/staticcheckanalyzers/sa5002", @@ -120,6 +124,8 @@ STATICCHECK_CHECKS = [ "//build/bazelutil/staticcheckanalyzers/sa9004", "//build/bazelutil/staticcheckanalyzers/sa9005", "//build/bazelutil/staticcheckanalyzers/sa9006", + "//build/bazelutil/staticcheckanalyzers/sa9007", + "//build/bazelutil/staticcheckanalyzers/sa9008", "//build/bazelutil/staticcheckanalyzers/st1000", "//build/bazelutil/staticcheckanalyzers/st1001", "//build/bazelutil/staticcheckanalyzers/st1003", diff --git a/build/bazelutil/staticcheckanalyzers/sa4028/BUILD.bazel b/build/bazelutil/staticcheckanalyzers/sa4028/BUILD.bazel new file mode 100644 index 000000000000..328f6266fbba --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4028/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "sa4028", + srcs = ["analyzer.go"], + importpath = "github.com/cockroachdb/cockroach/build/bazelutil/staticcheckanalyzers/sa4028", + visibility = ["//visibility:public"], + deps = [ + "//pkg/testutils/lint/passes/staticcheck", + "@co_honnef_go_tools//staticcheck", + "@org_golang_x_tools//go/analysis", + ], +) diff --git a/build/bazelutil/staticcheckanalyzers/sa4028/analyzer.go b/build/bazelutil/staticcheckanalyzers/sa4028/analyzer.go new file mode 100644 index 000000000000..bf5d176349e3 --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4028/analyzer.go @@ -0,0 +1,24 @@ +// Code generated by generate-staticcheck; DO NOT EDIT. + +//go:build bazel +// +build bazel + +package sa4028 + +import ( + util "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/staticcheck" + "golang.org/x/tools/go/analysis" + "honnef.co/go/tools/staticcheck" +) + +var Analyzer *analysis.Analyzer + +func init() { + for _, analyzer := range staticcheck.Analyzers { + if analyzer.Analyzer.Name == "SA4028" { + Analyzer = analyzer.Analyzer + break + } + } + util.MungeAnalyzer(Analyzer) +} diff --git a/build/bazelutil/staticcheckanalyzers/sa4029/BUILD.bazel b/build/bazelutil/staticcheckanalyzers/sa4029/BUILD.bazel new file mode 100644 index 000000000000..a545dd018f31 --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4029/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "sa4029", + srcs = ["analyzer.go"], + importpath = "github.com/cockroachdb/cockroach/build/bazelutil/staticcheckanalyzers/sa4029", + visibility = ["//visibility:public"], + deps = [ + "//pkg/testutils/lint/passes/staticcheck", + "@co_honnef_go_tools//staticcheck", + "@org_golang_x_tools//go/analysis", + ], +) diff --git a/build/bazelutil/staticcheckanalyzers/sa4029/analyzer.go b/build/bazelutil/staticcheckanalyzers/sa4029/analyzer.go new file mode 100644 index 000000000000..6e54f99e5a80 --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4029/analyzer.go @@ -0,0 +1,24 @@ +// Code generated by generate-staticcheck; DO NOT EDIT. + +//go:build bazel +// +build bazel + +package sa4029 + +import ( + util "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/staticcheck" + "golang.org/x/tools/go/analysis" + "honnef.co/go/tools/staticcheck" +) + +var Analyzer *analysis.Analyzer + +func init() { + for _, analyzer := range staticcheck.Analyzers { + if analyzer.Analyzer.Name == "SA4029" { + Analyzer = analyzer.Analyzer + break + } + } + util.MungeAnalyzer(Analyzer) +} diff --git a/build/bazelutil/staticcheckanalyzers/sa4030/BUILD.bazel b/build/bazelutil/staticcheckanalyzers/sa4030/BUILD.bazel new file mode 100644 index 000000000000..112472cd2f7c --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4030/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "sa4030", + srcs = ["analyzer.go"], + importpath = "github.com/cockroachdb/cockroach/build/bazelutil/staticcheckanalyzers/sa4030", + visibility = ["//visibility:public"], + deps = [ + "//pkg/testutils/lint/passes/staticcheck", + "@co_honnef_go_tools//staticcheck", + "@org_golang_x_tools//go/analysis", + ], +) diff --git a/build/bazelutil/staticcheckanalyzers/sa4030/analyzer.go b/build/bazelutil/staticcheckanalyzers/sa4030/analyzer.go new file mode 100644 index 000000000000..7378d2f504fa --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4030/analyzer.go @@ -0,0 +1,24 @@ +// Code generated by generate-staticcheck; DO NOT EDIT. + +//go:build bazel +// +build bazel + +package sa4030 + +import ( + util "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/staticcheck" + "golang.org/x/tools/go/analysis" + "honnef.co/go/tools/staticcheck" +) + +var Analyzer *analysis.Analyzer + +func init() { + for _, analyzer := range staticcheck.Analyzers { + if analyzer.Analyzer.Name == "SA4030" { + Analyzer = analyzer.Analyzer + break + } + } + util.MungeAnalyzer(Analyzer) +} diff --git a/build/bazelutil/staticcheckanalyzers/sa4031/BUILD.bazel b/build/bazelutil/staticcheckanalyzers/sa4031/BUILD.bazel new file mode 100644 index 000000000000..fb5d58317dd2 --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4031/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "sa4031", + srcs = ["analyzer.go"], + importpath = "github.com/cockroachdb/cockroach/build/bazelutil/staticcheckanalyzers/sa4031", + visibility = ["//visibility:public"], + deps = [ + "//pkg/testutils/lint/passes/staticcheck", + "@co_honnef_go_tools//staticcheck", + "@org_golang_x_tools//go/analysis", + ], +) diff --git a/build/bazelutil/staticcheckanalyzers/sa4031/analyzer.go b/build/bazelutil/staticcheckanalyzers/sa4031/analyzer.go new file mode 100644 index 000000000000..02ff4c15241f --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa4031/analyzer.go @@ -0,0 +1,24 @@ +// Code generated by generate-staticcheck; DO NOT EDIT. + +//go:build bazel +// +build bazel + +package sa4031 + +import ( + util "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/staticcheck" + "golang.org/x/tools/go/analysis" + "honnef.co/go/tools/staticcheck" +) + +var Analyzer *analysis.Analyzer + +func init() { + for _, analyzer := range staticcheck.Analyzers { + if analyzer.Analyzer.Name == "SA4031" { + Analyzer = analyzer.Analyzer + break + } + } + util.MungeAnalyzer(Analyzer) +} diff --git a/build/bazelutil/staticcheckanalyzers/sa9007/BUILD.bazel b/build/bazelutil/staticcheckanalyzers/sa9007/BUILD.bazel new file mode 100644 index 000000000000..cab7a454e851 --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa9007/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "sa9007", + srcs = ["analyzer.go"], + importpath = "github.com/cockroachdb/cockroach/build/bazelutil/staticcheckanalyzers/sa9007", + visibility = ["//visibility:public"], + deps = [ + "//pkg/testutils/lint/passes/staticcheck", + "@co_honnef_go_tools//staticcheck", + "@org_golang_x_tools//go/analysis", + ], +) diff --git a/build/bazelutil/staticcheckanalyzers/sa9007/analyzer.go b/build/bazelutil/staticcheckanalyzers/sa9007/analyzer.go new file mode 100644 index 000000000000..9c9a9483019b --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa9007/analyzer.go @@ -0,0 +1,24 @@ +// Code generated by generate-staticcheck; DO NOT EDIT. + +//go:build bazel +// +build bazel + +package sa9007 + +import ( + util "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/staticcheck" + "golang.org/x/tools/go/analysis" + "honnef.co/go/tools/staticcheck" +) + +var Analyzer *analysis.Analyzer + +func init() { + for _, analyzer := range staticcheck.Analyzers { + if analyzer.Analyzer.Name == "SA9007" { + Analyzer = analyzer.Analyzer + break + } + } + util.MungeAnalyzer(Analyzer) +} diff --git a/build/bazelutil/staticcheckanalyzers/sa9008/BUILD.bazel b/build/bazelutil/staticcheckanalyzers/sa9008/BUILD.bazel new file mode 100644 index 000000000000..f4aa63bb1916 --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa9008/BUILD.bazel @@ -0,0 +1,13 @@ +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "sa9008", + srcs = ["analyzer.go"], + importpath = "github.com/cockroachdb/cockroach/build/bazelutil/staticcheckanalyzers/sa9008", + visibility = ["//visibility:public"], + deps = [ + "//pkg/testutils/lint/passes/staticcheck", + "@co_honnef_go_tools//staticcheck", + "@org_golang_x_tools//go/analysis", + ], +) diff --git a/build/bazelutil/staticcheckanalyzers/sa9008/analyzer.go b/build/bazelutil/staticcheckanalyzers/sa9008/analyzer.go new file mode 100644 index 000000000000..ee4df1ea049b --- /dev/null +++ b/build/bazelutil/staticcheckanalyzers/sa9008/analyzer.go @@ -0,0 +1,24 @@ +// Code generated by generate-staticcheck; DO NOT EDIT. + +//go:build bazel +// +build bazel + +package sa9008 + +import ( + util "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/staticcheck" + "golang.org/x/tools/go/analysis" + "honnef.co/go/tools/staticcheck" +) + +var Analyzer *analysis.Analyzer + +func init() { + for _, analyzer := range staticcheck.Analyzers { + if analyzer.Analyzer.Name == "SA9008" { + Analyzer = analyzer.Analyzer + break + } + } + util.MungeAnalyzer(Analyzer) +} diff --git a/build/bootstrap/bootstrap-debian.sh b/build/bootstrap/bootstrap-debian.sh index 7d611c7d9ddd..ddcc9f28f1ef 100755 --- a/build/bootstrap/bootstrap-debian.sh +++ b/build/bootstrap/bootstrap-debian.sh @@ -46,9 +46,9 @@ sudo tar -C /usr --strip-components=1 -zxf /tmp/cmake.tgz && rm /tmp/cmake.tgz # Install Go. trap 'rm -f /tmp/go.tgz' EXIT -curl -fsSL https://dl.google.com/go/go1.17.11.linux-amd64.tar.gz > /tmp/go.tgz +curl -fsSL https://dl.google.com/go/go1.18.4.linux-amd64.tar.gz > /tmp/go.tgz sha256sum -c - < /tmp/go.tgz +curl -fsSL https://dl.google.com/go/go1.18.4.linux-amd64.tar.gz > /tmp/go.tgz sha256sum -c - < /tmp/go.tgz`, + ctx, t, c, node, "download go", `curl -fsSL https://dl.google.com/go/go1.18.4.linux-amd64.tar.gz > /tmp/go.tgz`, ); err != nil { t.Fatal(err) } if err := repeatRunE( ctx, t, c, node, "verify tarball", `sha256sum -c - < 0 { return nil, false } diff --git a/pkg/sql/parser/BUILD.bazel b/pkg/sql/parser/BUILD.bazel index 0d4833dfdc27..e1c54c530455 100644 --- a/pkg/sql/parser/BUILD.bazel +++ b/pkg/sql/parser/BUILD.bazel @@ -38,6 +38,8 @@ go_library( "//pkg/util/errorutil/unimplemented", "@com_github_cockroachdb_errors//:errors", "@com_github_lib_pq//oid", # keep + "@org_golang_x_text//cases", + "@org_golang_x_text//language", ], ) diff --git a/pkg/sql/parser/help.go b/pkg/sql/parser/help.go index 39a1e27b8f88..efff558507a0 100644 --- a/pkg/sql/parser/help.go +++ b/pkg/sql/parser/help.go @@ -23,6 +23,8 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/errors" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // HelpMessage describes a contextual help message. @@ -233,7 +235,7 @@ var AllHelp = func(h map[string]HelpMessageBody) string { var buf bytes.Buffer w := tabwriter.NewWriter(&buf, 0, 0, 1, ' ', 0) for _, cat := range categories { - fmt.Fprintf(w, "%s:\n", strings.Title(cat)) + fmt.Fprintf(w, "%s:\n", cases.Title(language.English, cases.NoLower).String(cat)) for _, item := range cmds[cat] { fmt.Fprintf(w, "\t\t%s\t%s\n", item, h[item].ShortDescription) } diff --git a/pkg/sql/sem/builtins/BUILD.bazel b/pkg/sql/sem/builtins/BUILD.bazel index 3b4a58474dc3..0bece5759689 100644 --- a/pkg/sql/sem/builtins/BUILD.bazel +++ b/pkg/sql/sem/builtins/BUILD.bazel @@ -121,6 +121,8 @@ go_library( "@com_github_twpayne_go_geom//:go-geom", "@com_github_twpayne_go_geom//encoding/ewkb", "@org_golang_x_crypto//bcrypt", + "@org_golang_x_text//cases", + "@org_golang_x_text//language", ], ) diff --git a/pkg/sql/sem/builtins/builtins.go b/pkg/sql/sem/builtins/builtins.go index 31ee2b326d9e..08b23fcf4b3f 100644 --- a/pkg/sql/sem/builtins/builtins.go +++ b/pkg/sql/sem/builtins/builtins.go @@ -94,6 +94,8 @@ import ( "github.com/cockroachdb/cockroach/pkg/util/uuid" "github.com/cockroachdb/errors" "github.com/knz/strtime" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) var ( @@ -1924,7 +1926,7 @@ var regularBuiltins = map[string]builtinDefinition{ "initcap": makeBuiltin(defProps(), stringOverload1( func(evalCtx *eval.Context, s string) (tree.Datum, error) { - return tree.NewDString(strings.Title(strings.ToLower(s))), nil + return tree.NewDString(cases.Title(language.English, cases.NoLower).String(strings.ToLower(s))), nil }, types.String, "Capitalizes the first letter of `val`.", diff --git a/pkg/sql/sem/builtins/generator_builtins.go b/pkg/sql/sem/builtins/generator_builtins.go index a5f01585ae55..38bb7e3ca833 100644 --- a/pkg/sql/sem/builtins/generator_builtins.go +++ b/pkg/sql/sem/builtins/generator_builtins.go @@ -1657,9 +1657,7 @@ func (j *jsonPopulateRecordSetGenerator) Values() (tree.Datums, error) { return nil, pgerror.Newf(pgcode.InvalidParameterValue, "argument of json_populate_recordset must be an array of objects") } output := tree.NewDTupleWithLen(j.input.ResolvedType(), j.input.D.Len()) - for i := range j.input.D { - output.D[i] = j.input.D[i] - } + copy(output.D, j.input.D) if err := eval.PopulateRecordWithJSON(j.evalCtx, obj, j.input.ResolvedType(), output); err != nil { return nil, err } diff --git a/pkg/sql/sem/tree/overload.go b/pkg/sql/sem/tree/overload.go index 7f692058cd6c..46b1455120de 100644 --- a/pkg/sql/sem/tree/overload.go +++ b/pkg/sql/sem/tree/overload.go @@ -447,9 +447,7 @@ func (v VariadicType) Length() int { // Types is part of the TypeList interface. func (v VariadicType) Types() []*types.T { result := make([]*types.T, len(v.FixedTypes)+1) - for i := range v.FixedTypes { - result[i] = v.FixedTypes[i] - } + copy(result, v.FixedTypes) result[len(result)-1] = v.VarType return result } diff --git a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel index 9f42ab117d67..7ca657193755 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel +++ b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/BUILD.bazel @@ -21,6 +21,8 @@ go_library( "@com_github_cockroachdb_apd_v3//:apd", "@com_github_cockroachdb_errors//:errors", "@com_github_stretchr_testify//require", + "@org_golang_x_text//cases", + "@org_golang_x_text//language", ], ) diff --git a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_encoding.go b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_encoding.go index 3594758bfabd..6e39a812ee05 100644 --- a/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_encoding.go +++ b/pkg/sql/sqlstats/persistedsqlstats/sqlstatsutil/json_encoding.go @@ -12,11 +12,12 @@ package sqlstatsutil import ( "encoding/hex" - "strings" "github.com/cockroachdb/cockroach/pkg/roachpb" "github.com/cockroachdb/cockroach/pkg/util/encoding" "github.com/cockroachdb/cockroach/pkg/util/json" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // ExplainTreePlanNodeToJSON builds a formatted JSON object from the explain tree nodes. @@ -30,7 +31,7 @@ func ExplainTreePlanNodeToJSON(node *roachpb.ExplainTreePlanNode) json.JSON { nodePlan.Add("Name", json.FromString(node.Name)) for _, attr := range node.Attrs { - nodePlan.Add(strings.Title(attr.Key), json.FromString(attr.Value)) + nodePlan.Add(cases.Title(language.English, cases.NoLower).String(attr.Key), json.FromString(attr.Value)) } for _, childNode := range node.Children { diff --git a/pkg/testutils/lint/lint_test.go b/pkg/testutils/lint/lint_test.go index b40606c973bf..0a0aede2da68 100644 --- a/pkg/testutils/lint/lint_test.go +++ b/pkg/testutils/lint/lint_test.go @@ -1755,9 +1755,9 @@ func TestLint(t *testing.T) { // Using deprecated WireLength call. stream.GrepNot(`pkg/rpc/stats_handler.go:.*v.WireLength is deprecated: This field is never set.*`), // roachpb/api.go needs v1 Protobuf reflection - stream.GrepNot(`pkg/roachpb/api_test.go:.*package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.`), + stream.GrepNot(`pkg/roachpb/api_test.go:.*"github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.`), // rpc/codec.go imports the same proto package that grpc-go imports (as of crdb@dd87d1145 and grpc-go@7b167fd6). - stream.GrepNot(`pkg/rpc/codec.go:.*package github.com/golang/protobuf/proto is deprecated: Use the "google.golang.org/protobuf/proto" package instead.`), + stream.GrepNot(`pkg/rpc/codec.go:.*"github.com/golang/protobuf/proto" is deprecated: Use the "google.golang.org/protobuf/proto" package instead.`), // goschedstats contains partial copies of go runtime structures, with // many fields that we're not using. stream.GrepNot(`pkg/util/goschedstats/runtime.*\.go:.*is unused`), diff --git a/pkg/testutils/lint/passes/fmtsafe/BUILD.bazel b/pkg/testutils/lint/passes/fmtsafe/BUILD.bazel index 54621df58e75..40033f707847 100644 --- a/pkg/testutils/lint/passes/fmtsafe/BUILD.bazel +++ b/pkg/testutils/lint/passes/fmtsafe/BUILD.bazel @@ -13,6 +13,8 @@ go_library( "//pkg/testutils/lint/passes/errwrap", "//pkg/util/log/logpb", "@com_github_cockroachdb_errors//:errors", + "@org_golang_x_text//cases", + "@org_golang_x_text//language", "@org_golang_x_tools//go/analysis", "@org_golang_x_tools//go/analysis/passes/inspect", "@org_golang_x_tools//go/ast/inspector", diff --git a/pkg/testutils/lint/passes/fmtsafe/functions.go b/pkg/testutils/lint/passes/fmtsafe/functions.go index 6e205334bcbf..d5f8a0e52407 100644 --- a/pkg/testutils/lint/passes/fmtsafe/functions.go +++ b/pkg/testutils/lint/passes/fmtsafe/functions.go @@ -15,6 +15,8 @@ import ( "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/errwrap" "github.com/cockroachdb/cockroach/pkg/util/log/logpb" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) // requireConstMsg records functions for which the last string @@ -135,9 +137,13 @@ var requireConstFmt = map[string]bool{ // Error things are populated in the init() message. } +func title(s string) string { + return cases.Title(language.English, cases.NoLower).String(s) +} + func init() { for _, sev := range logpb.Severity_name { - capsev := strings.Title(strings.ToLower(sev)) + capsev := title(strings.ToLower(sev)) // log.Infof, log.Warningf etc. requireConstFmt["github.com/cockroachdb/cockroach/pkg/util/log."+capsev+"f"] = true // log.VInfof, log.VWarningf etc. @@ -148,7 +154,7 @@ func init() { requireConstMsg["github.com/cockroachdb/cockroach/pkg/util/log."+capsev] = true for _, ch := range logpb.Channel_name { - capch := strings.ReplaceAll(strings.Title(strings.ReplaceAll(strings.ToLower(ch), "_", " ")), " ", "") + capch := strings.ReplaceAll(title(strings.ReplaceAll(strings.ToLower(ch), "_", " ")), " ", "") // log.Ops.Infof, log.Ops.Warningf, etc. requireConstFmt["(github.com/cockroachdb/cockroach/pkg/util/log.logger"+capch+")."+capsev+"f"] = true // log.Ops.VInfof, log.Ops.VWarningf, etc. @@ -160,7 +166,7 @@ func init() { } } for _, ch := range logpb.Channel_name { - capch := strings.ReplaceAll(strings.Title(strings.ReplaceAll(strings.ToLower(ch), "_", " ")), " ", "") + capch := strings.ReplaceAll(title(strings.ReplaceAll(strings.ToLower(ch), "_", " ")), " ", "") // log.Ops.Shoutf, log.Dev.Shoutf, etc. requireConstFmt["(github.com/cockroachdb/cockroach/pkg/util/log.logger"+capch+").Shoutf"] = true // log.Ops.Shout, log.Dev.Shout, etc. diff --git a/pkg/testutils/lint/passes/generics/BUILD.bazel b/pkg/testutils/lint/passes/generics/BUILD.bazel new file mode 100644 index 000000000000..e129ff9ca348 --- /dev/null +++ b/pkg/testutils/lint/passes/generics/BUILD.bazel @@ -0,0 +1,15 @@ +load("//build/bazelutil/unused_checker:unused.bzl", "get_x_data") +load("@io_bazel_rules_go//go:def.bzl", "go_library") + +go_library( + name = "generics", + srcs = ["generics.go"], + importpath = "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/generics", + visibility = ["//visibility:public"], + deps = [ + "@org_golang_x_tools//go/analysis", + "@org_golang_x_tools//go/analysis/passes/usesgenerics", + ], +) + +get_x_data(name = "get_x_data") diff --git a/pkg/testutils/lint/passes/generics/generics.go b/pkg/testutils/lint/passes/generics/generics.go new file mode 100644 index 000000000000..35689b3f5aaa --- /dev/null +++ b/pkg/testutils/lint/passes/generics/generics.go @@ -0,0 +1,42 @@ +// Copyright 2018 The Go Authors. All rights reserved. +// Use of this source code is governed by a BSD-style +// license that can be found in the LICENSE file. + +// Portions of this file are additionally subject to the following +// license and copyright. +// +// Copyright 2021 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. + +// Package generics reports an error if Go 1.18 generics are used. +package generics + +import ( + "golang.org/x/tools/go/analysis" + "golang.org/x/tools/go/analysis/passes/usesgenerics" +) + +// Analyzer is an analysis.Analyzer that reports uses of go 1.18 generics. +var Analyzer = &analysis.Analyzer{ + Name: "generics", + Doc: `report an error if generics are used`, + Run: run, + Requires: []*analysis.Analyzer{usesgenerics.Analyzer}, +} + +func run(pass *analysis.Pass) (interface{}, error) { + features := pass.ResultOf[usesgenerics.Analyzer].(*usesgenerics.Result).Direct + if features != 0 { + pass.Report(analysis.Diagnostic{ + Message: "generics are disallowed in CRDB source code", + }) + } + return nil, nil +} diff --git a/pkg/testutils/lint/passes/staticcheck/BUILD.bazel b/pkg/testutils/lint/passes/staticcheck/BUILD.bazel index 8678a200293e..cb6d6bb1506b 100644 --- a/pkg/testutils/lint/passes/staticcheck/BUILD.bazel +++ b/pkg/testutils/lint/passes/staticcheck/BUILD.bazel @@ -7,7 +7,7 @@ go_library( importpath = "github.com/cockroachdb/cockroach/pkg/testutils/lint/passes/staticcheck", visibility = ["//visibility:public"], deps = [ - "@co_honnef_go_tools//analysis/facts", + "@co_honnef_go_tools//analysis/facts/directives", "@co_honnef_go_tools//analysis/lint", "@co_honnef_go_tools//analysis/report", "@org_golang_x_tools//go/analysis", diff --git a/pkg/testutils/lint/passes/staticcheck/staticcheck.go b/pkg/testutils/lint/passes/staticcheck/staticcheck.go index 3cdc69412e72..2ed0a122cb46 100644 --- a/pkg/testutils/lint/passes/staticcheck/staticcheck.go +++ b/pkg/testutils/lint/passes/staticcheck/staticcheck.go @@ -16,7 +16,7 @@ import ( "strings" "golang.org/x/tools/go/analysis" - "honnef.co/go/tools/analysis/facts" + "honnef.co/go/tools/analysis/facts/directives" "honnef.co/go/tools/analysis/lint" "honnef.co/go/tools/analysis/report" ) @@ -25,19 +25,19 @@ import ( // The staticcheck analyzers don't look at "lint:ignore" directives, so if you // integrate them into `nogo` unchanged, you'll get spurious build failures for // issues that are actually explicitly ignored. So for each staticcheck analyzer -// we add `facts.Directives` to the list of dependencies, then cross-check +// we add `directives.Analyzer` to the list of dependencies, then cross-check // each reported diagnostic to make sure it's not ignored before allowing it // through. func MungeAnalyzer(analyzer *analysis.Analyzer) { // Add facts.directives to the list of dependencies for this analyzer. analyzer.Requires = analyzer.Requires[0:len(analyzer.Requires):len(analyzer.Requires)] - analyzer.Requires = append(analyzer.Requires, facts.Directives) + analyzer.Requires = append(analyzer.Requires, directives.Analyzer) oldRun := analyzer.Run analyzer.Run = func(p *analysis.Pass) (interface{}, error) { pass := *p oldReport := p.Report pass.Report = func(diag analysis.Diagnostic) { - dirs := pass.ResultOf[facts.Directives].([]lint.Directive) + dirs := pass.ResultOf[directives.Analyzer].([]lint.Directive) for _, dir := range dirs { cmd := dir.Command args := dir.Arguments diff --git a/pkg/util/contextutil/context_test.go b/pkg/util/contextutil/context_test.go index 35b89803d5b6..f313f8f540df 100644 --- a/pkg/util/contextutil/context_test.go +++ b/pkg/util/contextutil/context_test.go @@ -43,6 +43,7 @@ func TestRunWithTimeout(t *testing.T) { if !errors.As(err, &netError) { t.Fatal("RunWithTimeout should return a net.Error") } + //lint:ignore SA1019 grandfathered test code if !netError.Timeout() || !netError.Temporary() { t.Fatal("RunWithTimeout should return a timeout and temporary error") } @@ -60,6 +61,7 @@ func TestRunWithTimeout(t *testing.T) { if !errors.As(err, &netError) { t.Fatal("RunWithTimeout should return a net.Error") } + //lint:ignore SA1019 grandfathered test code if !netError.Timeout() || !netError.Temporary() { t.Fatal("RunWithTimeout should return a timeout and temporary error") } @@ -84,6 +86,7 @@ func TestRunWithTimeoutWithoutDeadlineExceeded(t *testing.T) { if !errors.As(err, &netError) { t.Fatal("RunWithTimeout should return a net.Error") } + //lint:ignore SA1019 grandfathered test code if !netError.Timeout() || !netError.Temporary() { t.Fatal("RunWithTimeout should return a timeout and temporary error") } diff --git a/pkg/util/goschedstats/BUILD.bazel b/pkg/util/goschedstats/BUILD.bazel index 3ecbd4fbacad..5dff3daed762 100644 --- a/pkg/util/goschedstats/BUILD.bazel +++ b/pkg/util/goschedstats/BUILD.bazel @@ -5,9 +5,7 @@ go_library( name = "goschedstats", srcs = [ "runnable.go", - "runtime_deferpool_go1.17.go", - "runtime_deferpool_go1.18.go", - "runtime_go1.17.go", + "runtime_go1.18.go", ], importpath = "github.com/cockroachdb/cockroach/pkg/util/goschedstats", visibility = ["//visibility:public"], diff --git a/pkg/util/goschedstats/runnable.go b/pkg/util/goschedstats/runnable.go index b8c389e9ac9a..3f1a60fed778 100644 --- a/pkg/util/goschedstats/runnable.go +++ b/pkg/util/goschedstats/runnable.go @@ -48,7 +48,7 @@ func RecentNormalizedRunnableGoroutines() float64 { } // If you get a compilation error here, the Go version you are using is not -// supported by this package. Cross-check the structures in runtime_go1.17.go +// supported by this package. Cross-check the structures in runtime_go1.18.go // against those in the new Go's runtime, and if they are still accurate adjust // the build tag in that file to accept the version. If they don't match, you // will have to add a new version of that file. diff --git a/pkg/util/goschedstats/runtime_deferpool_go1.17.go b/pkg/util/goschedstats/runtime_deferpool_go1.17.go deleted file mode 100644 index 3e831716c00e..000000000000 --- a/pkg/util/goschedstats/runtime_deferpool_go1.17.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 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. - -//go:build gc && go1.17 && !go1.18 -// +build gc,go1.17,!go1.18 - -package goschedstats - -type deferpool struct { - deferpool [5][]uintptr // pool of available defer structs of different sizes (see panic.go) - deferpoolbuf [5][32]uintptr -} diff --git a/pkg/util/goschedstats/runtime_deferpool_go1.18.go b/pkg/util/goschedstats/runtime_deferpool_go1.18.go deleted file mode 100644 index d52affd1c3b2..000000000000 --- a/pkg/util/goschedstats/runtime_deferpool_go1.18.go +++ /dev/null @@ -1,19 +0,0 @@ -// Copyright 2022 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. - -//go:build gc && go1.18 -// +build gc,go1.18 - -package goschedstats - -type deferpool struct { - deferpool []uintptr // pool of available defer structs (see panic.go) - deferpoolbuf [32]uintptr -} diff --git a/pkg/util/goschedstats/runtime_go1.17.go b/pkg/util/goschedstats/runtime_go1.18.go similarity index 91% rename from pkg/util/goschedstats/runtime_go1.17.go rename to pkg/util/goschedstats/runtime_go1.18.go index 9ae8794030f5..e8724d81cac2 100644 --- a/pkg/util/goschedstats/runtime_go1.17.go +++ b/pkg/util/goschedstats/runtime_go1.18.go @@ -8,12 +8,12 @@ // by the Apache License, Version 2.0, included in the file // licenses/APL.txt. // -// The structure definitions in this file have been cross-checked against go1.17 -// and go1.18. Before allowing newer versions, please check that the structures +// The structure definitions in this file have been cross-checked against go1.18. +// Before allowing newer versions, please check that the structures // still match with those in go/src/runtime. -//go:build gc && go1.17 && !go1.19 -// +build gc,go1.17,!go1.19 +//go:build gc && go1.18 && !go1.19 +// +build gc,go1.18,!go1.19 package goschedstats @@ -53,10 +53,8 @@ type p struct { pcache pageCache raceprocctx uintptr - // NOTE: the runtime does not have a deferpool struct type. We use one here to - // conditionally configure the size of these fields based on the go version. - // See runtime_deferpool_go1.17.go and runtime_deferpool_go1.18.go. - deferpool deferpool + deferpool []uintptr // pool of available defer structs (see panic.go) + deferpoolbuf [32]uintptr // Cache of goroutine ids, amortizes accesses to runtime·sched.goidgen. goidcache uint64 diff --git a/pkg/util/json/json.go b/pkg/util/json/json.go index b0aff4f817ca..3452271edd7a 100644 --- a/pkg/util/json/json.go +++ b/pkg/util/json/json.go @@ -2085,12 +2085,8 @@ func (j jsonObject) RemoveString(s string) (JSON, bool, error) { } newVal := make([]jsonKeyValuePair, len(j)-1) - for i, elem := range j[:idx] { - newVal[i] = elem - } - for i, elem := range j[idx+1:] { - newVal[idx+i] = elem - } + copy(newVal, j[:idx]) + copy(newVal[idx:], j[idx+1:]) return jsonObject(newVal), true, nil } diff --git a/pkg/util/json/json_test.go b/pkg/util/json/json_test.go index 784a910c3208..3ff59ce59356 100644 --- a/pkg/util/json/json_test.go +++ b/pkg/util/json/json_test.go @@ -2147,10 +2147,10 @@ func TestPositiveRandomJSONContains(t *testing.T) { t.Fatal(err) } if !c { - t.Fatal(fmt.Sprintf("%s should contain %s", j, subdoc)) + t.Fatalf("%s should contain %s", j, subdoc) } if !slowContains(j, subdoc) { - t.Fatal(fmt.Sprintf("%s should slowContains %s", j, subdoc)) + t.Fatalf("%s should slowContains %s", j, subdoc) } } } diff --git a/pkg/util/log/gen/BUILD.bazel b/pkg/util/log/gen/BUILD.bazel index 1ee32e814850..6ff9d8a1369b 100644 --- a/pkg/util/log/gen/BUILD.bazel +++ b/pkg/util/log/gen/BUILD.bazel @@ -10,6 +10,8 @@ go_library( "//pkg/cli/exit", "@com_github_cockroachdb_errors//:errors", "@com_github_cockroachdb_gostdlib//go/format", + "@org_golang_x_text//cases", + "@org_golang_x_text//language", ], ) diff --git a/pkg/util/log/gen/main.go b/pkg/util/log/gen/main.go index 79a4ec381aab..46b4521a9cf4 100644 --- a/pkg/util/log/gen/main.go +++ b/pkg/util/log/gen/main.go @@ -21,6 +21,8 @@ import ( "github.com/cockroachdb/cockroach/pkg/cli/exit" "github.com/cockroachdb/errors" "github.com/cockroachdb/gostdlib/go/format" + "golang.org/x/text/cases" + "golang.org/x/text/language" ) func main() { @@ -137,7 +139,8 @@ func readInput(protoName string) (chans []info, sevs []info, err error) { continue } key := strings.Split(line, " ")[0] - title := strings.ReplaceAll(strings.Title(strings.ReplaceAll(strings.ToLower(key), "_", " ")), " ", "") + title := strings.ReplaceAll(cases.Title(language.English, cases.NoLower).String( + strings.ReplaceAll(strings.ToLower(key), "_", " ")), " ", "") if inSevs { comment := "// The `" + key + "` severity" + strings.TrimPrefix(rawComment, "// "+key) sevs = append(sevs, info{ diff --git a/pkg/util/netutil/net.go b/pkg/util/netutil/net.go index 0fd575ae5a3e..da50a61a3dc4 100644 --- a/pkg/util/netutil/net.go +++ b/pkg/util/netutil/net.go @@ -137,6 +137,7 @@ func (s *Server) ServeWith( for { rw, e := l.Accept() if e != nil { + //lint:ignore SA1019 see discussion at https://github.com/cockroachdb/cockroach/pull/84590#issuecomment-1192709976 if ne := (net.Error)(nil); errors.As(e, &ne) && ne.Temporary() { if tempDelay == 0 { tempDelay = 5 * time.Millisecond @@ -170,6 +171,7 @@ func (s *Server) ServeWith( // cmux.ErrListenerClosed, grpc.ErrServerStopped, io.EOF, or net.ErrClosed. func IsClosedConnection(err error) bool { if netError := net.Error(nil); errors.As(err, &netError) { + //lint:ignore SA1019 see discussion at https://github.com/cockroachdb/cockroach/pull/84590#issuecomment-1192709976 return !netError.Temporary() } return errors.IsAny(err, cmux.ErrListenerClosed, grpc.ErrServerStopped, io.EOF, net.ErrClosed) || diff --git a/pkg/util/timeutil/lowercase_timezones_generated.go b/pkg/util/timeutil/lowercase_timezones_generated.go index a47e32063c98..9bc112e08651 100644 --- a/pkg/util/timeutil/lowercase_timezones_generated.go +++ b/pkg/util/timeutil/lowercase_timezones_generated.go @@ -557,6 +557,7 @@ var lowercaseTimezones = map[string]string{ `pacific/guam`: `Pacific/Guam`, `pacific/honolulu`: `Pacific/Honolulu`, `pacific/johnston`: `Pacific/Johnston`, + `pacific/kanton`: `Pacific/Kanton`, `pacific/kiritimati`: `Pacific/Kiritimati`, `pacific/kosrae`: `Pacific/Kosrae`, `pacific/kwajalein`: `Pacific/Kwajalein`, diff --git a/pkg/util/ulid/ulid_test.go b/pkg/util/ulid/ulid_test.go index b94c8018df17..80a4da9ef5c0 100644 --- a/pkg/util/ulid/ulid_test.go +++ b/pkg/util/ulid/ulid_test.go @@ -618,8 +618,7 @@ func TestMonotonicSafe(t *testing.T) { errs := make(chan error, 100) for i := 0; i < cap(errs); i++ { go func() { - u0 := ulid.MustNew(t0, safe) - u1 := ulid.MustNew(t0, safe) + var u0, u1 ulid.ULID for j := 0; j < 1024; j++ { u0, u1 = u1, ulid.MustNew(t0, safe) if u0.String() >= u1.String() { diff --git a/vendor b/vendor index 5753cedfc16e..9e78f64502a1 160000 --- a/vendor +++ b/vendor @@ -1 +1 @@ -Subproject commit 5753cedfc16eae20273341209daced05099be5fd +Subproject commit 9e78f64502a1f579a5beb5ced86ca0e270fe6b78 From b13876956e6913db92114dec7774dd9c3512520b Mon Sep 17 00:00:00 2001 From: Marcus Gartner Date: Wed, 20 Jul 2022 10:31:01 -0400 Subject: [PATCH 5/7] opt: set opt tester search path to empty `OptTester` now sets its `SemaContext`'s `SearchPath` to `EmptySearchPath`, instead of `nil`, to avoid nil pointer exceptions when resolving unknown functions. Release note: None --- pkg/sql/opt/optbuilder/testdata/udf | 4 ++++ pkg/sql/opt/testutils/opttester/opt_tester.go | 1 + 2 files changed, 5 insertions(+) create mode 100644 pkg/sql/opt/optbuilder/testdata/udf diff --git a/pkg/sql/opt/optbuilder/testdata/udf b/pkg/sql/opt/optbuilder/testdata/udf new file mode 100644 index 000000000000..7d3ca7b03f86 --- /dev/null +++ b/pkg/sql/opt/optbuilder/testdata/udf @@ -0,0 +1,4 @@ +build +SELECT foo() +---- +error (42883): unknown function: foo() diff --git a/pkg/sql/opt/testutils/opttester/opt_tester.go b/pkg/sql/opt/testutils/opttester/opt_tester.go index c9af74dd8d31..9fec4efa2ce4 100644 --- a/pkg/sql/opt/testutils/opttester/opt_tester.go +++ b/pkg/sql/opt/testutils/opttester/opt_tester.go @@ -274,6 +274,7 @@ func New(catalog cat.Catalog, sql string) *OptTester { semaCtx: tree.MakeSemaContext(), evalCtx: eval.MakeTestingEvalContext(cluster.MakeTestingClusterSettings()), } + ot.semaCtx.SearchPath = tree.EmptySearchPath ot.semaCtx.FunctionResolver = ot.catalog // To allow opttester tests to use now(), we hardcode a preset transaction // time. May 10, 2017 is a historic day: the release date of CockroachDB 1.0. From 71c8e32f3a5e90e047b54b2b9a866a3c9a574a47 Mon Sep 17 00:00:00 2001 From: Marcus Gartner Date: Wed, 20 Jul 2022 12:09:22 -0400 Subject: [PATCH 6/7] opt: build UDF expressions This commit adds basic support for building UDFs in optbuilder. Only scalar, nullary (arity of zero) functions with a single statement in the body are supported. Support for more types of UDFs will follow in future commits. Note that this commit does not add support for execution of UDFs, only building them within an optimizer expression. Release note: None --- pkg/sql/opt/memo/expr_format.go | 3 ++ pkg/sql/opt/norm/decorrelate_funcs.go | 4 ++ pkg/sql/opt/norm/testdata/rules/udf | 21 +++++++++ pkg/sql/opt/ops/scalar.opt | 15 ++++++ pkg/sql/opt/optbuilder/scalar.go | 34 ++++++++++++++ pkg/sql/opt/optbuilder/testdata/udf | 66 ++++++++++++++++++++++++++- 6 files changed, 142 insertions(+), 1 deletion(-) create mode 100644 pkg/sql/opt/norm/testdata/rules/udf diff --git a/pkg/sql/opt/memo/expr_format.go b/pkg/sql/opt/memo/expr_format.go index 578df2821779..66b89e3e9665 100644 --- a/pkg/sql/opt/memo/expr_format.go +++ b/pkg/sql/opt/memo/expr_format.go @@ -1512,6 +1512,9 @@ func FormatPrivate(f *ExprFmtCtx, private interface{}, physProps *physical.Requi case *FunctionPrivate: fmt.Fprintf(f.Buffer, " %s", t.Name) + case *UserDefinedFunctionPrivate: + fmt.Fprintf(f.Buffer, " %s", t.Name) + case *WindowsItemPrivate: fmt.Fprintf(f.Buffer, " frame=%q", &t.Frame) diff --git a/pkg/sql/opt/norm/decorrelate_funcs.go b/pkg/sql/opt/norm/decorrelate_funcs.go index 746aa48606c8..3701732275e4 100644 --- a/pkg/sql/opt/norm/decorrelate_funcs.go +++ b/pkg/sql/opt/norm/decorrelate_funcs.go @@ -62,6 +62,10 @@ func (c *CustomFuncs) deriveHasHoistableSubquery(scalar opt.ScalarExpr) bool { // WHERE clause, it will be transformed to an Exists operator, so this case // only occurs when the Any is nested, in a projection, etc. return !t.Input.Relational().OuterCols.Empty() + + case *memo.UserDefinedFunctionExpr: + // Do not attempt to hoist UDFs. + return false } // If HasHoistableSubquery is true for any child, then it's true for this diff --git a/pkg/sql/opt/norm/testdata/rules/udf b/pkg/sql/opt/norm/testdata/rules/udf new file mode 100644 index 000000000000..8548518c233b --- /dev/null +++ b/pkg/sql/opt/norm/testdata/rules/udf @@ -0,0 +1,21 @@ +exec-ddl +CREATE FUNCTION one() RETURNS INT LANGUAGE SQL AS 'SELECT 1'; +---- + +# Do not attempt to hoist UDFs. +norm +SELECT one() +---- +values + ├── columns: one:2 + ├── cardinality: [1 - 1] + ├── key: () + ├── fd: ()-->(2) + └── tuple + └── user-defined-function: one + └── values + ├── columns: "?column?":1!null + ├── cardinality: [1 - 1] + ├── key: () + ├── fd: ()-->(1) + └── (1,) diff --git a/pkg/sql/opt/ops/scalar.opt b/pkg/sql/opt/ops/scalar.opt index dcf85083cc5e..7abbc35d6c81 100644 --- a/pkg/sql/opt/ops/scalar.opt +++ b/pkg/sql/opt/ops/scalar.opt @@ -1214,6 +1214,21 @@ define NthValue { Nth ScalarExpr } +# UserDefinedFunction invokes a user-defined function. The +# UserDefinedFunctionPrivate field contains the name of the function and a +# pointer to its type. +[Scalar] +define UserDefinedFunction { + Body RelExpr + _ UserDefinedFunctionPrivate +} + +[Private] +define UserDefinedFunctionPrivate { + Name string + Typ Type +} + # KVOptions is a set of KVOptionItems that specify arbitrary keys and values # that are used as modifiers for various statements (see tree.KVOptions). The # key is a constant string but the value can be a scalar expression. diff --git a/pkg/sql/opt/optbuilder/scalar.go b/pkg/sql/opt/optbuilder/scalar.go index c6b50b81571f..41b8eb0bd115 100644 --- a/pkg/sql/opt/optbuilder/scalar.go +++ b/pkg/sql/opt/optbuilder/scalar.go @@ -21,6 +21,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/opt/cat" "github.com/cockroachdb/cockroach/pkg/sql/opt/memo" "github.com/cockroachdb/cockroach/pkg/sql/opt/norm" + "github.com/cockroachdb/cockroach/pkg/sql/parser" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgcode" "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/privilege" @@ -529,6 +530,10 @@ func (b *Builder) buildFunction( panic(err) } + if f.ResolvedOverload().Body != "" { + return b.buildUDF(f, def, inScope, outScope, outCol) + } + if isAggregate(def) { panic(errors.AssertionFailedf("aggregate function should have been replaced")) } @@ -583,6 +588,35 @@ func (b *Builder) buildFunction( return b.finishBuildScalar(f, out, inScope, outScope, outCol) } +// buildUDF builds a set of memo groups that represents a user-defined function +// invocation. +// TODO(mgartner): Support multi-statement UDFs. +// TODO(mgartner): Support UDFs with arguments. +func (b *Builder) buildUDF( + f *tree.FuncExpr, def *tree.FunctionDefinition, inScope, outScope *scope, outCol *scopeColumn, +) (out opt.ScalarExpr) { + stmt, err := parser.ParseOne(f.ResolvedOverload().Body) + if err != nil { + panic(err) + } + + // A statement inside a UDF body cannot refer to anything from the outer + // expression calling the function, so we use an empty scope. + // TODO(mgartner): We may need to set bodyScope.atRoot=true to prevent CTEs + // that mutate and are not at the top-level. + bodyScope := b.allocScope() + bodyScope = b.buildStmt(stmt.AST, nil /* desiredTypes */, bodyScope) + + out = b.factory.ConstructUserDefinedFunction( + bodyScope.expr, + &memo.UserDefinedFunctionPrivate{ + Name: def.Name, + Typ: f.ResolvedType(), + }, + ) + return b.finishBuildScalar(f, out, inScope, outScope, outCol) +} + // buildRangeCond builds a RANGE clause as a simpler expression. Examples: // x BETWEEN a AND b -> x >= a AND x <= b // x NOT BETWEEN a AND b -> NOT (x >= a AND x <= b) diff --git a/pkg/sql/opt/optbuilder/testdata/udf b/pkg/sql/opt/optbuilder/testdata/udf index 7d3ca7b03f86..a370e8ee357a 100644 --- a/pkg/sql/opt/optbuilder/testdata/udf +++ b/pkg/sql/opt/optbuilder/testdata/udf @@ -1,4 +1,68 @@ +exec-ddl +CREATE TABLE abc ( + a INT PRIMARY KEY, + b INT, + c INT +) +---- + build SELECT foo() ---- -error (42883): unknown function: foo() +error (42883): unknown function: foo + +exec-ddl +CREATE FUNCTION one() RETURNS INT LANGUAGE SQL AS 'SELECT 1'; +---- + +build +SELECT one() +---- +project + ├── columns: one:2 + ├── values + │ └── () + └── projections + └── user-defined-function: one [as=one:2] + └── project + ├── columns: "?column?":1!null + ├── values + │ └── () + └── projections + └── 1 [as="?column?":1] + +build +SELECT *, one() FROM abc +---- +project + ├── columns: a:1!null b:2 c:3 one:7 + ├── scan abc + │ └── columns: a:1!null b:2 c:3 crdb_internal_mvcc_timestamp:4 tableoid:5 + └── projections + └── user-defined-function: one [as=one:7] + └── project + ├── columns: "?column?":6!null + ├── values + │ └── () + └── projections + └── 1 [as="?column?":6] + +build +SELECT * FROM abc WHERE one() = c +---- +project + ├── columns: a:1!null b:2 c:3 + └── select + ├── columns: a:1!null b:2 c:3 crdb_internal_mvcc_timestamp:4 tableoid:5 + ├── scan abc + │ └── columns: a:1!null b:2 c:3 crdb_internal_mvcc_timestamp:4 tableoid:5 + └── filters + └── eq + ├── user-defined-function: one + │ └── project + │ ├── columns: "?column?":6!null + │ ├── values + │ │ └── () + │ └── projections + │ └── 1 [as="?column?":6] + └── c:3 From 8fca360f7be94667e1f52d5947a96f3c8f958417 Mon Sep 17 00:00:00 2001 From: Raphael 'kena' Poss Date: Mon, 25 Jul 2022 18:07:07 +0200 Subject: [PATCH 7/7] sql: remove a reference to issue 77733 Release note: None --- pkg/sql/tenant_settings.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/pkg/sql/tenant_settings.go b/pkg/sql/tenant_settings.go index 03457bc2458b..9082a993353c 100644 --- a/pkg/sql/tenant_settings.go +++ b/pkg/sql/tenant_settings.go @@ -24,7 +24,6 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" "github.com/cockroachdb/cockroach/pkg/sql/sessiondata" "github.com/cockroachdb/cockroach/pkg/sql/types" - "github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented" "github.com/cockroachdb/cockroach/pkg/util/log/eventpb" "github.com/cockroachdb/errors" ) @@ -89,9 +88,10 @@ func (p *planner) AlterTenantSetClusterSetting( return nil, errors.AssertionFailedf("expected writable setting, got %T", v) } - // We don't support changing the version for another tenant just yet. + // We don't support changing the version for another tenant. + // See discussion on issue https://github.com/cockroachdb/cockroach/issues/77733 (wontfix). if _, isVersion := setting.(*settings.VersionSetting); isVersion { - return nil, unimplemented.NewWithIssue(77733, "cannot change the version of another tenant") + return nil, errors.Newf("cannot change the version of another tenant") } value, err := p.getAndValidateTypedClusterSetting(ctx, name, n.Value, setting)