🐛 fix: raise LMDB mapsize cap 8GB→16GB + PersistentEmbeddingCache auto-resize on MDB_MAP_FULL (#189) - #190
Merged
Merged
Conversation
added 4 commits
August 4, 2026 23:25
) The 8GB hard cap (MAX_LMDB_MAP_SIZE_MB=8192) was too low for very large corpora — GitHub issue #189 shows a 1GB / 53k-file cargo-registry source with >1.2M chunks legitimately exceeding it, crashing after auto-resize exhausts ("already at max size 8192MB" → fatal MDB_MAP_FULL). - constants.rs: raise MAX_LMDB_MAP_SIZE_MB 8192→32768 (32GB). On 64-bit Linux/macOS the mapsize is just a VA reservation (free until written); on Windows the file may be pre-allocated but only to the grown size, which only happens on demand when MDB_MAP_FULL bites. - constants.rs: add max_lmdb_map_size_mb() reading the new CODESEARCH_MAX_LMDB_MAP_SIZE_MB env var (clamped to >= default), so operators with extreme corpora or Windows instances can tune the cap without rebuilding. - store.rs: route the 5 runtime cap comparisons (pin_map_size, resize_environment check+message, build_index, delete_chunks, insert_chunks_with_ids) through max_lmdb_map_size_mb(). The cap test is now env-aware (asserts against the resolved fn, not the const). Stage 1 of 3 for #189. Stage 2 adds the same auto-resize to PersistentEmbeddingCache (currently hardcoded 512MB, no resize).
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
Fixes the fatal
MDB_MAP_FULL: Environment mapsize limit reachedcrash on large corpus indexing (#189).Two complementary changes:
PersistentEmbeddingCacheonMDB_MAP_FULL— the cache LMDB was the remaining failure surface afterVectorStore::build_indexalready had this fix; the cache's ownput/put_batchpaths still aborted on a full map.Root cause
Two LMDB environments share the process, and only one of them could grow past its cap on
MDB_MAP_FULL:VectorStore::build_indexalready had a resize-retry loop.PersistentEmbeddingCache::put/put_batchdid not — a full cache map was a hard crash.On top of that, the global
MAX_LMDB_MAP_SIZE_MBcap (8 GB) was too small for the repro in #189, so even the resize-capable paths hit the ceiling.Changes by stage
7a58e78) —src/constants.rs,src/vectordb/store.rsMAX_LMDB_MAP_SIZE_MB8 GB → 16 GB.max_lmdb_map_size_mb()accessor with env overrideCODESEARCH_MAX_LMDB_MAP_SIZE_MB(clamped to ≥ 1024 MB; fail-fast on parse error).89244a1) —src/embed/cache.rsMDB_MAP_FULLauto-resize retry loops toPersistentEmbeddingCache::put/put_batch, mirroring the existingVectorStore::build_indexpattern.&selfreceiver preserved (no API churn).e58e225) —src/embed/cache.rs116176c) —src/constants.rsEscape hatch
Clamped to a minimum of 1024 MB; a non-integer value fails fast at startup rather than silently falling back.
Validation
All green on push (QC gate):
cargo fmt --all -- --checkcargo check --all-targetscargo clippy --all-targets -- -D warningscargo test --lib --bins— 558 passed / 0 failedReviews
All 4 stages reviewed individually (4× PASS, zero Critical / zero Important findings).
Files changed
src/constants.rssrc/vectordb/store.rssrc/embed/cache.rsCloses #189