Skip to content

fix(storage): session profile backfill UPDATEs run on every connection bootstrap #487

Closed

Description

@Sinity

Problem

schema_bootstrap.py:373-396 — three SchemaBackfillDescriptor instances run on every connection initialization when the schema is current-version:

UPDATE session_profiles SET evidence_search_text = search_text
WHERE TRIM(COALESCE(evidence_search_text, '')) = ''

Same for inference_search_text and enrichment_search_text.

These are gated by TRIM(COALESCE(X, '')) = '' so they're idempotent — but they still scan every row of session_profiles on every schema check. For large archives with millions of sessions, this adds measurable startup latency.

Fix

Track backfill completion in PRAGMA user_version metadata or a dedicated status table, and skip backfills that have already completed. Or add a partial index on the gating condition so the scan becomes an index lookup.

Discovered during adversarial audit 2026-04-26.

Activity

  1. added a commit that references this issue on Apr 27, 2026
    b80a0f1
  2. added a commit that references this issue on May 7, 2026
    fbe53f6
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    area:storagetype:perf

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions