fix: pin chromadb<1 + resilient mining against HNSW corruption - #116
Closed
jonashertner wants to merge 2 commits into
Closed
fix: pin chromadb<1 + resilient mining against HNSW corruption#116jonashertner wants to merge 2 commits into
jonashertner wants to merge 2 commits into
Conversation
When `mempalace mine` is interrupted mid-run (OOM kill, Ctrl-C, system pressure), ChromaDB's HNSW link_lists.bin can become catastrophically bloated, causing SIGSEGV on any subsequent collection access. This makes MemPalace resilient to that failure mode: 1. Batch writes with checkpointing — drawers are flushed in batches of 50 instead of one-at-a-time. A checkpoint file tracks which files have been fully processed so interrupted runs resume cleanly without querying ChromaDB (which may be corrupted). 2. Palace health check on startup — before mining, verify the palace is readable. If corrupted, auto-detect bloated HNSW index files and remove them so ChromaDB rebuilds on next access. 3. Graceful signal handling — SIGINT/SIGTERM flush the pending batch and save the checkpoint before exiting. 4. `mempalace repair` CLI command — detect and fix corrupted palaces manually (`--force` to rebuild unconditionally). Closes MemPalace#96 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
I experienced the same issue, this would be awesome to have it. |
The published PyPI package had no upper bound on chromadb, so `pip install mempalace` pulled chromadb 1.0.12 (Rust HNSW backend). On macOS arm64, interrupted mine runs cause link_lists.bin to bloat catastrophically and subsequent reads SIGSEGV. chromadb 0.6.3 (Python HNSW backend, within the <1 pin) is stable — 10,000+ drawers mine without incident on the same hardware. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Contributor
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.
Summary
Two related fixes for the SIGSEGV crash when mining (#96, #100):
Pin
chromadb>=0.4.0,<1in pyproject.toml — the published PyPI package had no upper bound, sopip install mempalacepulled chromadb 1.0.12 (Rust HNSW backend). On macOS arm64, interrupted mine runs causelink_lists.binto bloat catastrophically (297 GB for ~3,300 drawers) and subsequentcollection.get()/collection.count()calls SIGSEGV. Downgrading to chromadb 0.6.3 (Python HNSW backend, within the<1pin) resolves all crashes — 10,000+ drawers mine without incident on the same hardware.Crash-resilient mining pipeline (defence-in-depth against future regressions in any chromadb version):
mine-checkpoint.json) tracks fully processed files, so interrupted runs resume without querying ChromaDB (which may be corrupted).mempalace repairCLI command — detect and fix corrupted palaces (--forceto rebuild unconditionally).Files changed
pyproject.tomlchromadb>=0.4.0,<1mempalace/checkpoint.pymempalace/miner.pymempalace/cli.pymempalace repair [--force]subcommandtests/test_miner_resilience.pyTest plan
mempalace mineinterrupted with Ctrl-C resumes correctlymempalace repairrecovers a corrupted palacemempalace repair --forcerebuilds index unconditionallyCloses #96, closes #100
🤖 Generated with Claude Code