Skip to content

sql/catalog: ensure consistent versions during type hydration#162622

Merged
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:fixHydrationDroppedHandlin
Feb 9, 2026
Merged

sql/catalog: ensure consistent versions during type hydration#162622
trunk-io[bot] merged 1 commit intocockroachdb:masterfrom
fqazi:fixHydrationDroppedHandlin

Conversation

@fqazi
Copy link
Copy Markdown
Collaborator

@fqazi fqazi commented Feb 7, 2026

Previously, if a schema had references to types being dropped, for example due to functions that were being cleaned up, it was possible to encountered "descriptor is being dropped" when leasing the schema. This happened because the version of the schema could be behind that of other objects referenced. While locked leasing eliminates issues for non-dropped objects, it cannot alleviate it for any dropped descriptors that are being resolved. To address this, this patch will generate a retryable error, if we detect that a dropped type descriptor encountered after the read timestamp.

Fixes: #159509

Release note: None

@trunk-io
Copy link
Copy Markdown
Contributor

trunk-io bot commented Feb 7, 2026

😎 Merged successfully - details.

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@fqazi fqazi marked this pull request as ready for review February 9, 2026 15:02
@fqazi fqazi requested a review from a team as a code owner February 9, 2026 15:02
Copy link
Copy Markdown
Collaborator

@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.

nice work!

// with concurrent schema changes never encounter errors.
func TestLeasedDescriptorTypeHydration(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
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 test! there's a lot of concurrency so just want to to double check it's stable under stress/race/deadlock?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

I ran this on engflow under stress as validation.

// Note: This is a special case because type hydration cannot tolerate
// dropped descriptors. This already could occur by leasing any schema
// with type references that are being dropped.
if !witoutDropped && desc.Dropped() {
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.

should it be if !witoutDropped && !withoutLeased && desc.Dropped()

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Yeah that would make it more future proof.

@fqazi fqazi force-pushed the fixHydrationDroppedHandlin branch from 13a3178 to c561f91 Compare February 9, 2026 19:57
Copy link
Copy Markdown
Collaborator Author

@fqazi fqazi left a comment

Choose a reason for hiding this comment

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

@fqazi made 2 comments.
Reviewable status: :shipit: complete! 0 of 0 LGTMs obtained (waiting on @rafiss).

// Note: This is a special case because type hydration cannot tolerate
// dropped descriptors. This already could occur by leasing any schema
// with type references that are being dropped.
if !witoutDropped && desc.Dropped() {
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

Yeah that would make it more future proof.

// with concurrent schema changes never encounter errors.
func TestLeasedDescriptorTypeHydration(t *testing.T) {
defer leaktest.AfterTest(t)()
defer log.Scope(t).Close(t)
Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Done.

I ran this on engflow under stress as validation.

Previously, if a schema had references to types being dropped, for
example due to functions that were being cleaned up, it was possible to
encountered "descriptor is being dropped" when leasing the schema. This
happened because the version of the schema could be behind that of other
objects referenced. While locked leasing eliminates issues for
non-dropped objects, it cannot alleviate it for any dropped descriptors
that are being resolved. To address this, this patch will generate a
retryable error, if we detect that a dropped type descriptor encountered
after the read timestamp.

Fixes: cockroachdb#159509

Release note: None
@fqazi fqazi force-pushed the fixHydrationDroppedHandlin branch from c561f91 to 5353e64 Compare February 9, 2026 20:15
@fqazi
Copy link
Copy Markdown
Collaborator Author

fqazi commented Feb 9, 2026

/trunk merge

@trunk-io trunk-io bot merged commit 2a3f179 into cockroachdb:master Feb 9, 2026
26 checks passed
@fqazi
Copy link
Copy Markdown
Collaborator Author

fqazi commented Feb 10, 2026

blathers backport 26.1

@blathers-crl
Copy link
Copy Markdown

blathers-crl bot commented Feb 10, 2026

Encountered an error creating backports. Some common things that can go wrong:

  1. The backport branch might have already existed.
  2. There was a merge conflict.
  3. The backport branch contained merge commits.

You might need to create your backport manually using the backport tool.


error creating merge commit from 5353e64 to blathers/backport-release-26.1-162622: POST https://api.github.com/repos/fqazi/cockroach/merges: 409 Merge conflict []

you may need to manually resolve merge conflicts with the backport tool.

Backport to branch 26.1 failed. See errors above.


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

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.

roachtest: schemachange/mixed-versions failed [failed generating operation: dropPolicy: descriptor is being dropped]

3 participants