Skip to content

sql/importer: enable async row count validation by default#163543

Merged
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:inspect-enable-for-import
Feb 17, 2026
Merged

sql/importer: enable async row count validation by default#163543
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:inspect-enable-for-import

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented Feb 14, 2026

Row count validation after IMPORT is now enabled by default in async mode. After an IMPORT completes, a background INSPECT job validates that the imported row count matches expectations.

To make the background INSPECT job discoverable, this commit adds an inspect_job_id column to the IMPORT statement result output. When an INSPECT job is triggered, the column contains that job's ID; otherwise it is NULL.

The bulkio.import.row_count_validation.unsafe.mode cluster setting is made public under the name bulkio.import.row_count_validation.mode, and the metamorphic test default no longer includes "off" since validation is now considered stable.

Resolves: #161279
Resolves: #155472

Release note (sql change): Row count validation after IMPORT is now enabled by default in async mode. After an IMPORT completes, a background INSPECT job validates that the imported row count matches expectations. The IMPORT result now includes an inspect_job_id column so the INSPECT job can be viewed separately. The bulkio.import.row_count_validation.mode cluster setting controls this behavior, with valid values of off, async (default), and sync.

@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io bot commented Feb 14, 2026

😎 Merged successfully - details.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@rafiss rafiss force-pushed the inspect-enable-for-import branch from c3f8e9b to aafb676 Compare February 16, 2026 17:19
@rafiss rafiss marked this pull request as ready for review February 16, 2026 18:47
@rafiss rafiss requested review from a team as code owners February 16, 2026 18:47
@rafiss rafiss requested review from a team, dt, jasonlmfong and yuzefovich and removed request for a team and jasonlmfong February 16, 2026 18:47
@yuzefovich yuzefovich requested review from ZhouXing19 and mw5h and removed request for yuzefovich February 16, 2026 20:50
Copy link
Copy Markdown
Contributor

@spilchen spilchen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice improvement with the new inspect job column

@spilchen made 3 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on dt, mw5h, rafiss, and ZhouXing19).


pkg/sql/pgwire/command_result.go line 749 at r1 (raw file):

// Get the column index for job id based on the result header defined in
// jobs.ImportJobExecutionResultHeader and jobs.DetachedJobExecutionResultHeader.
func init() {

shouldn't this function still guard against drift in jobs.BulkJobExecutionResultHeader? I think it needs to validate between 3 structs now: jobs.ImportJobExecutionResultHeader, jobs.DetachedJobExecutionResultHeader and jobs.BulkJobExecutionResultHeader.


pkg/sql/importer/import_into_test.go line 521 at r1 (raw file):

// setUnsafeClusterSetting sets a cluster setting that is marked as unsafe. It
// extracts the interlock key from the initial error and retries with the key.
func setUnsafeClusterSetting(t *testing.T, db *gosql.DB, stmt string) {

there is some handling of the unsafe cluster setting in pkg/cmd/roachtest/tests/inspect_throughput.go (see disableRowCountValidation). Can we remove that handling too?

Copy link
Copy Markdown
Collaborator

@ZhouXing19 ZhouXing19 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, thank you!

Row count validation after IMPORT is now enabled by default in async
mode. After an IMPORT completes, a background INSPECT job validates
that the imported row count matches expectations.

To make the background INSPECT job discoverable, this commit adds an
`inspect_job_id` column to the IMPORT statement result output. When an
INSPECT job is triggered, the column contains that job's ID; otherwise
it is NULL.

The `bulkio.import.row_count_validation.unsafe.mode` cluster setting is
made public under the name `bulkio.import.row_count_validation.mode`,
and the metamorphic test default no longer includes "off" since
validation is now considered stable.

Resolves: cockroachdb#161279
Resolves: cockroachdb#155472

Release note (sql change): Row count validation after `IMPORT` is now
enabled by default in async mode. After an `IMPORT` completes, a
background `INSPECT` job validates that the imported row count matches
expectations. The `IMPORT` result now includes an `inspect_job_id`
column so the `INSPECT` job can be viewed separately. The
`bulkio.import.row_count_validation.mode` cluster setting controls
this behavior, with valid values of `off`, `async` (default), and
`sync`.
@rafiss rafiss force-pushed the inspect-enable-for-import branch from aafb676 to 3633494 Compare February 17, 2026 16:03
Copy link
Copy Markdown
Collaborator Author

@rafiss rafiss left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

TFTR!

/trunk merge

@rafiss made 3 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on dt, mw5h, and spilchen).


pkg/sql/pgwire/command_result.go line 749 at r1 (raw file):

Previously, spilchen wrote…

shouldn't this function still guard against drift in jobs.BulkJobExecutionResultHeader? I think it needs to validate between 3 structs now: jobs.ImportJobExecutionResultHeader, jobs.DetachedJobExecutionResultHeader and jobs.BulkJobExecutionResultHeader.

done, nice catch


pkg/sql/importer/import_into_test.go line 521 at r1 (raw file):

Previously, spilchen wrote…

there is some handling of the unsafe cluster setting in pkg/cmd/roachtest/tests/inspect_throughput.go (see disableRowCountValidation). Can we remove that handling too?

done

@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Feb 17, 2026

/trunk merge

@trunk-io trunk-io bot merged commit 7178574 into cockroachdb:master Feb 17, 2026
25 checks passed
@rafiss rafiss deleted the inspect-enable-for-import branch February 18, 2026 16:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

import: enable row count validation by default sql/inspect: support row count validation for INSPECT after IMPORT

4 participants