Skip to content

Commit 01a8e6a

Browse files
craig[bot]bghalcthumuluru-crdb
committed
158021: sql: add `INSPECT` to DRT runs r=bghal a=bghal This change adds a daily `INSPECT` operation to DRT. It is currently limited to index consistency checks; more checks are planned. Fixes: #148942 Epic: CRDB-55075 Release note: None 158262: kvserver: skip `TestAdminScatterWithDrainingNodes` test in DRPC mode r=cthumuluru-crdb a=cthumuluru-crdb `TestAdminScatterWithDrainingNodes` is failing at random when DRPC is enabled. The issue is specific to DRPC and the failure is reproducible once every 25 runs. The issue is not reproducible with cluster setting `SET CLUSTER SETTING sql.stats.flush.enabled=false` set to false to turn off stats flush. Re-enable the test once the underlying issue is resolved. Fixes: #156372 Epic: None Release note: None Co-authored-by: Brendan Gerrity <brendan.gerrity@cockroachlabs.com> Co-authored-by: Chandra Thumuluru <chandra.thumuluru@cockroachlabs.com>
3 parents 88c3f1d + 62e7d29 + deb903b commit 01a8e6a

File tree

4 files changed

+59
-0
lines changed

4 files changed

+59
-0
lines changed

pkg/cmd/roachtest/operations/BUILD.bazel

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ go_library(
1515
"disk_stall.go",
1616
"grant_revoke_all.go",
1717
"grant_role.go",
18+
"inspect.go",
1819
"license_throttle.go",
1920
"manual_compaction.go",
2021
"network_partition.go",
@@ -41,6 +42,7 @@ go_library(
4142
"//pkg/cmd/roachtest/roachtestutil",
4243
"//pkg/cmd/roachtest/tests",
4344
"//pkg/sql/catalog/catpb",
45+
"//pkg/sql/lexbase",
4446
"//pkg/sql/randgen",
4547
"//pkg/sql/sem/tree",
4648
"//pkg/sql/types",
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
// Copyright 2025 The Cockroach Authors.
2+
//
3+
// Use of this software is governed by the CockroachDB Software License
4+
// included in the /LICENSE file.
5+
6+
package operations
7+
8+
import (
9+
"context"
10+
"fmt"
11+
"time"
12+
13+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/cluster"
14+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/operation"
15+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/operations/helpers"
16+
"github.com/cockroachdb/cockroach/pkg/cmd/roachtest/registry"
17+
"github.com/cockroachdb/cockroach/pkg/sql/lexbase"
18+
)
19+
20+
func runInspect(
21+
ctx context.Context, o operation.Operation, c cluster.Cluster,
22+
) registry.OperationCleanup {
23+
conn := c.Conn(ctx, o.L(), 1)
24+
defer conn.Close()
25+
26+
_, err := conn.ExecContext(ctx, "SET enable_inspect_command = true;")
27+
if err != nil {
28+
o.Fatal(err)
29+
}
30+
31+
dbName := helpers.PickRandomDB(ctx, o, conn, []string{} /* excludeDBs */)
32+
33+
o.Status(fmt.Sprintf("inspecting database %s", dbName))
34+
_, err = conn.ExecContext(ctx, fmt.Sprintf("INSPECT DATABASE %s", lexbase.EscapeSQLIdent(dbName)))
35+
if err != nil {
36+
o.Fatal(err)
37+
}
38+
39+
return nil
40+
}
41+
42+
func registerInspect(r registry.Registry) {
43+
r.AddOperation(registry.OperationSpec{
44+
Name: "inspect/database",
45+
Owner: registry.OwnerSQLFoundations,
46+
Timeout: 24 * time.Hour,
47+
CompatibleClouds: registry.AllClouds,
48+
CanRunConcurrently: registry.OperationCanRunConcurrently,
49+
Run: runInspect,
50+
})
51+
}

pkg/cmd/roachtest/operations/register.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,5 @@ func RegisterOperations(r registry.Registry) {
3434
registerSessionVariables(r)
3535
registerDebugZip(r)
3636
changefeeds.RegisterChangefeeds(r)
37+
registerInspect(r)
3738
}

pkg/kv/kvserver/scatter_test.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,11 @@ func TestAdminScatterWithDrainingNodes(t *testing.T) {
4545
const drainingNodeID = drainingServerIdx + 1
4646
tc := testcluster.StartTestCluster(
4747
t, 2, base.TestClusterArgs{
48+
ServerArgs: base.TestServerArgs{
49+
// TODO(server): test is timing out when DRPC is enabled.
50+
// Investigate and re-enable once the issue is resolved.
51+
DefaultDRPCOption: base.TestDRPCDisabled,
52+
},
4853
ReplicationMode: base.ReplicationManual,
4954
},
5055
)

0 commit comments

Comments
 (0)