Skip to content

fix: paginate status() metadata fetch to avoid SQLite variable limit#803

Open
srgvg wants to merge 1 commit intoMemPalace:developfrom
srgvg:fix/status-pagination
Open

fix: paginate status() metadata fetch to avoid SQLite variable limit#803
srgvg wants to merge 1 commit intoMemPalace:developfrom
srgvg:fix/status-pagination

Conversation

@srgvg
Copy link
Copy Markdown

@srgvg srgvg commented Apr 13, 2026

Summary

  • mempalace status crashes with sqlite3.OperationalError: too many SQL variables on palaces with >~30k drawers
  • Root cause: col.get(limit=total, include=["metadatas"]) passes the full count as limit; SQLite binds one variable per metadata item and hits the compile-time limit (~32766)
  • Fix: paginate in batches of 5000 using the existing offset parameter on col.get()

Fixes #802

Test plan

  • python -m pytest tests/ -v --ignore=tests/benchmarks — 687 tests pass (2 pre-existing failures in test_version_consistency.py unrelated to this change)
  • ruff check . — clean
  • Manual: mempalace status on a palace with 50k+ drawers completes without error

col.get(limit=total) crashes with "too many SQL variables" once the
palace exceeds ~30k drawers (SQLite binds one variable per item).
Fetch metadatas in batches of 5000 instead.

Reproduces on any palace with > ~32766 drawers.
Workaround until this fix ships: sqlite3 chroma.sqlite3 "SELECT COUNT(*) FROM embeddings;"
@jphein
Copy link
Copy Markdown
Contributor

jphein commented Apr 13, 2026

Can confirm this is a real issue — we hit it with a 134K-drawer palace. Our fork has the same paginated approach in miner.py:status() (batches of 10K with offset). Included in #629 alongside the batch writes, but this standalone fix is much easier to review. 👍

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/mining File and conversation mining bug Something isn't working security Security related storage

Projects

None yet

Development

Successfully merging this pull request may close these issues.

mempalace status crashes with "too many SQL variables" on large palaces

3 participants