Skip to content

Commit 540d645

Browse files
craig[bot]spilchen
andcommitted
150918: sql/inspect: run INSPECT against a single index r=spilchen a=spilchen Previously, the INSPECT command was a no-op that performed no actual checking. This change implements the first consistency check for INSPECT: index consistency checking, currently supporting a single index at a time. The consistency checking uses a full outer join between the primary index and secondary index access paths to identify rows that exist in one index but not the other, detecting potential corruption or inconsistency issues. This new functionality is integrated into the INSPECT job and triggered through SCRUB when the enable_scrub_job setting is enabled. Future work will expose this through direct INSPECT SQL commands. Note for reviewers: - Several tests currently generate internal errors in the SQL query engine. These are not logged as issues for now and will be resolved in subsequent work. Release note: None Informs #148299 Epic: CRDB-30356 152910: sql/sem/tree: fix width handling for BIT column default values r=spilchen a=spilchen Previously, when a column was being added or dropped and had NOT NULL with no default value, the parseComputedExpr logic would generate a placeholder value to avoid NULL violations (see #46285 for historical context). For columns of type BIT(n), this fallback value was incorrectly set as BIT(0), which has a width mismatch and caused errors during row insertions or deletions. This change ensures that the fallback value matches the column's specified BIT(n) width, allowing operations to proceed without errors during schema changes involving such columns. Fixes #152326 Fixes #149567 Fixes #151451 Release note (bug fix): Fixed a bug where INSERTs could fail with a type checking error while adding a BIT(n) column. Epic: None Co-authored-by: Matt Spilchen <[email protected]>
3 parents 6766271 + 769e407 + b3288da commit 540d645

29 files changed

+2979
-61
lines changed

pkg/ccl/schemachangerccl/sctestbackupccl/backup_base_generated_test.go

Lines changed: 28 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

pkg/sql/exec_util.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2098,6 +2098,8 @@ type InspectTestingKnobs struct {
20982098
// OnInspectJobStart is called just before the inspect job begins execution.
20992099
// If it returns an error, the job fails immediately.
21002100
OnInspectJobStart func() error
2101+
// InspectIssueLogger is an override to the default issue logger.
2102+
InspectIssueLogger interface{}
21012103
}
21022104

21032105
// ModuleTestingKnobs implements the base.ModuleTestingKnobs interface.

pkg/sql/inspect/BUILD.bazel

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ load("@io_bazel_rules_go//go:def.bzl", "go_library", "go_test")
33
go_library(
44
name = "inspect",
55
srcs = [
6+
"index_consistency_check.go",
67
"inspect_job.go",
78
"inspect_processor.go",
89
"issue.go",
@@ -16,20 +17,31 @@ go_library(
1617
"//pkg/jobs",
1718
"//pkg/jobs/jobspb",
1819
"//pkg/roachpb",
20+
"//pkg/security/username",
1921
"//pkg/settings",
2022
"//pkg/settings/cluster",
2123
"//pkg/sql",
24+
"//pkg/sql/catalog",
25+
"//pkg/sql/catalog/catenumpb",
2226
"//pkg/sql/catalog/descpb",
2327
"//pkg/sql/catalog/descs",
2428
"//pkg/sql/execinfra",
2529
"//pkg/sql/execinfrapb",
2630
"//pkg/sql/isql",
31+
"//pkg/sql/lexbase",
32+
"//pkg/sql/pgwire/pgcode",
33+
"//pkg/sql/pgwire/pgerror",
2734
"//pkg/sql/physicalplan",
2835
"//pkg/sql/rowexec",
36+
"//pkg/sql/sem/idxtype",
2937
"//pkg/sql/sem/tree",
38+
"//pkg/sql/sessiondata",
39+
"//pkg/sql/sessiondatapb",
40+
"//pkg/sql/spanutils",
3041
"//pkg/sql/types",
3142
"//pkg/util/ctxgroup",
3243
"//pkg/util/log",
44+
"//pkg/util/timeutil",
3345
"//pkg/util/tracing",
3446
"@com_github_cockroachdb_errors//:errors",
3547
"@com_github_cockroachdb_redact//:redact",
@@ -39,6 +51,7 @@ go_library(
3951
go_test(
4052
name = "inspect_test",
4153
srcs = [
54+
"index_consistency_check_test.go",
4255
"inspect_job_test.go",
4356
"inspect_processor_test.go",
4457
"issue_test.go",
@@ -48,14 +61,21 @@ go_test(
4861
embed = [":inspect"],
4962
deps = [
5063
"//pkg/base",
64+
"//pkg/keys",
65+
"//pkg/kv",
5166
"//pkg/roachpb",
5267
"//pkg/security/securityassets",
5368
"//pkg/security/securitytest",
5469
"//pkg/server",
5570
"//pkg/settings/cluster",
5671
"//pkg/sql",
72+
"//pkg/sql/catalog",
73+
"//pkg/sql/catalog/desctestutils",
5774
"//pkg/sql/execinfra",
5875
"//pkg/sql/execinfrapb",
76+
"//pkg/sql/rowenc",
77+
"//pkg/sql/sem/tree",
78+
"//pkg/sql/sessiondata",
5979
"//pkg/testutils",
6080
"//pkg/testutils/serverutils",
6181
"//pkg/testutils/sqlutils",

0 commit comments

Comments
 (0)