release-26.1: sql: add lookup fallback in internalLookupCtx#165274
Merged
fqazi merged 1 commit intocockroachdb:release-26.1from Mar 16, 2026
Merged
release-26.1: sql: add lookup fallback in internalLookupCtx#165274fqazi merged 1 commit intocockroachdb:release-26.1from
fqazi merged 1 commit intocockroachdb:release-26.1from
Conversation
|
Thanks for opening a backport. Before merging, please confirm that the change does not break backwards compatibility and otherwise complies with the backport policy. Include a brief release justification in the PR description explaining why the backport is appropriate. All backports must be reviewed by the TL for the owning area. While the stricter LTS policy does not yet apply, please exercise judgment and consider gating non-critical changes behind a disabled-by-default feature flag when appropriate. |
Member
rafiss
approved these changes
Mar 11, 2026
rafiss
reviewed
Mar 11, 2026
Collaborator
rafiss
left a comment
There was a problem hiding this comment.
pkg/sql/database.go:115:57: not enough arguments in call to newInternalLookupCtx
have ([]"github.com/cockroachdb/cockroach/pkg/sql/catalog".Descriptor, "github.com/cockroachdb/cockroach/pkg/sql/catalog".DatabaseDescriptor)
want ([]"github.com/cockroachdb/cockroach/pkg/sql/catalog".Descriptor, "github.com/cockroachdb/cockroach/pkg/sql/catalog".DatabaseDescriptor, internalLookupCtxFallbackFn)
Previously, when internalLookupCtx was used by crdb_internal or pg_catalog functions, it was assumed that reading system.namespace would cache all references in a database. While this worked when fetching descriptors from KV, this assumption can break when using leased descriptors. This occurs because system.namespace may be newer than the leased descriptor timestamp. For example, if a table referenced by a foreign key is being dropped, the referencing table may still contain the entry. When the lookup context attempts to resolve that referenced table, the entry will be missing. To address this, this patch allows internalLookupCtx to use a fallback, enabling it to query missing objects using the descriptor collection. Fixes: cockroachdb#164430 Fixes: cockroachdb#164648 Release note (bug fix): Fixed a rare race condition where SHOW CREATE TABLE could fail with a "relation does not exist" error if a table referenced by a foreign key was being concurrently dropped.
92f62e3 to
433ee1f
Compare
This was referenced Mar 16, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Backport 1/1 commits from #164942 on behalf of @fqazi.
Previously, when internalLookupCtx was used by crdb_internal or pg_catalog functions, it was assumed that reading system.namespace would cache all references in a database. While this worked when fetching descriptors from KV, this assumption can break when using leased descriptors.
This occurs because system.namespace may be newer than the leased descriptor timestamp. For example, if a table referenced by a foreign key is being dropped, the referencing table may still contain the entry. When the lookup context attempts to resolve that referenced table, the entry will be missing.
To address this, this patch allows internalLookupCtx to use a fallback, enabling it to query missing objects using the descriptor collection.
Fixes: #164430
Fixes: #164648
Release note (bug fix): Fixed a rare race condition where SHOW CREATE TABLE could fail with a "relation does not exist" error if a table referenced by a foreign key was being concurrently dropped.
Release justification: low risk change that prevents errors with leased descriptors for crdb_internal / pg_catalog and concurrent drops