Artificial Intelligence

Semantic search returns high-similarity but irrelevant results after nightly vector DB compaction and shard rebalancing

Environment

Environment

Self-hosted vector search cluster (Milvus 2.x-like architecture) behind an indexer pipeline: documents → text normaliser → embedding model v1.3 → insertion into 4 shards; nightly scheduled compaction and shard rebalancing runs between 02:00–03:30. Application queries via gRPC service returning top‑k vectors and document IDs, RAG layer retrieves passage text by ID from primary DB.

Symptoms

Symptoms

After the overnight compaction/rebalance job, production semantic-search queries return top‑k results with very high cosine similarity scores (>0.9) but the retrieved passages are semantically unrelated to the query. Some top results reference document IDs that were previously deleted. The issue persists until a full reindex; a partial reindex or indexer restart does not permanently fix it.

Observations

Observations

Compaction logs show segments merged and segment IDs moved between shards; cluster metadata shows segment move operations completed without explicit errors. The document-to-vector mapping table in the primary DB still contains older doc IDs flagged as deleted. A full reindex (recompute embeddings for all active documents and rebuild indexes) restores correct results. No hardware errors reported on the nodes; network and RPC latencies normal during rebalance window.

Already attempted

Already attempted

Restarted vector DB processes, re-ran compaction on a single shard, reloaded node metadata; temporarily disabled nightly rebalance (issue still appears the next night if job runs). Performed partial reindex of affected collections — temporary fix until next compaction. Exported vectors for a small set of documents and ran local similarity checks: exported vectors map to correct docs before compaction and to wrong docs after compaction.

Question

Question

What are the likely root causes that could make segment compaction or shard rebalancing assign vectors to incorrect IDs or leave deleted IDs resolvable by similarity? Which reversible diagnostics can we run to prove whether the bug is in the compaction/rebalance logic, segment metadata store, or index‑to‑document mapping in the application?

COMMUNITY RESPONSES

Verified community troubleshooting

0 replies

No answers yet..

Showing 0 of 0 community responses
AI DIAGNOSTICS

Incident analysis

Updated 1mo ago• Trouble ID

Most likely causes

Compaction/merge/rebalance routine bug that fails to preserve vector→document-ID mapping when moving vectors between segments or shards 75%
Inconsistent or stale cluster metadata (segment manifests) during rebalancing causing nodes to resolve wrong doc IDs for vector slots 60%
Embedding model/version change without reindex leading to semantic mismatch (high similarity but to wrong passages unlikely but possible if IDs shifted) 30%

Summary

The fact that full reindex fixes results and that exported vectors change mapping after compaction strongly indicates metadata corruption or an ID remap bug during segment merge/rebalance. Likely causes include a bug in compaction logic that doesn't preserve mapping from vector slots to document IDs, an out‑of‑sync metadata store (e.g., segment manifest) used to resolve IDs after moves, or the index storage layer reusing vector slots without updating the ID->vector mapping. Less likely but possible are mismatched embedding pipeline versions causing semantic drift (wouldn't produce wrong IDs), or storage corruption.

Suggested Fixes

Diagnostic step 1
Before running compaction on production, snapshot the cluster metadata (segment manifests, shard allocation maps) and a small sample of vectors and their document IDs so you can compare pre/post mappings.
Diagnostic step 2
Run a controlled compaction on a staging copy of the collection and compare the exported (vector,docID) pairs before and after compaction to detect remapping; do not expose document content externally — use hashed IDs and vector dumps.
Diagnostic step 3
Enable (or increase) compaction/rebalance logging to capture detailed segment move/merge operations and any warnings; collect logs for the compaction window and preserve timestamps.

Continue troubleshooting

Matched from the title, description and tags