Skip to content

sql: add descriptors.json and schema_changes.txt to stmtbundle#170622

Merged
trunk-io[bot] merged 1 commit into
cockroachdb:masterfrom
virajchogle:stmtbundle-descriptors-170491
Jun 2, 2026
Merged

sql: add descriptors.json and schema_changes.txt to stmtbundle#170622
trunk-io[bot] merged 1 commit into
cockroachdb:masterfrom
virajchogle:stmtbundle-descriptors-170491

Conversation

@virajchogle

Copy link
Copy Markdown
Contributor

When investigating optimizer surprises, the bundle reviewer often needs to rule out schema-state interactions. Two new files help: descriptors.json with the pretty-printed JSON for each descriptor used by the statement, and schema_changes.txt with the recent schema-change job history for those descriptors.

The declarative schema changer drains payload.DescriptorIDs as targets complete, so completed declarative jobs have an empty descriptorIds field. PrintSchemaChanges therefore also matches the descriptor's fully-qualified name against the job's description text.

Verified manually on a single-node demo cluster:

  • ALTER TABLE ... ADD COLUMN and CREATE INDEX (declarative schema changer) both appear in schema_changes.txt with status, timestamp, and description.
  • descriptors.json shows the table descriptor with the new column and secondary index.
  • EXPLAIN ANALYZE (DEBUG, REDACT) replaces both files with the omitted-in-redacted-bundle placeholder and does not emit errors.txt.
  • EXPLAIN ANALYZE (DEBUG) SELECT count(*) FROM pg_catalog.pg_class produces clean empty-state placeholders (no errors.txt).

Fixes: #170491
Epic: None
Release note (general change): Statement bundles produced by EXPLAIN ANALYZE (DEBUG) now include descriptors.json (pretty-printed descriptor JSON for each object used by the statement) and schema_changes.txt (recent schema-change history for those descriptors).

@michae2

@trunk-io

trunk-io Bot commented May 20, 2026

Copy link
Copy Markdown
Contributor

😎 Merged successfully - details.

@blathers-crl

blathers-crl Bot commented May 20, 2026

Copy link
Copy Markdown

Thank you for contributing to CockroachDB. Please ensure you have followed the guidelines for creating a PR.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

I have added a few people who may be able to assist in reviewing:

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@blathers-crl blathers-crl Bot added O-community Originated from the community X-blathers-triaged blathers was able to find an owner labels May 20, 2026
@blathers-crl blathers-crl Bot requested a review from michae2 May 20, 2026 07:53
@cockroach-teamcity

Copy link
Copy Markdown
Member

This change is Reviewable

@virajchogle

Copy link
Copy Markdown
Contributor Author

Quick ping for review whenever you get a chance, happy to address any feedback.

When investigating optimizer surprises, the bundle reviewer often
needs to rule out schema-state interactions. Two new files help:
descriptors.json with the pretty-printed JSON for each descriptor
used by the statement, and schema_changes.txt with the recent
schema-change job history for those descriptors.

The declarative schema changer drains payload.DescriptorIDs as
targets complete, so completed declarative jobs have an empty
descriptorIds field. PrintSchemaChanges therefore also matches the
descriptor's fully-qualified name against the job's description
text.

Fixes: cockroachdb#170491
Epic: None
Release note (general change): Statement bundles produced by EXPLAIN
ANALYZE (DEBUG) now include descriptors.json (pretty-printed
descriptor JSON for each object used by the statement) and
schema_changes.txt (recent schema-change history for those
descriptors).
@virajchogle virajchogle force-pushed the stmtbundle-descriptors-170491 branch from 3221ac5 to 1c5a284 Compare June 2, 2026 02:09
@virajchogle virajchogle requested a review from a team as a code owner June 2, 2026 02:09
@blathers-crl

blathers-crl Bot commented Jun 2, 2026

Copy link
Copy Markdown

Thank you for updating your pull request.

My owl senses detect your PR is good for review. Please keep an eye out for any test failures in CI.

🦉 Hoot! I am a Blathers, a bot for CockroachDB. My owner is dev-inf.

@virajchogle

Copy link
Copy Markdown
Contributor Author

Pushed a follow-up. The unit_tests failure was TestDistributedQueryErrorIsRetriedLocally (pkg/sql/distsql_running_test.go), which asserts on the bundle's file list. I missed updating that hardcoded list to include the two new files this PR adds (descriptors.json and schema_changes.txt). Verified the fix locally with ./dev test pkg/sql -f TestDistributedQueryErrorIsRetriedLocally now. Should be good.

@michae2 michae2 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Nice work, @virajchogle! :lgtm:

/trunk merge

@michae2 reviewed 3 files and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on virajchogle).

@blathers-crl

blathers-crl Bot commented Jun 2, 2026

Copy link
Copy Markdown

Detected infrastructure failure on trunk-merge branch (matched: self-hosted runner lost communication with the server). Automatically resubmitting to merge queue (attempt 1 of 2). (run link)

@blathers-crl

blathers-crl Bot commented Jun 2, 2026

Copy link
Copy Markdown

/trunk merge

@trunk-io trunk-io Bot merged commit 3eb31da into cockroachdb:master Jun 2, 2026
25 checks passed
@virajchogle

Copy link
Copy Markdown
Contributor Author

Thanks for the review, @michae2! Glad to have my first CRDB PR land. More incoming!

@virajchogle virajchogle deleted the stmtbundle-descriptors-170491 branch June 2, 2026 09:07
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

O-community Originated from the community target-release-26.3.0 X-blathers-triaged blathers was able to find an owner

Projects

None yet

Development

Successfully merging this pull request may close these issues.

stmtbundle: add recent schema changes and descriptor JSON

3 participants