Skip to content

Commit 62e7d29

Browse files
committed
sql: add INSPECT to DRT runs
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
1 parent a652bfc commit 62e7d29

File tree

3 files changed

+54
-0
lines changed

3 files changed

+54
-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
}

0 commit comments

Comments
 (0)