cockroachdb / cockroachdb/cockroach
sql: improve validation when dropping temp schemas
- Dominant language
- Go
- Stars
- 32.5k
- Forks
- 4.1k
- PR merge metrics
- PR metrics pending
Description
We've seen cases where temporary objects aren't properly cleaned up (see [support issue #3391](https://github.com/cockroachlabs/support/issues/3391)). The root cause is still unknown. One challenge is that the initial issue often happens long before any visible failure, making debugging difficult.
This ticket proposes improving descriptor validation during temp object cleanup, to catch issues closer to when they happen.
Ideas to explore:
- Detect missing temp schemas during descriptor validation
Right now, we intentionally skip validating temp schemas:
https://github.com/cockroachdb/cockroach/blob/f09c7b83377bd7047aac56d1a6099f180aceec29/pkg/sql/catalog/tabledesc/validate.go#L162-L177
Adding this check might be tricky, since temp schema info lives in session-specific structures and descriptor validation is session-agnostic.
- Validate that all objects under a temp schema are removed during cleanup
We could do this here:
https://github.com/cockroachdb/cockroach/blob/7e50c9f9cea923ea39bb1bda71f81796378b43d1/pkg/sql/temporary_schema.go#L216-L227
At this point we have the temp schema ID, so once cleanup finishes, we could verify that all objects within the schema are gone. One edge case: temp sequences owned by permanent tables are skipped during deletion and would need special handling.
Jira issue: CRDB-53336
Epic CRDB-17128
Contributor guide
Assessment
This issue has not been assessed yet.