Skip to content

db: drop the lowercased sandbox name index - #1613

Merged
ac-pplx merged 1 commit into
mainfrom
ac/drop-sandboxes-name-lower-index
Nov 6, 2026
Merged

ac-pplx merged 1 commit into
mainfrom
ac/drop-sandboxes-name-lower-index

Conversation

@ac-pplx

@ac-pplx ac-pplx commented Nov 6, 2026

Copy link
Copy Markdown
Contributor

Summary

Drops idx_sandboxes_name_lower, which #1522 added on sandboxes for the admin list's case-insensitive name search. #1523 now makes that search match IDs only, so nothing reads the index. Names are still found by the list's case-sensitive prefix.

The index costs more than it buys:

  • ECW/E2B creates never set a name (crates/l40_api/api/src/routes/e2b/translate.rs, name: None), and native names are optional. So it mostly indexes NULL keys.
  • Every non-HOT write to sandboxes, the busiest table, inserts an entry into it.

#1522's other index, idx_sandboxes_id_suffix, stays: the ID search reads it.

Migration only, as the isolation check requires:

  • up: DROP INDEX CONCURRENTLY IF EXISTS public.idx_sandboxes_name_lower;, a single-statement -- no-transaction file.
  • down: rebuilds it exactly as 20261105161136_sandboxes_name_lower_index.up.sql did (CONCURRENTLY, the same key), with that file's recovery notes, adapted to a down.

#1522's files are unchanged, so their checksums still match.

Validation

Severity and risk

Severity: low. It removes write overhead and index storage; nothing is incorrect without it.

Risk: low. On main nothing reads the index; its only reader was #1523's previous head, which never merged.

Rollback: run this migration's down, which rebuilds the index concurrently.

Rollout

A deployment that has run #1522's migration has already built idx_sandboxes_name_lower. A deployment that runs migrations before this lands will build it too. The drop handles either case: IF EXISTS makes it a no-op where the index is gone, and CONCURRENTLY keeps writes flowing while it drops.

A deploy that carries both #1522 and this migration builds the index and then drops it. That costs one concurrent build, and is harmless.

The drop runs under the migrator session's timeouts and is not retried. It waits for every transaction holding a lock on sandboxes. If it fails, it records nothing, possibly leaving the index INVALID, and the next migrator run drops it.

No API on main reads the index, so this can merge before or after #1523 and #1524.

AI assistance: Claude Code drafted the migration and this description, and ran the checks.

🤖 Generated with Claude Code

The admin list's search no longer matches names (#1523), so nothing reads
idx_sandboxes_name_lower. Most sandbox rows have no name, and every
non-HOT write to the table still inserts into it. Drop it concurrently;
the down rebuilds it as its create migration did.
@coderabbitai

coderabbitai Bot commented Nov 6, 2026 •

Copy link
Copy Markdown

Explain Change →

Automatic approval withheld

Automatic approval is disabled by the configured approval policy for this pull request. Review comments and requests for changes continue normally.

Commit: 514661d0f190.

No actionable comments were generated in the recent review.

Walkthrough

The migration drops public.idx_sandboxes_name_lower concurrently if it exists. Its rollback creates the index concurrently on public.sandboxes using left(lower(name), 256) with "C" collation.

Possibly related PRs

Merge Risk: Minimal · up to 51466

The index removal does not affect the inspected admin search query, and no actionable merge risk remains after normal migration checks.

Security architecture risk: Low · up to 51466

The change removes a non-unique search index without changing sandbox data, permissions, or the current search contract. Rollback restores the original definition. Operational risk remains because interrupted concurrent index operations can require manual recovery, and compatibility with older deployed application versions was not established.

Retained concerns
No architecture-level concerns identified.

Security review details

Security Blast Radius

  • inferred — The direct scope is a shared control-plane table’s secondary index, not an individual tenant’s index. Any migration wait or older-query performance effect could therefore affect the shared database, although no tenant-isolation or authorization change appears in the executable SQL.

Trust Boundaries and Controls

  • inferred — The routed public-entrypoint signal identifies static migration DDL, not a new request handler. The changed statements have fixed database targets and contain no request-derived SQL or new grant of authority.

Resilience and Maintainability Implications

  • observed — The existing runner avoids automatically retrying potentially partial non-transactional migrations and deliberately leaves rollback supervised. This limits unsafe automatic repetition but leaves index/history reconciliation dependent on operator recovery after interruption.
Pre-merge checks: Passed 5

