Skip to content

Commit

Permalink
Merge #76886 #76917
Browse files Browse the repository at this point in the history
76886: sql: scheduled logger to capture index usage stats r=THardy98 a=THardy98

Resolves: #72486

This change introduces a scheduled logger that captures index usage
statistics logs on a time interval.

Release note (sql change): Initial implementation of a scheduled logger
used to capture index usage statistics to the telemetry logging channel.

Release justification: Category 4: Low risk, high benefit changes to
existing functionality.

76917: sql: introduce crdb_internal.transaction_contention_events virtual table r=maryliag,matthewtodd a=Azhng

This commit introduces `crdb_internal.transaction_contention_events`
virtual table. This virtual tables exposes transaction contention events
annotated with transaction fingerprint IDs for transactions that have
finished executing. This allows this virtual table to be joined into the
statement statistics and transaction statistics tables.
The new virtual table require either VIEWACTIVITYREDACTED OR
VIEWACTIVITY role option to access. However, if user has
VIEWACTIVTYREDACTED role, the contending key will be redacted. The contention
events are stored in memory. The amount of contention events stored is
controlled via 'sql.contention.event_store.capacity' cluster setting.

The new table has the following schema:

CREATE TABLE crdb_internal.transaction_contention_events (
    collection_ts                TIMESTAMPTZ NOT NULL,

    blocking_txn_id              UUID NOT NULL,
    blocking_txn_fingerprint_id  BYTES NOT NULL,

    waiting_txn_id               UUID NOT NULL,
    waiting_txn_fingerprint_id   BYTES NOT NULL,

    contention_duration          INTERVAL NOT NULL,
    contending_key               BYTES NOT NULL
)

* collected_ts: stores the timestamp of when the contention event was
collected
* blocking_txn_id: stores the transaction ID of the blocking transaction
of the contention event. This column can be joined into
`crdb_internal.cluster_contention_events` or
`crdb_internal.node_contention_events` table.
* blocking_txn_fingerprint_id: stores the transaction fingerprint ID of
the blocking transaction fingerprint IDs. This can be used to join into
the `crdb_internal.statement_statistics` and
`crdb_internal.transaction_statistics` tables to surface historical
information of the transactions that caused the contention.
* waiting_txn_id: stores the transaction ID of the waiting transaction
in the contention event. Similar to `blocking_txn_id`, this column can
be joined into `crdb_internal.cluster_contention_events` and
`crdb_internal.node_contention_events` tables.
* waiting_txn_fingerprint_id: stores the transaction fingerprint ID of
the waiting transaction. Similar to `blocking_txn_fingerprint_id`, this
column can be joined to `crdb_internal.statement_statistics` and
`crdb_internal.transaction_statistics` tables.
* contention_duration: stores the amount of time the waiting transaction
spent waiting for the blocking transaction.
* contending_key: stores the key that caused the contention. If
the user has VIEWACTIVITYREDACTED role option, this column is redacted.

Resolves #75904

Release note (sql change): introducing
`crdb_internal.transaction_contention_events` virtual table, that exposes
historical transaction contention events. The events exposed in the new virtual
table also include transaction fingerprint IDs for both blocking and
waiting transactions. This allows the new virtual table to be joined
into statement statistics and transaction statistics tables.
The new virtual table require either VIEWACTIVITYREDACTED OR
VIEWACTIVITY role option to access. However, if user has
VIEWACTIVTYREDACTED role, the contending key will be redacted. The contention
events are stored in memory. The amount of contention events stored is
controlled via 'sql.contention.event_store.capacity' cluster setting.

Release note (api change): introducing
GET `/_status/transactioncontentionevents` endpoint, that returns
cluster-wide in-memory historical transaction contention events.
The endpoint require either VIEWACTIVITYREDACTED OR VIEWACTIVITY role
option to access. However, if user has VIEWACTIVTYREDACTED role, the
contending key will be redacted. The contention events are stored in memory.
The amount of contention events stored is controlled via
'sql.contention.event_store.capacity' cluster setting.

Release Justification: Low risk, high benefit change

Co-authored-by: Thomas Hardy <[email protected]>
Co-authored-by: Azhng <[email protected]>
  • Loading branch information
3 people committed Mar 1, 2022
3 parents 12c968f + d09a45e + 5fb64b0 commit 9bab39f
Show file tree
Hide file tree
Showing 45 changed files with 3,281 additions and 1,666 deletions.
26 changes: 26 additions & 0 deletions docs/generated/eventlog.md
Original file line number Diff line number Diff line change
Expand Up @@ -2305,6 +2305,32 @@ are automatically converted server-side.
Events in this category are logged to the `TELEMETRY` channel.


### `captured_index_usage_stats`

An event of type `captured_index_usage_stats`


| Field | Description | Sensitive |
|--|--|--|
| `TotalReadCount` | TotalReadCount is the number of times this index has been read from. | no |
| `LastRead` | LastRead is the timestamp that this index was last being read from. | yes |
| `TableID` | TableID is the ID of the table this index is created on. This is same as descpb.TableID and is unique within the cluster. | no |
| `IndexID` | IndexID is the ID of the index within the scope of the given table. | no |
| `DatabaseName` | | yes |
| `TableName` | | yes |
| `IndexName` | | yes |
| `IndexType` | | yes |
| `IsUnique` | | no |
| `IsInverted` | | no |


#### Common fields

| Field | Description | Sensitive |
|--|--|--|
| `Timestamp` | The timestamp of the event. Expressed as nanoseconds since the Unix epoch. | no |
| `EventType` | The type of the event. | no |

### `sampled_query`

An event of type `sampled_query` is the SQL query event logged to the telemetry channel. It
Expand Down
45 changes: 45 additions & 0 deletions docs/generated/http/full.md
Original file line number Diff line number Diff line change
Expand Up @@ -4440,6 +4440,51 @@ Response object for issuing Transaction ID Resolution.



## TransactionContentionEvents

`GET /_status/transactioncontentionevents`

TransactionContentionEvents returns a list of un-aggregated contention
events sorted by the collection timestamp.

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

#### Request Parameters







| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| node_id | [string](#cockroach.server.serverpb.TransactionContentionEventsRequest-string) | | | [reserved](#support-status) |







#### Response Parameters







| Field | Type | Label | Description | Support status |
| ----- | ---- | ----- | ----------- | -------------- |
| events | [cockroach.sql.contentionpb.ExtendedContentionEvent](#cockroach.server.serverpb.TransactionContentionEventsResponse-cockroach.sql.contentionpb.ExtendedContentionEvent) | repeated | | [reserved](#support-status) |







## RequestCA

`GET /_join/v1/ca`
Expand Down
1 change: 1 addition & 0 deletions pkg/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -322,6 +322,7 @@ ALL_TESTS = [
"//pkg/sql/rowexec:rowexec_test",
"//pkg/sql/rowflow:rowflow_test",
"//pkg/sql/scanner:scanner_test",
"//pkg/sql/scheduledlogging:scheduledlogging_test",
"//pkg/sql/schemachange:schemachange_test",
"//pkg/sql/schemachanger/rel:rel_test",
"//pkg/sql/schemachanger/scbuild:scbuild_test",
Expand Down
57 changes: 29 additions & 28 deletions pkg/base/testing_knobs.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,32 +19,33 @@ type ModuleTestingKnobs interface {
// TestingKnobs contains facilities for controlling various parts of the
// system for testing.
type TestingKnobs struct {
Store ModuleTestingKnobs
KVClient ModuleTestingKnobs
RangeFeed ModuleTestingKnobs
SQLExecutor ModuleTestingKnobs
SQLLeaseManager ModuleTestingKnobs
SQLSchemaChanger ModuleTestingKnobs
SQLDeclarativeSchemaChanger ModuleTestingKnobs
SQLTypeSchemaChanger ModuleTestingKnobs
GCJob ModuleTestingKnobs
PGWireTestingKnobs ModuleTestingKnobs
StartupMigrationManager ModuleTestingKnobs
DistSQL ModuleTestingKnobs
SQLEvalContext ModuleTestingKnobs
NodeLiveness ModuleTestingKnobs
Server ModuleTestingKnobs
TenantTestingKnobs ModuleTestingKnobs
JobsTestingKnobs ModuleTestingKnobs
BackupRestore ModuleTestingKnobs
TTL ModuleTestingKnobs
Streaming ModuleTestingKnobs
MigrationManager ModuleTestingKnobs
IndexUsageStatsKnobs ModuleTestingKnobs
SQLStatsKnobs ModuleTestingKnobs
SpanConfig ModuleTestingKnobs
SQLLivenessKnobs ModuleTestingKnobs
TelemetryLoggingKnobs ModuleTestingKnobs
DialerKnobs ModuleTestingKnobs
ProtectedTS ModuleTestingKnobs
Store ModuleTestingKnobs
KVClient ModuleTestingKnobs
RangeFeed ModuleTestingKnobs
SQLExecutor ModuleTestingKnobs
SQLLeaseManager ModuleTestingKnobs
SQLSchemaChanger ModuleTestingKnobs
SQLDeclarativeSchemaChanger ModuleTestingKnobs
SQLTypeSchemaChanger ModuleTestingKnobs
GCJob ModuleTestingKnobs
PGWireTestingKnobs ModuleTestingKnobs
StartupMigrationManager ModuleTestingKnobs
DistSQL ModuleTestingKnobs
SQLEvalContext ModuleTestingKnobs
NodeLiveness ModuleTestingKnobs
Server ModuleTestingKnobs
TenantTestingKnobs ModuleTestingKnobs
JobsTestingKnobs ModuleTestingKnobs
BackupRestore ModuleTestingKnobs
TTL ModuleTestingKnobs
Streaming ModuleTestingKnobs
MigrationManager ModuleTestingKnobs
IndexUsageStatsKnobs ModuleTestingKnobs
SQLStatsKnobs ModuleTestingKnobs
SpanConfig ModuleTestingKnobs
SQLLivenessKnobs ModuleTestingKnobs
TelemetryLoggingKnobs ModuleTestingKnobs
DialerKnobs ModuleTestingKnobs
ProtectedTS ModuleTestingKnobs
CapturedIndexUsageStatsKnobs ModuleTestingKnobs
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,7 @@ crdb_internal table_indexes table NULL NULL NULL
crdb_internal table_row_statistics table NULL NULL NULL
crdb_internal tables table NULL NULL NULL
crdb_internal tenant_usage_details view NULL NULL NULL
crdb_internal transaction_contention_events table NULL NULL NULL
crdb_internal transaction_statistics view NULL NULL NULL
crdb_internal zones table NULL NULL NULL

Expand Down
2 changes: 2 additions & 0 deletions pkg/ccl/serverccl/statusccl/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@ go_library(
"//pkg/roachpb",
"//pkg/security",
"//pkg/server/serverpb",
"//pkg/sql",
"//pkg/sql/contention",
"//pkg/sql/pgwire",
"//pkg/sql/sqlstats/persistedsqlstats",
"//pkg/sql/tests",
Expand Down
20 changes: 20 additions & 0 deletions pkg/ccl/serverccl/statusccl/tenant_status_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -713,6 +713,26 @@ SET TRACING=off;
t.Errorf("did not expect contention event in controlled cluster, but it was found")
}
}

testutils.SucceedsWithin(t, func() error {
err = testHelper.testCluster().tenantContentionRegistry(1).FlushEventsForTest(ctx)
if err != nil {
return err
}

resp := &serverpb.TransactionContentionEventsResponse{}
testHelper.
testCluster().
tenantHTTPClient(t, 1).
GetJSON("/_status/transactioncontentionevents", resp)

if len(resp.Events) == 0 {
return errors.New("expected transaction contention events being populated, " +
"but it is not")
}

return nil
}, 5*time.Second)
}

func testIndexUsageForTenants(t *testing.T, testHelper *tenantTestHelper) {
Expand Down
29 changes: 19 additions & 10 deletions pkg/ccl/serverccl/statusccl/tenant_test_utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@ import (
"github.com/cockroachdb/cockroach/pkg/roachpb"
"github.com/cockroachdb/cockroach/pkg/security"
"github.com/cockroachdb/cockroach/pkg/server/serverpb"
"github.com/cockroachdb/cockroach/pkg/sql"
"github.com/cockroachdb/cockroach/pkg/sql/contention"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire"
"github.com/cockroachdb/cockroach/pkg/sql/sqlstats/persistedsqlstats"
"github.com/cockroachdb/cockroach/pkg/sql/tests"
Expand All @@ -37,11 +39,12 @@ type serverIdx int
const randomServer serverIdx = -1

type testTenant struct {
tenant serverutils.TestTenantInterface
tenantConn *gosql.DB
tenantDB *sqlutils.SQLRunner
tenantStatus serverpb.SQLStatusServer
tenantSQLStats *persistedsqlstats.PersistedSQLStats
tenant serverutils.TestTenantInterface
tenantConn *gosql.DB
tenantDB *sqlutils.SQLRunner
tenantStatus serverpb.SQLStatusServer
tenantSQLStats *persistedsqlstats.PersistedSQLStats
tenantContentionRegistry *contention.Registry
}

func newTestTenant(
Expand All @@ -62,13 +65,15 @@ func newTestTenant(
status := tenant.StatusServer().(serverpb.SQLStatusServer)
sqlStats := tenant.PGServer().(*pgwire.Server).SQLServer.
GetSQLStatsProvider().(*persistedsqlstats.PersistedSQLStats)
contentionRegistry := tenant.ExecutorConfig().(sql.ExecutorConfig).ContentionRegistry

return &testTenant{
tenant: tenant,
tenantConn: tenantConn,
tenantDB: sqlDB,
tenantStatus: status,
tenantSQLStats: sqlStats,
tenant: tenant,
tenantConn: tenantConn,
tenantDB: sqlDB,
tenantStatus: status,
tenantSQLStats: sqlStats,
tenantContentionRegistry: contentionRegistry,
}
}

Expand Down Expand Up @@ -172,6 +177,10 @@ func (c tenantCluster) tenantStatusSrv(idx serverIdx) serverpb.SQLStatusServer {
return c.tenant(idx).tenantStatus
}

func (c tenantCluster) tenantContentionRegistry(idx serverIdx) *contention.Registry {
return c.tenant(idx).tenantContentionRegistry
}

func (c tenantCluster) cleanup(t *testing.T) {
for _, tenant := range c {
tenant.cleanup(t)
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/partial1
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0s /dev/null
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.table_indexes... writing output: debug/crdb_internal.table_indexes.txt... done
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events... writing output: debug/crdb_internal.transaction_contention_events.txt... done
[cluster] requesting nodes... received response... converting to JSON... writing binary output: debug/nodes.json... done
[cluster] requesting liveness... received response... converting to JSON... writing binary output: debug/liveness.json... done
[node 1] node status... converting to JSON... writing binary output: debug/nodes/1/status.json... done
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/partial1_excluded
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ debug zip /dev/null --concurrency=1 --exclude-nodes=2 --cpu-profile-duration=0
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.table_indexes... writing output: debug/crdb_internal.table_indexes.txt... done
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events... writing output: debug/crdb_internal.transaction_contention_events.txt... done
[cluster] requesting nodes... received response... converting to JSON... writing binary output: debug/nodes.json... done
[cluster] requesting liveness... received response... converting to JSON... writing binary output: debug/liveness.json... done
[node 1] node status... converting to JSON... writing binary output: debug/nodes/1/status.json... done
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/partial2
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ debug zip --concurrency=1 --cpu-profile-duration=0 /dev/null
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.table_indexes... writing output: debug/crdb_internal.table_indexes.txt... done
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events... writing output: debug/crdb_internal.transaction_contention_events.txt... done
[cluster] requesting nodes... received response... converting to JSON... writing binary output: debug/nodes.json... done
[cluster] requesting liveness... received response... converting to JSON... writing binary output: debug/liveness.json... done
[node 1] node status... converting to JSON... writing binary output: debug/nodes/1/status.json... done
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/testzip
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.table_indexes... writing output: debug/crdb_internal.table_indexes.txt... done
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events... writing output: debug/crdb_internal.transaction_contention_events.txt... done
[cluster] requesting nodes... received response... converting to JSON... writing binary output: debug/nodes.json... done
[cluster] requesting liveness... received response... converting to JSON... writing binary output: debug/liveness.json... done
[cluster] requesting CPU profiles
Expand Down
3 changes: 3 additions & 0 deletions pkg/cli/testdata/zip/testzip_concurrent
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,9 @@ zip
[cluster] retrieving SQL data for crdb_internal.table_indexes...
[cluster] retrieving SQL data for crdb_internal.table_indexes: done
[cluster] retrieving SQL data for crdb_internal.table_indexes: writing output: debug/crdb_internal.table_indexes.txt...
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events...
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events: done
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events: writing output: debug/crdb_internal.transaction_contention_events.txt...
[cluster] retrieving SQL data for crdb_internal.zones...
[cluster] retrieving SQL data for crdb_internal.zones: done
[cluster] retrieving SQL data for crdb_internal.zones: writing output: debug/crdb_internal.zones.txt...
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/testdata/zip/testzip_tenant
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ debug zip --concurrency=1 --cpu-profile-duration=1s /dev/null
[cluster] retrieving SQL data for crdb_internal.invalid_objects... writing output: debug/crdb_internal.invalid_objects.txt... done
[cluster] retrieving SQL data for crdb_internal.index_usage_statistics... writing output: debug/crdb_internal.index_usage_statistics.txt... done
[cluster] retrieving SQL data for crdb_internal.table_indexes... writing output: debug/crdb_internal.table_indexes.txt... done
[cluster] retrieving SQL data for crdb_internal.transaction_contention_events... writing output: debug/crdb_internal.transaction_contention_events.txt... done
[cluster] requesting nodes... received response... converting to JSON... writing binary output: debug/nodes.json... done
[cluster] requesting liveness... received response...
[cluster] requesting liveness: last request failed: rpc error: ...
Expand Down
1 change: 1 addition & 0 deletions pkg/cli/zip_cluster_wide.go
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ var debugZipTablesPerCluster = []string{
"crdb_internal.invalid_objects",
"crdb_internal.index_usage_statistics",
"crdb_internal.table_indexes",
"crdb_internal.transaction_contention_events",
}

// nodesInfo holds node details pulled from a SQL or storage node.
Expand Down
3 changes: 3 additions & 0 deletions pkg/rpc/auth_tenant.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,9 @@ func (a tenantAuthorizer) authorize(
case "/cockroach.server.serverpb.Status/CancelLocalQuery":
return a.authTenant(tenID)

case "/cockroach.server.serverpb.Status/TransactionContentionEvents":
return a.authTenant(tenID)

case "/cockroach.roachpb.Internal/GetSpanConfigs":
return a.authGetSpanConfigs(tenID, req.(*roachpb.GetSpanConfigsRequest))

Expand Down
1 change: 1 addition & 0 deletions pkg/server/BUILD.bazel
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ go_library(
"//pkg/sql/physicalplan",
"//pkg/sql/querycache",
"//pkg/sql/roleoption",
"//pkg/sql/scheduledlogging",
"//pkg/sql/schemachanger/scdeps",
"//pkg/sql/schemachanger/scjob",
"//pkg/sql/schemachanger/scrun",
Expand Down
5 changes: 5 additions & 0 deletions pkg/server/server_sql.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ import (
"github.com/cockroachdb/cockroach/pkg/sql/optionalnodeliveness"
"github.com/cockroachdb/cockroach/pkg/sql/pgwire"
"github.com/cockroachdb/cockroach/pkg/sql/querycache"
"github.com/cockroachdb/cockroach/pkg/sql/scheduledlogging"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scdeps"
"github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scrun"
"github.com/cockroachdb/cockroach/pkg/sql/sem/tree"
Expand Down Expand Up @@ -792,6 +793,9 @@ func newSQLServer(ctx context.Context, cfg sqlServerArgs) (*SQLServer, error) {
if spanConfigKnobs := cfg.TestingKnobs.SpanConfig; spanConfigKnobs != nil {
execCfg.SpanConfigTestingKnobs = spanConfigKnobs.(*spanconfig.TestingKnobs)
}
if capturedIndexUsageStatsKnobs := cfg.TestingKnobs.CapturedIndexUsageStatsKnobs; capturedIndexUsageStatsKnobs != nil {
execCfg.CaptureIndexUsageStatsKnobs = capturedIndexUsageStatsKnobs.(*scheduledlogging.CaptureIndexUsageStatsTestingKnobs)
}

statsRefresher := stats.MakeRefresher(
cfg.AmbientCtx,
Expand Down Expand Up @@ -1251,6 +1255,7 @@ func (s *SQLServer) preStart(
scheduledjobs.ProdJobSchedulerEnv,
)

scheduledlogging.Start(ctx, stopper, s.execCfg.DB, s.execCfg.Settings, s.internalExecutor, s.execCfg.CaptureIndexUsageStatsKnobs)
return nil
}

Expand Down
1 change: 1 addition & 0 deletions pkg/server/serverpb/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ type SQLStatusServer interface {
TableIndexStats(context.Context, *TableIndexStatsRequest) (*TableIndexStatsResponse, error)
UserSQLRoles(context.Context, *UserSQLRolesRequest) (*UserSQLRolesResponse, error)
TxnIDResolution(context.Context, *TxnIDResolutionRequest) (*TxnIDResolutionResponse, error)
TransactionContentionEvents(context.Context, *TransactionContentionEventsRequest) (*TransactionContentionEventsResponse, error)
}

// OptionalNodesStatusServer is a StatusServer that is only optionally present
Expand Down
18 changes: 18 additions & 0 deletions pkg/server/serverpb/status.proto
Original file line number Diff line number Diff line change
Expand Up @@ -1565,6 +1565,16 @@ message TxnIDResolutionResponse {
(gogoproto.nullable) = false];
}

message TransactionContentionEventsRequest {
string node_id = 1 [(gogoproto.customname) = "NodeID"];
}

message TransactionContentionEventsResponse {
repeated cockroach.sql.contentionpb.ExtendedContentionEvent events = 1 [
(gogoproto.nullable) = false
];
}

service Status {
// Certificates retrieves a copy of the TLS certificates.
rpc Certificates(CertificatesRequest) returns (CertificatesResponse) {
Expand Down Expand Up @@ -1977,4 +1987,12 @@ service Status {
// Client is responsible to perform retries if the requested transaction ID
// is not returned in the RPC response.
rpc TxnIDResolution(TxnIDResolutionRequest) returns (TxnIDResolutionResponse) {}

// TransactionContentionEvents returns a list of un-aggregated contention
// events sorted by the collection timestamp.
rpc TransactionContentionEvents(TransactionContentionEventsRequest) returns (TransactionContentionEventsResponse) {
option (google.api.http) = {
get: "/_status/transactioncontentionevents"
};
}
}
Loading

0 comments on commit 9bab39f

Please sign in to comment.