Skip to content

Commit d36e5f2

Browse files
craig[bot]bghal
andcommitted
154635: sql: skip flaky ngpsql roachtests r=rafiss a=bghal The tests are timing out. ``` Failed Import_string_array [30 s] Stack Trace: ``` ``` Failed Prepended_messages [30 s] Stack Trace: ``` Fixes: #154004 Fixes: #153691 Release note: None 154678: sql: give cluster time to upgrade under test r=rafiss a=bghal In local 3-node testing the upgrade takes ~80s to get to the cluster version bump so relaxing the retries helps the tests pass. Epic: none Fixes: #154550 Fixes: #154077 Fixes: #155046 Release note: None 154873: sql: implement `INSPECT` command r=bghal a=bghal This change implements the `INSPECT` command which runs inspect jobs to perform consistency validation checks on tables and their indexes. Informs: #148365, #155056 Epic: CRDB-30356 Release note (sql change): The `INSPECT` command runs consistency validation check jobs against tables or databases and specified indexes. Co-authored-by: Brendan Gerrity <[email protected]>
4 parents 0affc8d + df38d38 + 06c470b + bead324 commit d36e5f2

File tree

27 files changed

+713
-301
lines changed

27 files changed

+713
-301
lines changed

pkg/cmd/roachtest/tests/npgsql_blocklist.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -662,6 +662,8 @@ var npgsqlBlocklist = blocklist{
662662

663663
var npgsqlIgnoreList = blocklist{
664664
`Npgsql.Tests.ConnectionTests(Multiplexing).Fail_connect_then_succeed(True)`: "flaky",
665+
`Npgsql.Tests.CopyTests(Multiplexing).Import_string_array`: "flaky",
666+
`Npgsql.Tests.CopyTests(Multiplexing).Prepended_messages`: "flaky",
665667
`Npgsql.Tests.TransactionTests(NonMultiplexing).Failed_transaction_on_close_with_custom_timeout`: "flaky",
666668
`Npgsql.Tests.TransactionTests(Multiplexing).Failed_transaction_on_close_with_custom_timeout`: "flaky",
667669
}

pkg/jobs/resultcols.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ var OnlineRestoreJobExecutionResultHeader = colinfo.ResultColumns{
3838
{Name: "background_download_job_id", Typ: types.Int},
3939
}
4040

41+
// InspectJobExecutionResultHeader is the header for INSPECT job results.
42+
var InspectJobExecutionResultHeader = colinfo.ResultColumns{
43+
{Name: "job_id", Typ: types.Int},
44+
{Name: "status", Typ: types.String},
45+
}
46+
4147
// DetachedJobExecutionResultHeader is the header for various job commands when
4248
// job executes in detached mode (i.e. the caller doesn't wait for job completion).
4349
var DetachedJobExecutionResultHeader = colinfo.ResultColumns{

pkg/server/server.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ import (
100100
"github.com/cockroachdb/cockroach/pkg/sql/flowinfra"
101101
_ "github.com/cockroachdb/cockroach/pkg/sql/gcjob" // register jobs declared outside of pkg/sql
102102
_ "github.com/cockroachdb/cockroach/pkg/sql/importer" // register jobs/planHooks declared outside of pkg/sql
103-
_ "github.com/cockroachdb/cockroach/pkg/sql/inspect" // register jobs declared outside of pkg/sql
103+
_ "github.com/cockroachdb/cockroach/pkg/sql/inspect" // register job and planHook declared outside of pkg/sql
104104
"github.com/cockroachdb/cockroach/pkg/sql/optionalnodeliveness"
105105
"github.com/cockroachdb/cockroach/pkg/sql/pgwire"
106106
_ "github.com/cockroachdb/cockroach/pkg/sql/schemachanger/scjob" // register jobs declared outside of pkg/sql

pkg/sql/BUILD.bazel

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ go_library(
141141
"information_schema.go",
142142
"insert.go",
143143
"insert_fast_path.go",
144-
"inspect_node.go",
144+
"inspect_job.go",
145145
"instrumentation.go",
146146
"internal.go",
147147
"internal_result_channel.go",

pkg/sql/alter_index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ func (p *planner) AlterIndex(ctx context.Context, n *tree.AlterIndex) (planNode,
4040
return nil, err
4141
}
4242

43-
_, tableDesc, index, err := p.getTableAndIndex(ctx, &n.Index, privilege.CREATE, true /* skipCache */)
43+
_, tableDesc, index, err := p.GetTableAndIndex(ctx, &n.Index, privilege.CREATE, true /* skipCache */)
4444
if err != nil {
4545
return nil, err
4646
}

pkg/sql/catalog/descriptor.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -341,7 +341,7 @@ type DatabaseDescriptor interface {
341341
type TableDescriptor interface {
342342
Descriptor
343343

344-
// TableDesc returns the backing protobuf for this database.
344+
// TableDesc returns the backing protobuf for this table.
345345
TableDesc() *descpb.TableDescriptor
346346

347347
// GetState returns the raw state of this descriptor. This information is

pkg/sql/comment_on_index.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ func (p *planner) CommentOnIndex(ctx context.Context, n *tree.CommentOnIndex) (p
3434
return nil, err
3535
}
3636

37-
_, tableDesc, index, err := p.getTableAndIndex(ctx, &n.Index, privilege.CREATE, true /* skipCache */)
37+
_, tableDesc, index, err := p.GetTableAndIndex(ctx, &n.Index, privilege.CREATE, true /* skipCache */)
3838
if err != nil {
3939
return nil, err
4040
}

pkg/sql/importer/import_job.go

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -328,24 +328,30 @@ func (r *importResumer) Resume(ctx context.Context, execCtx interface{}) error {
328328
}
329329
tblDesc := tabledesc.NewBuilder(table.Desc).BuildImmutableTable()
330330
if len(tblDesc.PublicNonPrimaryIndexes()) > 0 {
331-
jobID, err := sql.TriggerInspectJob(
331+
checks, err := sql.InspectChecksForTable(ctx, nil /* p */, tblDesc)
332+
if err != nil {
333+
return err
334+
}
335+
336+
job, err := sql.TriggerInspectJob(
332337
ctx,
333338
fmt.Sprintf("import-validation-%s", tblDesc.GetName()),
334339
p.ExecCfg(),
335-
tblDesc,
340+
nil, /* txn */
341+
checks,
336342
setPublicTimestamp,
337343
)
338344
if err != nil {
339345
return errors.Wrapf(err, "failed to trigger inspect for import validation for table %s", tblDesc.GetName())
340346
}
341-
log.Eventf(ctx, "triggered inspect job %d for import validation for table %s with AOST %s", jobID, tblDesc.GetName(), setPublicTimestamp)
347+
log.Eventf(ctx, "triggered inspect job %d for import validation for table %s with AOST %s", job.ID(), tblDesc.GetName(), setPublicTimestamp)
342348

343349
// For sync mode, wait for the inspect job to complete.
344350
if validationMode == ImportRowCountValidationSync {
345-
if err := p.ExecCfg().JobRegistry.WaitForJobs(ctx, []jobspb.JobID{jobID}); err != nil {
346-
return errors.Wrapf(err, "failed to wait for inspect job %d for table %s", jobID, tblDesc.GetName())
351+
if err := p.ExecCfg().JobRegistry.WaitForJobs(ctx, []jobspb.JobID{job.ID()}); err != nil {
352+
return errors.Wrapf(err, "failed to wait for inspect job %d for table %s", job.ID(), tblDesc.GetName())
347353
}
348-
log.Eventf(ctx, "inspect job %d completed for table %s", jobID, tblDesc.GetName())
354+
log.Eventf(ctx, "inspect job %d completed for table %s", job.ID(), tblDesc.GetName())
349355
}
350356
}
351357
}

pkg/sql/inspect/BUILD.bazel

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ go_library(
77
"inspect_job.go",
88
"inspect_logger.go",
99
"inspect_metrics.go",
10+
"inspect_plan.go",
1011
"inspect_processor.go",
1112
"issue.go",
1213
"log_sink.go",
@@ -18,6 +19,7 @@ go_library(
1819
importpath = "github.com/cockroachdb/cockroach/pkg/sql/inspect",
1920
visibility = ["//visibility:public"],
2021
deps = [
22+
"//pkg/clusterversion",
2123
"//pkg/jobs",
2224
"//pkg/jobs/jobfrontier",
2325
"//pkg/jobs/jobspb",
@@ -30,6 +32,7 @@ go_library(
3032
"//pkg/sql",
3133
"//pkg/sql/catalog",
3234
"//pkg/sql/catalog/catenumpb",
35+
"//pkg/sql/catalog/colinfo",
3336
"//pkg/sql/catalog/descpb",
3437
"//pkg/sql/catalog/descs",
3538
"//pkg/sql/execinfra",
@@ -39,6 +42,7 @@ go_library(
3942
"//pkg/sql/pgwire/pgcode",
4043
"//pkg/sql/pgwire/pgerror",
4144
"//pkg/sql/physicalplan",
45+
"//pkg/sql/privilege",
4246
"//pkg/sql/rowexec",
4347
"//pkg/sql/sem/idxtype",
4448
"//pkg/sql/sem/tree",

pkg/sql/inspect/index_consistency_check_test.go

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -438,8 +438,7 @@ func TestDetectIndexConsistencyErrors(t *testing.T) {
438438
FROM generate_series(1001, 2000) AS gs1;`,
439439
)
440440

441-
// TODO(148365): Run INSPECT instead of SCRUB.
442-
_, err = db.Exec(`SET enable_scrub_job=true`)
441+
_, err = db.Exec(`SET enable_inspect_command=true`)
443442
require.NoError(t, err)
444443

445444
// If not using timestamp before corruption, get current timestamp
@@ -451,8 +450,8 @@ func TestDetectIndexConsistencyErrors(t *testing.T) {
451450

452451
// Use the absolute timestamp in nanoseconds for inspect command
453452
absoluteTimestamp := fmt.Sprintf("'%d'", expectedASOFTime.UnixNano())
454-
scrubQuery := fmt.Sprintf(`EXPERIMENTAL SCRUB TABLE test.t AS OF SYSTEM TIME %s WITH OPTIONS INDEX ALL`, absoluteTimestamp)
455-
_, err = db.Query(scrubQuery)
453+
inspectQuery := fmt.Sprintf(`INSPECT TABLE test.t AS OF SYSTEM TIME %s WITH OPTIONS INDEX ALL`, absoluteTimestamp)
454+
_, err = db.Query(inspectQuery)
456455
if tc.expectedErrRegex == "" {
457456
require.NoError(t, err)
458457
require.Equal(t, 0, issueLogger.numIssuesFound())
@@ -587,10 +586,9 @@ func TestIndexConsistencyWithReservedWordColumns(t *testing.T) {
587586
`CREATE INDEX idx_having ON test.reserved_table ("having", "group")`,
588587
)
589588

590-
// TODO(148365): Run INSPECT instead of SCRUB.
591-
_, err := db.Exec(`SET enable_scrub_job=true`)
589+
_, err := db.Exec(`SET enable_inspect_command=true`)
592590
require.NoError(t, err)
593-
_, err = db.Query(`EXPERIMENTAL SCRUB TABLE test.reserved_table WITH OPTIONS INDEX ALL`)
591+
_, err = db.Query(`INSPECT TABLE test.reserved_table WITH OPTIONS INDEX ALL`)
594592
require.NoError(t, err, "should succeed on table with reserved word column names")
595593
require.Equal(t, 0, issueLogger.numIssuesFound(), "No issues should be found in happy path test")
596594

0 commit comments

Comments
 (0)