From dcc4533902fc73891e8407805ec7192d17992965 Mon Sep 17 00:00:00 2001 From: Yahor Yuzefovich Date: Tue, 25 Apr 2023 17:17:51 -0700 Subject: [PATCH 1/5] sql: remove redundant column from crdb_internal.*_distsql_flows This commit removes now redundant `status` column from `crdb_internal.cluster_distsql_flows` and `crdb_internal.node_distsql_flows` virtual tables. We no longer have queueing of the remote flows in place, so all remote flows always have 'running' status. Epic: None Release note: None --- docs/generated/http/full.md | 2 - pkg/cli/zip_table_registry.go | 2 - pkg/server/serverpb/status.proto | 9 +-- pkg/server/status.go | 1 - pkg/server/status_test.go | 76 +++++++++---------- pkg/sql/crdb_internal.go | 7 +- pkg/sql/crdb_internal_test.go | 34 +++------ .../testdata/logic_test/crdb_internal_catalog | 4 +- 8 files changed, 54 insertions(+), 81 deletions(-) diff --git a/docs/generated/http/full.md b/docs/generated/http/full.md index 179f407d4300..a556e20fc736 100644 --- a/docs/generated/http/full.md +++ b/docs/generated/http/full.md @@ -2701,7 +2701,6 @@ Info contains an information about a single DistSQL remote flow. | ----- | ---- | ----- | ----------- | -------------- | | node_id | [int32](#cockroach.server.serverpb.ListDistSQLFlowsResponse-int32) | | NodeID is the node on which this remote flow is either running or queued. | [reserved](#support-status) | | timestamp | [google.protobuf.Timestamp](#cockroach.server.serverpb.ListDistSQLFlowsResponse-google.protobuf.Timestamp) | | Timestamp must be in the UTC timezone. | [reserved](#support-status) | -| status | [DistSQLRemoteFlows.Status](#cockroach.server.serverpb.ListDistSQLFlowsResponse-cockroach.server.serverpb.DistSQLRemoteFlows.Status) | | Status is the current status of this remote flow. TODO(yuzefovich): remove this in 23.2. | [reserved](#support-status) | | stmt | [string](#cockroach.server.serverpb.ListDistSQLFlowsResponse-string) | | Stmt is the SQL statement for which this flow is executing. | [reserved](#support-status) | @@ -2795,7 +2794,6 @@ Info contains an information about a single DistSQL remote flow. | ----- | ---- | ----- | ----------- | -------------- | | node_id | [int32](#cockroach.server.serverpb.ListDistSQLFlowsResponse-int32) | | NodeID is the node on which this remote flow is either running or queued. | [reserved](#support-status) | | timestamp | [google.protobuf.Timestamp](#cockroach.server.serverpb.ListDistSQLFlowsResponse-google.protobuf.Timestamp) | | Timestamp must be in the UTC timezone. | [reserved](#support-status) | -| status | [DistSQLRemoteFlows.Status](#cockroach.server.serverpb.ListDistSQLFlowsResponse-cockroach.server.serverpb.DistSQLRemoteFlows.Status) | | Status is the current status of this remote flow. TODO(yuzefovich): remove this in 23.2. | [reserved](#support-status) | | stmt | [string](#cockroach.server.serverpb.ListDistSQLFlowsResponse-string) | | Stmt is the SQL statement for which this flow is executing. | [reserved](#support-status) | diff --git a/pkg/cli/zip_table_registry.go b/pkg/cli/zip_table_registry.go index d1f55dd5c64f..ce25b8bbc090 100644 --- a/pkg/cli/zip_table_registry.go +++ b/pkg/cli/zip_table_registry.go @@ -130,7 +130,6 @@ var zipInternalTablesPerCluster = DebugZipTableRegistry{ "flow_id", "node_id", "since", - "status", "crdb_internal.hide_sql_constants(stmt) as stmt", }, }, @@ -624,7 +623,6 @@ var zipInternalTablesPerNode = DebugZipTableRegistry{ "node_id", "stmt", "since", - "status", "crdb_internal.hide_sql_constants(stmt) as stmt", }, }, diff --git a/pkg/server/serverpb/status.proto b/pkg/server/serverpb/status.proto index b80b24cab4e1..9ce095e714db 100644 --- a/pkg/server/serverpb/status.proto +++ b/pkg/server/serverpb/status.proto @@ -1136,11 +1136,6 @@ message ListDistSQLFlowsRequest {} // same physical plan. The gateway node that initiated the execution of the plan // isn't included. message DistSQLRemoteFlows { - enum Status { - RUNNING = 0; - QUEUED = 1; - } - // Info contains an information about a single DistSQL remote flow. message Info { // NodeID is the node on which this remote flow is either running or queued. @@ -1152,9 +1147,7 @@ message DistSQLRemoteFlows { (gogoproto.nullable) = false, (gogoproto.stdtime) = true ]; - // Status is the current status of this remote flow. - // TODO(yuzefovich): remove this in 23.2. - Status status = 3; + reserved 3; // Stmt is the SQL statement for which this flow is executing. string stmt = 4; diff --git a/pkg/server/status.go b/pkg/server/status.go index c4756f7d41ce..611421cc078a 100644 --- a/pkg/server/status.go +++ b/pkg/server/status.go @@ -375,7 +375,6 @@ func (b *baseStatusServer) ListLocalDistSQLFlows( Infos: []serverpb.DistSQLRemoteFlows_Info{{ NodeID: nodeIDOrZero, Timestamp: f.Timestamp, - Status: serverpb.DistSQLRemoteFlows_RUNNING, Stmt: f.StatementSQL, }}, }) diff --git a/pkg/server/status_test.go b/pkg/server/status_test.go index d4538a247719..11985fa53d2a 100644 --- a/pkg/server/status_test.go +++ b/pkg/server/status_test.go @@ -2659,15 +2659,15 @@ func TestMergeDistSQLRemoteFlows(t *testing.T) { { FlowID: flowIDs[0], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[1], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, }, }, }, @@ -2675,15 +2675,15 @@ func TestMergeDistSQLRemoteFlows(t *testing.T) { { FlowID: flowIDs[0], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[1], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, }, }, }, @@ -2694,15 +2694,15 @@ func TestMergeDistSQLRemoteFlows(t *testing.T) { { FlowID: flowIDs[0], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[1], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, }, }, }, @@ -2711,15 +2711,15 @@ func TestMergeDistSQLRemoteFlows(t *testing.T) { { FlowID: flowIDs[0], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[1], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, }, }, }, @@ -2730,21 +2730,21 @@ func TestMergeDistSQLRemoteFlows(t *testing.T) { { FlowID: flowIDs[0], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[2], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[3], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 0, Timestamp: ts[0], Status: serverpb.DistSQLRemoteFlows_QUEUED}, + {NodeID: 0, Timestamp: ts[0]}, }, }, }, @@ -2752,22 +2752,22 @@ func TestMergeDistSQLRemoteFlows(t *testing.T) { { FlowID: flowIDs[0], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 0, Timestamp: ts[0], Status: serverpb.DistSQLRemoteFlows_QUEUED}, + {NodeID: 0, Timestamp: ts[0]}, }, }, { FlowID: flowIDs[1], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 0, Timestamp: ts[0], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, + {NodeID: 0, Timestamp: ts[0]}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, }, }, { FlowID: flowIDs[3], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, }, }, }, @@ -2775,32 +2775,32 @@ func TestMergeDistSQLRemoteFlows(t *testing.T) { { FlowID: flowIDs[0], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 0, Timestamp: ts[0], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 0, Timestamp: ts[0]}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[1], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 0, Timestamp: ts[0], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, + {NodeID: 0, Timestamp: ts[0]}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, }, }, { FlowID: flowIDs[2], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 3, Timestamp: ts[3], Status: serverpb.DistSQLRemoteFlows_RUNNING}, + {NodeID: 3, Timestamp: ts[3]}, }, }, { FlowID: flowIDs[3], Infos: []serverpb.DistSQLRemoteFlows_Info{ - {NodeID: 0, Timestamp: ts[0], Status: serverpb.DistSQLRemoteFlows_QUEUED}, - {NodeID: 1, Timestamp: ts[1], Status: serverpb.DistSQLRemoteFlows_RUNNING}, - {NodeID: 2, Timestamp: ts[2], Status: serverpb.DistSQLRemoteFlows_QUEUED}, + {NodeID: 0, Timestamp: ts[0]}, + {NodeID: 1, Timestamp: ts[1]}, + {NodeID: 2, Timestamp: ts[2]}, }, }, }, diff --git a/pkg/sql/crdb_internal.go b/pkg/sql/crdb_internal.go index 0e1cc07e52e4..12a67f3ec451 100644 --- a/pkg/sql/crdb_internal.go +++ b/pkg/sql/crdb_internal.go @@ -2858,14 +2858,12 @@ func populateContentionEventsTable( return nil } -// TODO(yuzefovich): remove 'status' column in 23.2. const distSQLFlowsSchemaPattern = ` CREATE TABLE crdb_internal.%s ( flow_id UUID NOT NULL, node_id INT NOT NULL, stmt STRING NULL, - since TIMESTAMPTZ NOT NULL, - status STRING NOT NULL + since TIMESTAMPTZ NOT NULL ) ` @@ -2914,8 +2912,7 @@ func populateDistSQLFlowsTable( if err != nil { return err } - status := tree.NewDString(strings.ToLower(info.Status.String())) - if err = addRow(flowID, nodeID, stmt, since, status); err != nil { + if err = addRow(flowID, nodeID, stmt, since); err != nil { return err } } diff --git a/pkg/sql/crdb_internal_test.go b/pkg/sql/crdb_internal_test.go index 7d743b508c6a..f743a743df64 100644 --- a/pkg/sql/crdb_internal_test.go +++ b/pkg/sql/crdb_internal_test.go @@ -635,14 +635,10 @@ func TestDistSQLFlowsVirtualTables(t *testing.T) { }) t.Log("checking the virtual tables") - const ( - clusterScope = "cluster" - nodeScope = "node" - runningStatus = "running" - queuedStatus = "queued" - ) - getNum := func(db *sqlutils.SQLRunner, scope, status string) int { - querySuffix := fmt.Sprintf("FROM crdb_internal.%s_distsql_flows WHERE status = '%s'", scope, status) + const clusterScope = "cluster" + const nodeScope = "node" + getNum := func(db *sqlutils.SQLRunner, scope string) int { + querySuffix := fmt.Sprintf("FROM crdb_internal.%s_distsql_flows", scope) // Check that all remote flows (if any) correspond to the expected // statement. stmts := db.QueryStr(t, "SELECT stmt "+querySuffix) @@ -658,28 +654,20 @@ func TestDistSQLFlowsVirtualTables(t *testing.T) { db := sqlutils.MakeSQLRunner(conn) // Check cluster level table. - expRunning, expQueued := 2, 0 - gotRunning, gotQueued := getNum(db, clusterScope, runningStatus), getNum(db, clusterScope, queuedStatus) - if gotRunning != expRunning { - t.Fatalf("unexpected output from cluster_distsql_flows on node %d (running=%d)", nodeID+1, gotRunning) - } - if gotQueued != expQueued { - t.Fatalf("unexpected output from cluster_distsql_flows on node %d (queued=%d)", nodeID+1, gotQueued) + actual := getNum(db, clusterScope) + if actual != 2 { + t.Fatalf("unexpected output from cluster_distsql_flows on node %d (found %d)", nodeID+1, actual) } // Check node level table. if nodeID == gatewayNodeID { - if getNum(db, nodeScope, runningStatus) != 0 || getNum(db, nodeScope, queuedStatus) != 0 { + if getNum(db, nodeScope) != 0 { t.Fatal("unexpectedly non empty output from node_distsql_flows on the gateway") } } else { - expRunning, expQueued = 1, 0 - gotRunning, gotQueued = getNum(db, nodeScope, runningStatus), getNum(db, nodeScope, queuedStatus) - if gotRunning != expRunning { - t.Fatalf("unexpected output from node_distsql_flows on node %d (running=%d)", nodeID+1, gotRunning) - } - if gotQueued != expQueued { - t.Fatalf("unexpected output from node_distsql_flows on node %d (queued=%d)", nodeID+1, gotQueued) + actual = getNum(db, nodeScope) + if actual != 1 { + t.Fatalf("unexpected output from node_distsql_flows on node %d (found %d)", nodeID+1, actual) } } } diff --git a/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog b/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog index d1d317aa0f35..0287469f7598 100644 --- a/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog +++ b/pkg/sql/logictest/testdata/logic_test/crdb_internal_catalog @@ -435,7 +435,7 @@ SELECT id, strip_volatile(descriptor) FROM crdb_internal.kv_catalog_descriptor 4294967246 {"table": {"columns": [{"id": 1, "name": "id", "nullable": true, "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 2, "name": "node_id", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "session_id", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "start", "nullable": true, "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 5, "name": "txn_string", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 6, "name": "application_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 7, "name": "num_stmts", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 8, "name": "num_retries", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 9, "name": "num_auto_retries", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 10, "name": "last_auto_retry_reason", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967246, "name": "node_transactions", "nextColumnId": 11, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967247 {"table": {"columns": [{"id": 1, "name": "query_id", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "txn_id", "nullable": true, "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 3, "name": "node_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 4, "name": "session_id", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 5, "name": "user_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 6, "name": "start", "nullable": true, "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 7, "name": "query", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 8, "name": "client_address", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 9, "name": "application_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 10, "name": "distributed", "nullable": true, "type": {"oid": 16}}, {"id": 11, "name": "phase", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 12, "name": "full_scan", "nullable": true, "type": {"oid": 16}}, {"id": 13, "name": "plan_gist", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 14, "name": "database", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967247, "name": "node_queries", "nextColumnId": 15, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967248 {"table": {"columns": [{"id": 1, "name": "session_id", "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "txn_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 3, "name": "txn_fingerprint_id", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 4, "name": "stmt_id", "type": {"family": "StringFamily", "oid": 25}}, {"id": 5, "name": "stmt_fingerprint_id", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 6, "name": "problem", "type": {"family": "StringFamily", "oid": 25}}, {"id": 7, "name": "causes", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 8, "name": "query", "type": {"family": "StringFamily", "oid": 25}}, {"id": 9, "name": "status", "type": {"family": "StringFamily", "oid": 25}}, {"id": 10, "name": "start_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 11, "name": "end_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 12, "name": "full_scan", "type": {"oid": 16}}, {"id": 13, "name": "user_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 14, "name": "app_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 15, "name": "database_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 16, "name": "plan_gist", "type": {"family": "StringFamily", "oid": 25}}, {"id": 17, "name": "rows_read", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 18, "name": "rows_written", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 19, "name": "priority", "type": {"family": "StringFamily", "oid": 25}}, {"id": 20, "name": "retries", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 21, "name": "last_retry_reason", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 22, "name": "exec_node_ids", "type": {"arrayContents": {"family": "IntFamily", "oid": 20, "width": 64}, "arrayElemType": "IntFamily", "family": "ArrayFamily", "oid": 1016, "width": 64}}, {"id": 23, "name": "contention", "nullable": true, "type": {"family": "IntervalFamily", "intervalDurationField": {}, "oid": 1186}}, {"id": 24, "name": "index_recommendations", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 25, "name": "implicit_txn", "type": {"oid": 16}}, {"id": 26, "name": "cpu_sql_nanos", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 27, "name": "error_code", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967248, "name": "node_execution_insights", "nextColumnId": 28, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} -4294967249 {"table": {"columns": [{"id": 1, "name": "flow_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 2, "name": "node_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "stmt", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "since", "type": {"family": "TimestampTZFamily", "oid": 1184}}, {"id": 5, "name": "status", "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967249, "name": "node_distsql_flows", "nextColumnId": 6, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} +4294967249 {"table": {"columns": [{"id": 1, "name": "flow_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 2, "name": "node_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "stmt", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "since", "type": {"family": "TimestampTZFamily", "oid": 1184}}], "formatVersion": 3, "id": 4294967249, "name": "node_distsql_flows", "nextColumnId": 5, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967250 {"table": {"columns": [{"id": 1, "name": "table_id", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "index_id", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "num_contention_events", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 4, "name": "cumulative_contention_time", "type": {"family": "IntervalFamily", "intervalDurationField": {}, "oid": 1186}}, {"id": 5, "name": "key", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 6, "name": "txn_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 7, "name": "count", "type": {"family": "IntFamily", "oid": 20, "width": 64}}], "formatVersion": 3, "id": 4294967250, "name": "node_contention_events", "nextColumnId": 8, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967251 {"table": {"columns": [{"id": 1, "name": "node_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "table_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "parent_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 5, "name": "expiration", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 6, "name": "deleted", "type": {"oid": 16}}], "formatVersion": 3, "id": 4294967251, "name": "leases", "nextColumnId": 7, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967252 {"table": {"columns": [{"id": 1, "name": "node_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "store_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "attrs", "type": {"family": "JsonFamily", "oid": 3802}}, {"id": 4, "name": "capacity", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 5, "name": "available", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 6, "name": "used", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 7, "name": "logical_bytes", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 8, "name": "range_count", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 9, "name": "lease_count", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 10, "name": "writes_per_second", "type": {"family": "FloatFamily", "oid": 701, "width": 64}}, {"id": 11, "name": "bytes_per_replica", "type": {"family": "JsonFamily", "oid": 3802}}, {"id": 12, "name": "writes_per_replica", "type": {"family": "JsonFamily", "oid": 3802}}, {"id": 13, "name": "metrics", "type": {"family": "JsonFamily", "oid": 3802}}, {"id": 14, "name": "properties", "type": {"family": "JsonFamily", "oid": 3802}}], "formatVersion": 3, "id": 4294967252, "name": "kv_store_status", "nextColumnId": 15, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} @@ -469,7 +469,7 @@ SELECT id, strip_volatile(descriptor) FROM crdb_internal.kv_catalog_descriptor 4294967280 {"table": {"columns": [{"id": 1, "name": "txn_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 2, "name": "txn_fingerprint_id", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 3, "name": "query", "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "implicit_txn", "type": {"oid": 16}}, {"id": 5, "name": "session_id", "type": {"family": "StringFamily", "oid": 25}}, {"id": 6, "name": "start_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 7, "name": "end_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 8, "name": "user_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 9, "name": "app_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 10, "name": "rows_read", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 11, "name": "rows_written", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 12, "name": "priority", "type": {"family": "StringFamily", "oid": 25}}, {"id": 13, "name": "retries", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 14, "name": "last_retry_reason", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 15, "name": "contention", "nullable": true, "type": {"family": "IntervalFamily", "intervalDurationField": {}, "oid": 1186}}, {"id": 16, "name": "problems", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 17, "name": "causes", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 18, "name": "stmt_execution_ids", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 19, "name": "cpu_sql_nanos", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 20, "name": "last_error_code", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 21, "name": "status", "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967280, "name": "node_txn_execution_insights", "nextColumnId": 22, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967281 {"table": {"columns": [{"id": 1, "name": "txn_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 2, "name": "txn_fingerprint_id", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 3, "name": "query", "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "implicit_txn", "type": {"oid": 16}}, {"id": 5, "name": "session_id", "type": {"family": "StringFamily", "oid": 25}}, {"id": 6, "name": "start_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 7, "name": "end_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 8, "name": "user_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 9, "name": "app_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 10, "name": "rows_read", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 11, "name": "rows_written", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 12, "name": "priority", "type": {"family": "StringFamily", "oid": 25}}, {"id": 13, "name": "retries", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 14, "name": "last_retry_reason", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 15, "name": "contention", "nullable": true, "type": {"family": "IntervalFamily", "intervalDurationField": {}, "oid": 1186}}, {"id": 16, "name": "problems", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 17, "name": "causes", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 18, "name": "stmt_execution_ids", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 19, "name": "cpu_sql_nanos", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 20, "name": "last_error_code", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 21, "name": "status", "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967281, "name": "cluster_txn_execution_insights", "nextColumnId": 22, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967282 {"table": {"columns": [{"id": 1, "name": "session_id", "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "txn_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 3, "name": "txn_fingerprint_id", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 4, "name": "stmt_id", "type": {"family": "StringFamily", "oid": 25}}, {"id": 5, "name": "stmt_fingerprint_id", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 6, "name": "problem", "type": {"family": "StringFamily", "oid": 25}}, {"id": 7, "name": "causes", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 8, "name": "query", "type": {"family": "StringFamily", "oid": 25}}, {"id": 9, "name": "status", "type": {"family": "StringFamily", "oid": 25}}, {"id": 10, "name": "start_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 11, "name": "end_time", "type": {"family": "TimestampFamily", "oid": 1114}}, {"id": 12, "name": "full_scan", "type": {"oid": 16}}, {"id": 13, "name": "user_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 14, "name": "app_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 15, "name": "database_name", "type": {"family": "StringFamily", "oid": 25}}, {"id": 16, "name": "plan_gist", "type": {"family": "StringFamily", "oid": 25}}, {"id": 17, "name": "rows_read", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 18, "name": "rows_written", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 19, "name": "priority", "type": {"family": "StringFamily", "oid": 25}}, {"id": 20, "name": "retries", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 21, "name": "last_retry_reason", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 22, "name": "exec_node_ids", "type": {"arrayContents": {"family": "IntFamily", "oid": 20, "width": 64}, "arrayElemType": "IntFamily", "family": "ArrayFamily", "oid": 1016, "width": 64}}, {"id": 23, "name": "contention", "nullable": true, "type": {"family": "IntervalFamily", "intervalDurationField": {}, "oid": 1186}}, {"id": 24, "name": "index_recommendations", "type": {"arrayContents": {"family": "StringFamily", "oid": 25}, "arrayElemType": "StringFamily", "family": "ArrayFamily", "oid": 1009}}, {"id": 25, "name": "implicit_txn", "type": {"oid": 16}}, {"id": 26, "name": "cpu_sql_nanos", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 27, "name": "error_code", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967282, "name": "cluster_execution_insights", "nextColumnId": 28, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} -4294967283 {"table": {"columns": [{"id": 1, "name": "flow_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 2, "name": "node_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "stmt", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "since", "type": {"family": "TimestampTZFamily", "oid": 1184}}, {"id": 5, "name": "status", "type": {"family": "StringFamily", "oid": 25}}], "formatVersion": 3, "id": 4294967283, "name": "cluster_distsql_flows", "nextColumnId": 6, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} +4294967283 {"table": {"columns": [{"id": 1, "name": "flow_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 2, "name": "node_id", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "stmt", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "since", "type": {"family": "TimestampTZFamily", "oid": 1184}}], "formatVersion": 3, "id": 4294967283, "name": "cluster_distsql_flows", "nextColumnId": 5, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967284 {"table": {"columns": [{"id": 1, "name": "table_id", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 2, "name": "index_id", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 3, "name": "num_contention_events", "type": {"family": "IntFamily", "oid": 20, "width": 64}}, {"id": 4, "name": "cumulative_contention_time", "type": {"family": "IntervalFamily", "intervalDurationField": {}, "oid": 1186}}, {"id": 5, "name": "key", "type": {"family": "BytesFamily", "oid": 17}}, {"id": 6, "name": "txn_id", "type": {"family": "UuidFamily", "oid": 2950}}, {"id": 7, "name": "count", "type": {"family": "IntFamily", "oid": 20, "width": 64}}], "formatVersion": 3, "id": 4294967284, "name": "cluster_contention_events", "nextColumnId": 8, "nextConstraintId": 2, "nextIndexId": 2, "nextMutationId": 1, "primaryIndex": {"constraintId": 1, "foreignKey": {}, "geoConfig": {}, "id": 1, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1"}} 4294967285 {"table": {"columns": [{"id": 1, "name": "database_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "schema_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 3, "name": "table_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "num_contention_events", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}], "formatVersion": 3, "id": 4294967285, "name": "cluster_contended_tables", "nextColumnId": 5, "nextConstraintId": 1, "nextMutationId": 1, "primaryIndex": {"foreignKey": {}, "geoConfig": {}, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1", "viewQuery": "SELECT database_name, schema_name, name, sum(num_contention_events) FROM (SELECT DISTINCT database_name, schema_name, name, index_id, num_contention_events FROM crdb_internal.cluster_contention_events JOIN crdb_internal.tables ON crdb_internal.cluster_contention_events.table_id = crdb_internal.tables.table_id) GROUP BY database_name, schema_name, name"}} 4294967286 {"table": {"columns": [{"id": 1, "name": "database_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 2, "name": "schema_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 3, "name": "table_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 4, "name": "index_name", "nullable": true, "type": {"family": "StringFamily", "oid": 25}}, {"id": 5, "name": "key", "nullable": true, "type": {"family": "BytesFamily", "oid": 17}}, {"id": 6, "name": "num_contention_events", "nullable": true, "type": {"family": "IntFamily", "oid": 20, "width": 64}}], "formatVersion": 3, "id": 4294967286, "name": "cluster_contended_keys", "nextColumnId": 7, "nextConstraintId": 1, "nextMutationId": 1, "primaryIndex": {"foreignKey": {}, "geoConfig": {}, "interleave": {}, "partitioning": {}, "sharded": {}}, "privileges": {"ownerProto": "node", "users": [{"privileges": "32", "userProto": "public"}], "version": 2}, "replacementOf": {"time": {}}, "unexposedParentSchemaId": 4294967295, "version": "1", "viewQuery": "SELECT database_name, schema_name, name, index_name, crdb_internal.pretty_key(key, 0), sum(count) FROM crdb_internal.cluster_contention_events, crdb_internal.tables, crdb_internal.table_indexes WHERE ((crdb_internal.cluster_contention_events.index_id = crdb_internal.table_indexes.index_id) AND (crdb_internal.cluster_contention_events.table_id = crdb_internal.table_indexes.descriptor_id)) AND (crdb_internal.cluster_contention_events.table_id = crdb_internal.tables.table_id) GROUP BY database_name, schema_name, name, index_name, key"}} From e054ffd43dbd5db73927008839a15d168de3d0c5 Mon Sep 17 00:00:00 2001 From: Rail Aliiev Date: Wed, 26 Apr 2023 10:32:22 -0400 Subject: [PATCH 2/5] release: increase bincheck timeout Increase overall timeout for bincheck in order to be less flaky running the tests on GitHub runners. Epic: none Release note: None --- build/release/bincheck/bincheck | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/build/release/bincheck/bincheck b/build/release/bincheck/bincheck index 24c9f8e96af2..2ab7178c9b4b 100755 --- a/build/release/bincheck/bincheck +++ b/build/release/bincheck/bincheck @@ -35,7 +35,7 @@ echo "" "$cockroach" start-single-node --insecure --listening-url-file="$urlfile" --enterprise-encryption=path=cockroach-data,key=aes-128.key,old-key=plain --pid-file="$pidfile" & trap "kill -9 $! || true" EXIT -for i in {0..3} +for i in {0..8} do [[ -f "$urlfile" ]] && break backoff=$((2 ** i)) From 8eecff7cfe8e497e60003c0317aec15d2c9dcd96 Mon Sep 17 00:00:00 2001 From: Herko Lategan Date: Fri, 21 Apr 2023 18:48:07 +0100 Subject: [PATCH 3/5] dev: add flag for extra docker args In order to support git alternates an additional volume must be supplied to the bazel support docker. The TeamCity script already supplies a utility method called `run_bazel` which supplies the volume to support git alternates. This change allows for extra arguments to be passed via a command line argument to the docker invocation that is utilised for cross builds by the `dev` utility. --- dev | 2 +- pkg/cmd/dev/acceptance.go | 2 +- pkg/cmd/dev/build.go | 13 ++++++++++--- pkg/cmd/dev/builder.go | 6 ++++-- pkg/cmd/dev/compose.go | 2 +- pkg/cmd/dev/roachprod_stress.go | 2 +- pkg/cmd/dev/test_binaries.go | 12 +++++++----- pkg/cmd/dev/util.go | 8 ++++++++ 8 files changed, 33 insertions(+), 14 deletions(-) diff --git a/dev b/dev index f0cf57df5930..29749c6a98cc 100755 --- a/dev +++ b/dev @@ -8,7 +8,7 @@ fi set -euo pipefail # Bump this counter to force rebuilding `dev` on all machines. -DEV_VERSION=71 +DEV_VERSION=72 THIS_DIR=$(cd "$(dirname "$0")" && pwd) BINARY_DIR=$THIS_DIR/bin/dev-versions diff --git a/pkg/cmd/dev/acceptance.go b/pkg/cmd/dev/acceptance.go index 69f7443fb557..3c889ca29473 100644 --- a/pkg/cmd/dev/acceptance.go +++ b/pkg/cmd/dev/acceptance.go @@ -58,7 +58,7 @@ func (d *dev) acceptance(cmd *cobra.Command, commandLine []string) error { return err } volume := mustGetFlagString(cmd, volumeFlag) - err = d.crossBuild(ctx, crossArgs, targets, "crosslinux", volume) + err = d.crossBuild(ctx, crossArgs, targets, "crosslinux", volume, nil) if err != nil { return err } diff --git a/pkg/cmd/dev/build.go b/pkg/cmd/dev/build.go index 75a5defb9d8e..9411c18ad165 100644 --- a/pkg/cmd/dev/build.go +++ b/pkg/cmd/dev/build.go @@ -65,6 +65,7 @@ func makeBuildCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.Com buildCmd.Flags().String(volumeFlag, "bzlhome", "the Docker volume to use as the container home directory (only used for cross builds)") buildCmd.Flags().String(crossFlag, "", "cross-compiles using the builder image (options: linux, linuxarm, macos, macosarm, windows)") buildCmd.Flags().Lookup(crossFlag).NoOptDefVal = "linux" + buildCmd.Flags().StringArray(dockerArgsFlag, []string{}, "additional arguments to pass to Docker (only used for cross builds)") addCommonBuildFlags(buildCmd) return buildCmd } @@ -145,6 +146,7 @@ func (d *dev) build(cmd *cobra.Command, commandLine []string) error { targets, additionalBazelArgs := splitArgsAtDash(cmd, commandLine) ctx := cmd.Context() cross := mustGetFlagString(cmd, crossFlag) + dockerArgs := mustGetFlagStringArray(cmd, dockerArgsFlag) // Set up dev cache unless it's disabled via the environment variable or the // testing knob. @@ -185,15 +187,20 @@ func (d *dev) build(cmd *cobra.Command, commandLine []string) error { } volume := mustGetFlagString(cmd, volumeFlag) cross = "cross" + cross - return d.crossBuild(ctx, args, buildTargets, cross, volume) + return d.crossBuild(ctx, args, buildTargets, cross, volume, dockerArgs) } func (d *dev) crossBuild( - ctx context.Context, bazelArgs []string, targets []buildTarget, crossConfig string, volume string, + ctx context.Context, + bazelArgs []string, + targets []buildTarget, + crossConfig string, + volume string, + dockerArgs []string, ) error { bazelArgs = append(bazelArgs, fmt.Sprintf("--config=%s", crossConfig), "--config=ci") configArgs := getConfigArgs(bazelArgs) - dockerArgs, err := d.getDockerRunArgs(ctx, volume, false) + dockerArgs, err := d.getDockerRunArgs(ctx, volume, false, dockerArgs) if err != nil { return err } diff --git a/pkg/cmd/dev/builder.go b/pkg/cmd/dev/builder.go index 2b0bf9f316f9..f108cfd17f53 100644 --- a/pkg/cmd/dev/builder.go +++ b/pkg/cmd/dev/builder.go @@ -22,6 +22,7 @@ import ( ) const volumeFlag = "volume" +const dockerArgsFlag = "docker-args" // MakeBuilderCmd constructs the subcommand used to run func makeBuilderCmd(runE func(cmd *cobra.Command, args []string) error) *cobra.Command { @@ -44,7 +45,7 @@ func (d *dev) builder(cmd *cobra.Command, extraArgs []string) error { if len(extraArgs) == 0 { tty = true } - args, err := d.getDockerRunArgs(ctx, volume, tty) + args, err := d.getDockerRunArgs(ctx, volume, tty, nil) args = append(args, extraArgs...) if err != nil { return err @@ -56,7 +57,7 @@ func (d *dev) builder(cmd *cobra.Command, extraArgs []string) error { } func (d *dev) getDockerRunArgs( - ctx context.Context, volume string, tty bool, + ctx context.Context, volume string, tty bool, extraArgs []string, ) (args []string, err error) { err = d.ensureBinaryInPath("docker") if err != nil { @@ -137,6 +138,7 @@ func (d *dev) getDockerRunArgs( // is authoritative. This can result in writes to the actual underlying // filesystem to be lost, but it's a cache so we don't care about that. args = append(args, "-v", volume+":/home/roach:delegated") + args = append(args, extraArgs...) args = append(args, "-u", fmt.Sprintf("%s:%s", uid, gid)) args = append(args, bazelImage) return diff --git a/pkg/cmd/dev/compose.go b/pkg/cmd/dev/compose.go index ef9046ced648..50b530ca5590 100644 --- a/pkg/cmd/dev/compose.go +++ b/pkg/cmd/dev/compose.go @@ -48,7 +48,7 @@ func (d *dev) compose(cmd *cobra.Command, _ []string) error { return err } volume := mustGetFlagString(cmd, volumeFlag) - err = d.crossBuild(ctx, crossArgs, targets, "crosslinux", volume) + err = d.crossBuild(ctx, crossArgs, targets, "crosslinux", volume, nil) if err != nil { return err } diff --git a/pkg/cmd/dev/roachprod_stress.go b/pkg/cmd/dev/roachprod_stress.go index 9642f1c356f6..abe737b34c10 100644 --- a/pkg/cmd/dev/roachprod_stress.go +++ b/pkg/cmd/dev/roachprod_stress.go @@ -107,7 +107,7 @@ func (d *dev) roachprodStress(cmd *cobra.Command, commandLine []string) error { if race { crossArgs = append(crossArgs, "--config=race") } - err = d.crossBuild(ctx, crossArgs, targets, "crosslinux", volume) + err = d.crossBuild(ctx, crossArgs, targets, "crosslinux", volume, nil) if err != nil { return err } diff --git a/pkg/cmd/dev/test_binaries.go b/pkg/cmd/dev/test_binaries.go index 20898ee43cc5..a32cfc5f616b 100644 --- a/pkg/cmd/dev/test_binaries.go +++ b/pkg/cmd/dev/test_binaries.go @@ -89,6 +89,7 @@ func makeTestBinariesCmd(runE func(cmd *cobra.Command, args []string) error) *co RunE: runE, } testBinariesCmd.Flags().String(volumeFlag, "bzlhome", "the Docker volume to use as the container home directory (only used for cross builds)") + testBinariesCmd.Flags().StringArray(dockerArgsFlag, []string{}, "additional arguments to pass to Docker (only used for cross builds)") testBinariesCmd.Flags().String(outputFlag, "bin/test_binaries.tar.gz", "the file output path of the archived test binaries") testBinariesCmd.Flags().Bool(raceFlag, false, "produce race builds") testBinariesCmd.Flags().Int(batchSizeFlag, 128, "the number of packages to build per batch") @@ -99,10 +100,11 @@ func makeTestBinariesCmd(runE func(cmd *cobra.Command, args []string) error) *co func (d *dev) testBinaries(cmd *cobra.Command, commandLine []string) error { ctx := cmd.Context() var ( - volume = mustGetFlagString(cmd, volumeFlag) - output = mustGetFlagString(cmd, outputFlag) - race = mustGetFlagBool(cmd, raceFlag) - batchSize = mustGetConstrainedFlagInt(cmd, batchSizeFlag, func(v int) error { + extraDockerArgs = mustGetFlagStringArray(cmd, dockerArgsFlag) + volume = mustGetFlagString(cmd, volumeFlag) + output = mustGetFlagString(cmd, outputFlag) + race = mustGetFlagBool(cmd, raceFlag) + batchSize = mustGetConstrainedFlagInt(cmd, batchSizeFlag, func(v int) error { if v <= 0 { return fmt.Errorf("%s must be greater than zero", batchSizeFlag) } @@ -155,7 +157,7 @@ func (d *dev) testBinaries(cmd *cobra.Command, commandLine []string) error { } binTar := strings.TrimSuffix(output, ".gz") - dockerArgs, err := d.getDockerRunArgs(ctx, volume, false) + dockerArgs, err := d.getDockerRunArgs(ctx, volume, false, extraDockerArgs) if err != nil { return err } diff --git a/pkg/cmd/dev/util.go b/pkg/cmd/dev/util.go index ed48b6c42434..0769302e8416 100644 --- a/pkg/cmd/dev/util.go +++ b/pkg/cmd/dev/util.go @@ -54,6 +54,14 @@ func mustGetFlagString(cmd *cobra.Command, name string) string { return val } +func mustGetFlagStringArray(cmd *cobra.Command, name string) []string { + val, err := cmd.Flags().GetStringArray(name) + if err != nil { + log.Fatalf("unexpected error: %v", err) + } + return val +} + func mustGetFlagStringSlice(cmd *cobra.Command, name string) []string { val, err := cmd.Flags().GetStringSlice(name) if err != nil { From b64c1709e2caf9c3b44925127b9558d5515f29e5 Mon Sep 17 00:00:00 2001 From: zachlite Date: Wed, 26 Apr 2023 13:42:17 -0400 Subject: [PATCH 4/5] ui: enable initial data fetch in insecure mode Previously, `alertDataSync`, the function that populates missing cluster info, did not consider insecure mode when assessing a user's login state. Because the 23.1 test cluster is running in insecure mode, the UI is noticeably missing it's cluster ID. Resolves #102350 Epic: none Release note: None --- pkg/ui/workspaces/db-console/src/redux/alerts.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/pkg/ui/workspaces/db-console/src/redux/alerts.ts b/pkg/ui/workspaces/db-console/src/redux/alerts.ts index 9a8102d64f1f..44e8a5558dad 100644 --- a/pkg/ui/workspaces/db-console/src/redux/alerts.ts +++ b/pkg/ui/workspaces/db-console/src/redux/alerts.ts @@ -653,15 +653,19 @@ export function alertDataSync(store: Store) { // Always refresh health. dispatch(refreshHealth()); + const { Insecure } = getDataFromServer(); // We should not send out requests to the endpoints below if // the user has not successfully logged in since the requests // will always return with a 401 error. - if ( - !state.login || - !state.login.loggedInUser || - state.login.loggedInUser == `` - ) { - return; + // Insecure mode is an exception, where login state is irrelevant. + if (!Insecure) { + if ( + !state.login || + !state.login.loggedInUser || + state.login.loggedInUser == `` + ) { + return; + } } // Load persistent settings which have not yet been loaded. From 94b5a806e0440d882e1dada399a8ad14e561773a Mon Sep 17 00:00:00 2001 From: Rebecca Taft Date: Mon, 24 Apr 2023 17:55:42 -0500 Subject: [PATCH 5/5] sql,clusterversion: add a cluster version for partially visible indexes Fixes #101976 Release note: None --- .../settings/settings-for-tenants.txt | 2 +- docs/generated/settings/settings.html | 2 +- pkg/clusterversion/cockroach_versions.go | 24 ++-- pkg/sql/alter_index_visible.go | 8 ++ pkg/sql/alter_table.go | 6 + pkg/sql/create_index.go | 7 +- pkg/sql/create_table.go | 9 ++ .../mixed_version_partially_visible_index | 104 ++++++++++++++++++ .../BUILD.bazel | 2 +- .../generated_test.go | 7 ++ .../internal/scbuildstmt/create_index.go | 7 ++ pkg/upgrade/upgrades/upgrades.go | 6 + .../schemachange/operation_generator.go | 12 +- 13 files changed, 182 insertions(+), 14 deletions(-) create mode 100644 pkg/sql/logictest/testdata/logic_test/mixed_version_partially_visible_index diff --git a/docs/generated/settings/settings-for-tenants.txt b/docs/generated/settings/settings-for-tenants.txt index 2983b117b591..a5e5992aa6ed 100644 --- a/docs/generated/settings/settings-for-tenants.txt +++ b/docs/generated/settings/settings-for-tenants.txt @@ -294,4 +294,4 @@ trace.opentelemetry.collector string address of an OpenTelemetry trace collecto trace.snapshot.rate duration 0s if non-zero, interval at which background trace snapshots are captured tenant-rw trace.span_registry.enabled boolean true if set, ongoing traces can be seen at https:///#/debug/tracez tenant-rw trace.zipkin.collector string the address of a Zipkin instance to receive traces, as :. If no port is specified, 9411 will be used. tenant-rw -version version 1000023.1-4 set the active cluster version in the format '.' tenant-rw +version version 1000023.1-6 set the active cluster version in the format '.' tenant-rw diff --git a/docs/generated/settings/settings.html b/docs/generated/settings/settings.html index 3d571fe77bb5..dac4e1395217 100644 --- a/docs/generated/settings/settings.html +++ b/docs/generated/settings/settings.html @@ -247,6 +247,6 @@
trace.snapshot.rate
duration0sif non-zero, interval at which background trace snapshots are capturedServerless/Dedicated/Self-Hosted
trace.span_registry.enabled
booleantrueif set, ongoing traces can be seen at https://<ui>/#/debug/tracezServerless/Dedicated/Self-Hosted
trace.zipkin.collector
stringthe address of a Zipkin instance to receive traces, as <host>:<port>. If no port is specified, 9411 will be used.Serverless/Dedicated/Self-Hosted -
version
version1000023.1-4set the active cluster version in the format '<major>.<minor>'Serverless/Dedicated/Self-Hosted +
version
version1000023.1-6set the active cluster version in the format '<major>.<minor>'Serverless/Dedicated/Self-Hosted diff --git a/pkg/clusterversion/cockroach_versions.go b/pkg/clusterversion/cockroach_versions.go index 723513d90f20..7b62ebfb7ff2 100644 --- a/pkg/clusterversion/cockroach_versions.go +++ b/pkg/clusterversion/cockroach_versions.go @@ -538,14 +538,18 @@ const ( // the process of upgrading from previous supported releases to 23.2. V23_2Start + // V23_2TTLAllowDescPK is the version where TTL tables can have descending + // primary keys. + V23_2TTLAllowDescPK + + // V23_2_PartiallyVisibleIndexes is the version where partially visible + // indexes are enabled. + V23_2_PartiallyVisibleIndexes + // ************************************************* // Step 1b: Add new version for 23.2 development here. // Do not add new versions to a patch release. // ************************************************* - - // V23_2TTLAllowDescPK is the version where TTL tables can have descending - // primary keys. - V23_2TTLAllowDescPK ) func (k Key) String() string { @@ -940,15 +944,19 @@ var rawVersionsSingleton = keyedVersions{ Key: V23_2Start, Version: roachpb.Version{Major: 23, Minor: 1, Internal: 2}, }, + { + Key: V23_2TTLAllowDescPK, + Version: roachpb.Version{Major: 23, Minor: 1, Internal: 4}, + }, + { + Key: V23_2_PartiallyVisibleIndexes, + Version: roachpb.Version{Major: 23, Minor: 1, Internal: 6}, + }, // ************************************************* // Step 2b: Add new version gates for 23.2 development here. // Do not add new versions to a patch release. // ************************************************* - { - Key: V23_2TTLAllowDescPK, - Version: roachpb.Version{Major: 23, Minor: 1, Internal: 4}, - }, } // developmentBranch must true on the main development branch but diff --git a/pkg/sql/alter_index_visible.go b/pkg/sql/alter_index_visible.go index 8874be5c820b..9bcd5cbb3cdd 100644 --- a/pkg/sql/alter_index_visible.go +++ b/pkg/sql/alter_index_visible.go @@ -13,6 +13,7 @@ package sql import ( "context" + "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/sql/catalog" "github.com/cockroachdb/cockroach/pkg/sql/catalog/descpb" "github.com/cockroachdb/cockroach/pkg/sql/catalog/tabledesc" @@ -20,6 +21,7 @@ import ( "github.com/cockroachdb/cockroach/pkg/sql/pgwire/pgerror" "github.com/cockroachdb/cockroach/pkg/sql/privilege" "github.com/cockroachdb/cockroach/pkg/sql/sem/tree" + "github.com/cockroachdb/cockroach/pkg/util/errorutil/unimplemented" "github.com/cockroachdb/cockroach/pkg/util/log/eventpb" ) @@ -84,6 +86,12 @@ func (n *alterIndexVisibleNode) startExec(params runParams) error { return pgerror.Newf(pgcode.FeatureNotSupported, "primary index cannot be invisible") } + activeVersion := params.ExecCfg().Settings.Version.ActiveVersion(params.ctx) + if !activeVersion.IsActive(clusterversion.V23_2_PartiallyVisibleIndexes) && + n.n.Invisibility > 0.0 && n.n.Invisibility < 1.0 { + return unimplemented.New("partially visible indexes", "partially visible indexes are not yet supported") + } + // Warn if this invisible index may still be used to enforce constraint check // behind the scene. if n.n.Invisibility != 0.0 { diff --git a/pkg/sql/alter_table.go b/pkg/sql/alter_table.go index df8fe577fbe4..a97ec7eea61c 100644 --- a/pkg/sql/alter_table.go +++ b/pkg/sql/alter_table.go @@ -295,6 +295,12 @@ func (n *alterTableNode) startExec(params runParams) error { return err } } + + activeVersion := params.ExecCfg().Settings.Version.ActiveVersion(params.ctx) + if !activeVersion.IsActive(clusterversion.V23_2_PartiallyVisibleIndexes) && + d.Invisibility > 0.0 && d.Invisibility < 1.0 { + return unimplemented.New("partially visible indexes", "partially visible indexes are not yet supported") + } idx := descpb.IndexDescriptor{ Name: string(d.Name), Unique: true, diff --git a/pkg/sql/create_index.go b/pkg/sql/create_index.go index 42f2f69bca9c..2cde1b4a8915 100644 --- a/pkg/sql/create_index.go +++ b/pkg/sql/create_index.go @@ -167,6 +167,7 @@ func makeIndexDescriptor( // Replace expression index elements with hidden virtual computed columns. // The virtual columns are added as mutation columns to tableDesc. + activeVersion := params.ExecCfg().Settings.Version.ActiveVersion(params.ctx) if err := replaceExpressionElemsWithVirtualCols( params.ctx, tableDesc, @@ -175,7 +176,7 @@ func makeIndexDescriptor( n.Inverted, false, /* isNewTable */ params.p.SemaCtx(), - params.ExecCfg().Settings.Version.ActiveVersion(params.ctx), + activeVersion, ); err != nil { return nil, err } @@ -198,6 +199,10 @@ func makeIndexDescriptor( return nil, err } + if !activeVersion.IsActive(clusterversion.V23_2_PartiallyVisibleIndexes) && + n.Invisibility > 0.0 && n.Invisibility < 1.0 { + return nil, unimplemented.New("partially visible indexes", "partially visible indexes are not yet supported") + } indexDesc := descpb.IndexDescriptor{ Name: string(n.Name), Unique: n.Unique, diff --git a/pkg/sql/create_table.go b/pkg/sql/create_table.go index c3f7aa472492..344c77c0ed5b 100644 --- a/pkg/sql/create_table.go +++ b/pkg/sql/create_table.go @@ -19,6 +19,7 @@ import ( "time" "github.com/cockroachdb/cockroach/pkg/build" + "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/docs" "github.com/cockroachdb/cockroach/pkg/jobs" "github.com/cockroachdb/cockroach/pkg/jobs/jobspb" @@ -1788,6 +1789,10 @@ func NewTableDesc( if err := checkIndexColumns(&desc, d.Columns, d.Storing, d.Inverted); err != nil { return nil, err } + if !version.IsActive(clusterversion.V23_2_PartiallyVisibleIndexes) && + d.Invisibility > 0.0 && d.Invisibility < 1.0 { + return nil, unimplemented.New("partially visible indexes", "partially visible indexes are not yet supported") + } idx := descpb.IndexDescriptor{ Name: string(d.Name), StoreColumnNames: d.Storing.ToStrings(), @@ -1900,6 +1905,10 @@ func NewTableDesc( ); err != nil { return nil, err } + if !version.IsActive(clusterversion.V23_2_PartiallyVisibleIndexes) && + d.Invisibility > 0.0 && d.Invisibility < 1.0 { + return nil, unimplemented.New("partially visible indexes", "partially visible indexes are not yet supported") + } idx := descpb.IndexDescriptor{ Name: string(d.Name), Unique: true, diff --git a/pkg/sql/logictest/testdata/logic_test/mixed_version_partially_visible_index b/pkg/sql/logictest/testdata/logic_test/mixed_version_partially_visible_index new file mode 100644 index 000000000000..54d2ce9ae9b5 --- /dev/null +++ b/pkg/sql/logictest/testdata/logic_test/mixed_version_partially_visible_index @@ -0,0 +1,104 @@ +# LogicTest: cockroach-go-testserver-upgrade-to-master + +# Verify that all nodes are running 22.2 binaries. + +query T nodeidx=0 +SELECT crdb_internal.node_executable_version() +---- +22.2 + +query T nodeidx=1 +SELECT crdb_internal.node_executable_version() +---- +22.2 + +query T nodeidx=2 +SELECT crdb_internal.node_executable_version() +---- +22.2 + +upgrade 0 + +user root nodeidx=0 + +# These statements should fail with an unimplemented error. +statement error unimplemented: partially visible indexes are not yet supported +CREATE TABLE t1 (k INT PRIMARY KEY, v INT, INDEX (v) VISIBILITY 0.5, FAMILY (k, v)) + +statement ok +CREATE TABLE t2 (k INT PRIMARY KEY, v INT, FAMILY (k, v)) + +statement error unimplemented: partially visible indexes are not yet supported +CREATE INDEX t2_v_idx ON t2 (v) VISIBILITY 0.5 + +statement ok +CREATE INDEX t2_v2_idx ON t2 (v) + +statement error unimplemented: partially visible indexes are not yet supported +ALTER INDEX t2_v2_idx VISIBILITY 0.5 + +# It's ok to use the VISIBILITY syntax as long as it's either 0 or 1. +statement ok +ALTER INDEX t2_v2_idx VISIBILITY 1.0 + +statement ok +ALTER INDEX t2_v2_idx VISIBILITY 0.0 + +user root nodeidx=1 + +# Index t2_v2_idx should be NOT VISIBLE. +query TT +SHOW CREATE TABLE t2 +---- +t2 CREATE TABLE public.t2 ( + k INT8 NOT NULL, + v INT8 NULL, + CONSTRAINT t2_pkey PRIMARY KEY (k ASC), + INDEX t2_v2_idx (v ASC) NOT VISIBLE, + FAMILY fam_0_k_v (k, v) + ) + +# These statements should fail with a parsing error. +statement error at or near "visibility": syntax error +CREATE TABLE t3 (k INT PRIMARY KEY, v INT, INDEX (v) VISIBILITY 0.5, FAMILY (k, v)) + +statement ok +CREATE TABLE t4 (k INT PRIMARY KEY, v INT, FAMILY (k, v)) + +statement error at or near "visibility": syntax error +CREATE INDEX t4_v_idx ON t4 (v) VISIBILITY 0.5 + +statement ok +CREATE INDEX t4_v2_idx ON t4 (v) + +statement error at or near "visibility": syntax error +ALTER INDEX t4_v2_idx VISIBILITY 0.5 + +statement ok +ALTER INDEX t4_v2_idx NOT VISIBLE + +user root nodeidx=0 + +# Index t2_v2_idx should be NOT VISIBLE. +query TT +SHOW CREATE TABLE t2 +---- +t2 CREATE TABLE public.t2 ( + k INT8 NOT NULL, + v INT8 NULL, + CONSTRAINT t2_pkey PRIMARY KEY (k ASC), + INDEX t2_v2_idx (v ASC) NOT VISIBLE, + FAMILY fam_0_k_v (k, v) + ) + +# Index t4_v2_idx should be NOT VISIBLE. +query TT +SHOW CREATE TABLE t4 +---- +t4 CREATE TABLE public.t4 ( + k INT8 NOT NULL, + v INT8 NULL, + CONSTRAINT t4_pkey PRIMARY KEY (k ASC), + INDEX t4_v2_idx (v ASC) NOT VISIBLE, + FAMILY fam_0_k_v (k, v) + ) diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/BUILD.bazel b/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/BUILD.bazel index bc5161f66189..865fbe3f2745 100644 --- a/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/BUILD.bazel +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/BUILD.bazel @@ -11,7 +11,7 @@ go_test( "//pkg/cmd/cockroach-short", # keep "//pkg/sql/logictest:testdata", # keep ], - shard_count = 8, + shard_count = 9, tags = [ "cpu:2", ], diff --git a/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/generated_test.go b/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/generated_test.go index 9fbfbce11465..e32c2ee0b6b2 100644 --- a/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/generated_test.go +++ b/pkg/sql/logictest/tests/cockroach-go-testserver-upgrade-to-master/generated_test.go @@ -107,6 +107,13 @@ func TestLogic_mixed_version_new_system_privileges( runLogicTest(t, "mixed_version_new_system_privileges") } +func TestLogic_mixed_version_partially_visible_index( + t *testing.T, +) { + defer leaktest.AfterTest(t)() + runLogicTest(t, "mixed_version_partially_visible_index") +} + func TestLogic_mixed_version_range_tombstones( t *testing.T, ) { diff --git a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/create_index.go b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/create_index.go index 46336b2d596c..173a3c6510c8 100644 --- a/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/create_index.go +++ b/pkg/sql/schemachanger/scbuild/internal/scbuildstmt/create_index.go @@ -11,11 +11,13 @@ package scbuildstmt import ( + "context" "fmt" "sort" "strconv" "strings" + "github.com/cockroachdb/cockroach/pkg/clusterversion" "github.com/cockroachdb/cockroach/pkg/docs" "github.com/cockroachdb/cockroach/pkg/geo/geoindex" "github.com/cockroachdb/cockroach/pkg/sql/catalog" @@ -81,6 +83,11 @@ func CreateIndex(b BuildCtx, n *tree.CreateIndex) { b.IncrementSchemaChangeIndexCounter("multi_column_inverted_index") } } + activeVersion := b.EvalCtx().Settings.Version.ActiveVersion(context.TODO()) + if !activeVersion.IsActive(clusterversion.V23_2_PartiallyVisibleIndexes) && + n.Invisibility > 0.0 && n.Invisibility < 1.0 { + panic(unimplemented.New("partially visible indexes", "partially visible indexes are not yet supported")) + } var idxSpec indexSpec idxSpec.secondary = &scpb.SecondaryIndex{ Index: scpb.Index{ diff --git a/pkg/upgrade/upgrades/upgrades.go b/pkg/upgrade/upgrades/upgrades.go index 1d2faddea175..eda16e2df7c5 100644 --- a/pkg/upgrade/upgrades/upgrades.go +++ b/pkg/upgrade/upgrades/upgrades.go @@ -310,6 +310,12 @@ var upgrades = []upgradebase.Upgrade{ createActivityUpdateJobMigration, "create statement_activity and transaction_activity job", ), + upgrade.NewTenantUpgrade( + "enable partially visible indexes", + toCV(clusterversion.V23_2_PartiallyVisibleIndexes), + upgrade.NoPrecondition, + NoTenantUpgradeFunc, + ), } func init() { diff --git a/pkg/workload/schemachange/operation_generator.go b/pkg/workload/schemachange/operation_generator.go index e866c276f451..f6b57ce0f289 100644 --- a/pkg/workload/schemachange/operation_generator.go +++ b/pkg/workload/schemachange/operation_generator.go @@ -1051,8 +1051,16 @@ func (og *operationGenerator) createIndex(ctx context.Context, tx pgx.Tx) (*opSt visibility := 1.0 if notvisible := og.randIntn(20) == 0; notvisible { visibility = 0.0 - if og.randIntn(2) == 0 { - visibility = og.params.rng.Float64() + partiallyVisibleIndexNotSupported, err := isClusterVersionLessThan( + ctx, tx, clusterversion.ByKey(clusterversion.V23_2_PartiallyVisibleIndexes), + ) + if err != nil { + return nil, err + } + if !partiallyVisibleIndexNotSupported { + if og.randIntn(2) == 0 { + visibility = og.params.rng.Float64() + } } }