Skip to content

fix(memory): recreate Qdrant collections on vector dimension mismatch#1820

Merged
bug-ops merged 2 commits intomainfrom
qdrant-dimension-mismatch
Mar 15, 2026
Merged

fix(memory): recreate Qdrant collections on vector dimension mismatch#1820
bug-ops merged 2 commits intomainfrom
qdrant-dimension-mismatch

Conversation

@bug-ops
Copy link
Copy Markdown
Owner

@bug-ops bug-ops commented Mar 15, 2026

Summary

  • Fixes bug(qdrant): dimension mismatch crash when switching embedding models with existing collections #1815 — dimension mismatch crash when switching embedding models with existing Qdrant collections
  • ensure_collection() now queries collection_info() to compare the existing collection's vector size against the required dimension before deciding to recreate
  • Empty collections (0 points) are now correctly handled — the previous scroll_all() metadata check missed them since there are no points to inspect
  • Probe (embed_fn) is called at most once per invocation and only when actually needed (collection absent or size unknown), avoiding unnecessary embedding API round-trips on every sync

Behaviour change

Scenario Before After
Collection exists, same dim Return OK Return OK (no change)
Collection exists, dim mismatch Return OK (bug) Warn + delete + recreate
Collection exists, 0 points, model changed Return OK (bug) Warn + delete + recreate
Collection absent Create Create (no change)

Test plan

  • All existing unit tests pass (5790 passed, 0 failed)
  • cargo +nightly fmt --check — clean
  • cargo clippy --workspace --features full -- -D warnings — clean
  • Integration test: start with qwen3-embedding (4096-dim), switch to text-embedding-3-small (1536-dim) — collections must be recreated without errors

…#1815)

ensure_collection() now checks the existing collection's configured vector
size via collection_info() before deciding whether to recreate. Previously
the check relied on point metadata, which meant empty collections (0 points)
were never detected as stale when the embedding model changed.

New logic:
- collection_info() is queried first (no embedding probe)
- If existing size matches the required size, return early
- If sizes differ or collection uses named vectors (ParamsMap), delete and
  recreate with the correct dimensions
- embed_fn probe is called at most once per invocation, only when needed
@github-actions github-actions bot added documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes bug Something isn't working size/M Medium PR (51-200 lines) labels Mar 15, 2026
@bug-ops bug-ops enabled auto-merge (squash) March 15, 2026 14:14
@bug-ops bug-ops merged commit c79fbc1 into main Mar 15, 2026
15 checks passed
@bug-ops bug-ops deleted the qdrant-dimension-mismatch branch March 15, 2026 14:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working documentation Improvements or additions to documentation memory zeph-memory crate (SQLite) rust Rust code changes size/M Medium PR (51-200 lines)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

bug(qdrant): dimension mismatch crash when switching embedding models with existing collections

1 participant