Skip to content

sql: fix TestNumRangesInSpanContainedBy for multitenant mode#160593

Merged
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:mt-TestNumRangesInSpanContainedBy
Jan 7, 2026
Merged

sql: fix TestNumRangesInSpanContainedBy for multitenant mode#160593
craig[bot] merged 1 commit intocockroachdb:masterfrom
rafiss:mt-TestNumRangesInSpanContainedBy

Conversation

@rafiss
Copy link
Copy Markdown
Collaborator

@rafiss rafiss commented Jan 7, 2026

Previously, the test used s.ScratchRange() which returns a key in the system keyspace, outside the tenant's accessible keyspace. When running in multitenant mode, the RangeIterator would fail with an "Unauthenticated" error because the tenant cannot access keys outside its keyspace.

This commit fixes the test by:

  1. Using a tenant-prefixed scratch key via Codec().TenantPrefix() + keys.ScratchRangeMin, which ensures the key is within the tenant's keyspace.
  2. Adding a scan after splitting ranges to populate the tenant's range cache with the new range descriptors.

Resolves: #107376

Release note: None

@cockroach-teamcity
Copy link
Copy Markdown
Member

This change is Reviewable

@rafiss rafiss marked this pull request as ready for review January 7, 2026 13:54
@rafiss rafiss requested a review from a team as a code owner January 7, 2026 13:54
@rafiss rafiss requested a review from fqazi January 7, 2026 13:54
Previously, the test used `s.ScratchRange()` which returns a key in the
system keyspace, outside the tenant's accessible keyspace. When running
in multitenant mode, the RangeIterator would fail with an
"Unauthenticated" error because the tenant cannot access keys outside
its keyspace.

This commit fixes the test by:
1. Using a tenant-prefixed scratch key via `Codec().TenantPrefix()` +
   `keys.ScratchRangeMin`, which ensures the key is within the tenant's
   keyspace.
2. Adding a scan after splitting ranges to populate the tenant's range
   cache with the new range descriptors.

Resolves: cockroachdb#107376

Release note: None
@rafiss rafiss force-pushed the mt-TestNumRangesInSpanContainedBy branch from 507bb9c to 69ca7e4 Compare January 7, 2026 14:40
Copy link
Copy Markdown
Collaborator

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

:lgtm:

@fqazi reviewed 1 file and all commit messages, and made 1 comment.
Reviewable status: :shipit: complete! 1 of 0 LGTMs obtained (waiting on @rafiss).

@rafiss
Copy link
Copy Markdown
Collaborator Author

rafiss commented Jan 7, 2026

bors r+

@craig
Copy link
Copy Markdown
Contributor

craig bot commented Jan 7, 2026

@craig craig bot merged commit c49126f into cockroachdb:master Jan 7, 2026
26 checks passed
@rafiss rafiss deleted the mt-TestNumRangesInSpanContainedBy branch January 9, 2026 23:10
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.

sql: adjust TestNumRangesInSpanContainedBy to work with test tenant

3 participants