cockroachdb / cockroachdb/cockroach

sql/catalog: type hydration under locked leasing may return an error during concurrent DROP

Open
#174,636 1 comment 0 reactions 0 assignees View on GitHub
C-bug T-sql-foundations
Dominant language
Go
Stars
32.5k
Forks
4.1k
PR merge metrics
PR metrics pending

Description

**Describe the problem**
Under locked leasing, type hydration resolves a descriptor at the lease timestamp but resolves its referenced descriptors (the type and its parent schema/database) at the newer read timestamp. When one of those referenced descriptors is deleted in that window by a concurrent `DROP ... CASCADE`, hydration fails and the query surfaces an error such as "unknown schema" instead of transparently completing.

This issue was first seen in https://github.com/cockroachdb/cockroach/issues/173211. `TestLeasedDescriptorTypeHydration` flaked with error ```pq: unknown schema "[104]"``` while a `DROP SCHEMA ... CASCADE `runs concurrently with queries that hydrate descriptors referencing types in that schema.

**Potential Solution**
The hydration path can force a transaction retry when a referenced descriptor is not found at the read timestamp, but the retry must be bounded to avoid retrying for ever. Make sure the solution is valid for all isolation levels.

Jira issue: CRDB-67835

Epic CRDB-65516

Contributor guide

Open the contributing guide

Research direction

Start with TestLeasedDescriptorTypeHydration and trace the locked-leasing type hydration path that resolves referenced descriptors at the newer read timestamp. Reproduce the concurrent DROP ... CASCADE failure, then verify that missing referenced descriptors trigger a bounded transaction retry across all isolation levels without surfacing an unknown-schema error.

Written by the indexing model from the issue text.

Assessment

Tech stack
go, sql
Domain
databases, distributed-systems
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Active
Clarity
Mostly clear
Newbie friendliness
48/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.