Check name Status Explanation
Title check Passed The title describes the index removal and meets the title format requirements.
Description Follows The Pr Template Passed The description contains all four required items: a summary, validation and results, severity and risk, and an AI assistance line that identifies the tool and its contributions.
Bug Fixes Name A Regression Test Passed The PR only adds database migrations to remove and restore an index. It does not fix an application behavior defect under crates/, shim/, or ui/, so the check does not apply.
Weakened Safeguards Are Justified Passed The new migration files explain the Squawk directives and timeout exceptions in adjacent comments. The diff does not weaken any safeguards without a specific reason.
Public-Safe Content Passed The diff, title, and description contain no content that matches the specified failure conditions.
Recent review info

Automatic approval policy

Commit: 514661d0f190.

Setting Effective value Source
Automatic approvals Disabled Override 4
Merge risk Low Override 2
Security risk Not set Global configuration

Matching overrides (numbered as in the resolved configuration):

  • Override 2 — any author; paths: **, !ui/**; merge risk: Low.
  • Override 4 — any author; paths: .coderabbit.yaml, .coderabbit.yml, coderabbit.yaml, coderabbit.yml, .coderabbit.config.ts, **/AGENTS.md, **/CLAUDE.md, .agents/**, .claude/**, .claude-plugin/**, CONTRIBUTING.md, docs/versioning.md, docs/rust/space-conventions.md, docs/rust/space-review-lessons.md, .github/**, ci/**, !ci/scripts/setup-nextest-*.sh, scripts/source_guards/**, scripts/check*, clippy.toml, deny.toml, .gitleaks.toml, .pre-commit-config.yaml, lefthook.yaml, rust-toolchain.toml, .cargo/**, supply-chain/**, pyproject.toml, uv.lock, **/package.json, **/package-lock.json, **/go.mod, **/go.sum, **/requirements*.txt, **/requirements*.in, proto/**, db/**, crates/l40_api/api/src/auth.rs, crates/l40_api/api/src/auth/**, crates/l40_api/api/src/middleware/auth*, crates/l40_api/api/src/middleware/auth/**, crates/l40_api/api/src/routes/authz.rs, crates/l10_foundation/bearer/**, crates/l10_foundation/rustls/**, crates/l10_foundation/guest/**, crates/l10_foundation/pii/**, shim/**, docker/**, !docker/Dockerfile.rust-build-kind, templates/**, infra/space/aws/**, infra/space/cluster/**, infra/space/identity/**, infra/space/observability/**, infra/space/packer/**, infra/space/kind/charts/**, LICENSE, SECURITY.md; automatic approvals: disabled.

Any matching disabled override withholds approval, regardless of risk. Otherwise, the strictest explicitly set limit wins for each score. Limits omitted by all matching overrides inherit the global configuration.

Not set means no limit was configured after inheritance. Use @coderabbitai configuration to inspect the resolved settings and their sources.

Run configuration

  • Source mode: Auto
  • Repository: perplexityai/SPACE
  • Branch: main
  • File: .coderabbit.yaml
  • Commit: 651df81
  • Layers: Repository YAML; Enforced overrides: Organization
  • Review profile: CHILL
  • Plan: Enterprise
  • Run ID: 839cb9dd-dcf9-457d-bd18-23c3dc78e3a1
Commits

Reviewing files that changed from the base of the PR and between 651df81 and 514661d.

Files selected for processing: 2

  • db/postgres/20261106034255_drop_sandboxes_name_lower_index.down.sql
  • db/postgres/20261106034255_drop_sandboxes_name_lower_index.up.sql

Included review availability: This review used your included allowance. Your plan provides up to 12 included reviews per hour; 5 remain after this review.

@ac-pplx
ac-pplx marked this pull request as ready for review November 6, 2026 04:37
@github-actions github-actions Bot added the triage:pending Waiting for a maintainer to triage label Nov 6, 2026
@github-actions

github-actions Bot commented Nov 6, 2026

Copy link
Copy Markdown

Thanks for opening this pull request! A SPACE maintainer will take a look.

CONTRIBUTING.md explains how we review outside contributions.

@ac-pplx
ac-pplx added this pull request to the merge queue Nov 6, 2026
@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to failed status checks Nov 6, 2026
@ac-pplx
ac-pplx added this pull request to the merge queue Nov 6, 2026
Merged via the queue into main with commit 09925bf Nov 6, 2026
28 of 44 checks passed
@ac-pplx
ac-pplx deleted the ac/drop-sandboxes-name-lower-index branch November 6, 2026 05:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

triage:pending Waiting for a maintainer to triage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants