Artificial Intelligence

Vector DB returns stale document IDs after background compaction and shard reallocation — RAG assistant cites deleted passages

Environment

Environment

Self-hosted vector database cluster with 3 data nodes and 1 coordinator. Daily background compaction and shard rebalancing run during low-traffic windows. Application reads vectors via a RAG pipeline; writes and deletes happen continuously. Recent incremental compaction followed by shard moves correlated with responses returning IDs pointing to documents that were deleted days ago.

Symptoms

Symptoms

RAG queries return high-similarity hits that reference deleted documents or passages; retrieved passages do not exist in the current document store. Document IDs in search results sometimes refer to removed content, causing wrong citations and user-visible incorrect answers.

Observations

Observations

Cluster logs show compaction and segment merges completed successfully; metadata service reported successful shard reassignments. Attempts to re-run a metadata-only sync returned no errors. A forced reindex of a small subset regenerated correct vectors and removed stale IDs for that set. No explicit errors reported in write path, but occasional 'segment index mismatch' messages appeared in compaction logs around the time of rebalancing.

Already attempted

Already attempted

Restarted coordinator and data nodes, re-ran compaction on affected shards, attempted metadata sync script, performed a targeted reindex for a subset which corrected results for that subset but not the entire corpus.

Question

Question

What diagnostic checks confirm whether stale IDs are due to a compaction metadata bug, caching layer mismatch, or incomplete delete tombstone application? What's the safest recovery path to restore consistency with minimal downtime?

COMMUNITY RESPONSES

Verified community troubleshooting

1 reply
0
williamweb Answer
user
Posted 4w ago • 0 confirmations

Stop ingest temporarily and export cluster metadata to prevent further divergence. Run the DB's integrity/verify tool (or the compaction dry-run) to see if tombstones were applied; check compaction logs for skipped deletes. If verification flags inconsistent segments, the safest route is a controlled rebuild: snapshot current index, reindex from the source documents into a new index, switch the read alias when verified, and keep the old index until you confirm results. This is reversible: you can point traffic back to the old index while investigating. Long-term, enable stronger write quorum and alerting on compaction failures.

Showing 1 of 1 community responses
AI DIAGNOSTICS

Incident analysis

Updated 4w ago• Trouble ID

Most likely causes

Compaction/merge bug that failed to apply delete tombstones to new segments, leaving deleted IDs referenced 85%
Metadata inconsistency after shard reallocation where the coordinator points to outdated segment files on a data node 70%
Client-side or API-layer caching returning stale ID mapping despite server-side deletion 40%

Summary

Stale document IDs after compaction and shard moves typically indicate metadata or index mappings that weren't updated during segment merges, or delete tombstones not applied before compaction. Other causes include client-side caches returning old IDs, or a split-brain during reallocation causing duplicate IDs and stale pointers. The partial correction when reindexing a subset suggests the index data can be rebuilt to remove stale entries, pointing to compaction or metadata update issues rather than persistent storage corruption.

Suggested Fixes

Diagnostic step 1
Quiesce writes (put cluster into read-only or pause ingestion) to stop mutation while diagnosing to avoid further inconsistencies.
Diagnostic step 2
Export current cluster metadata (shard maps, segment lists, tombstone markers) and snapshot vector segment files before further action.
Diagnostic step 3
Run built-in index integrity/check tools (cluster-provided verify/repair) if available and review compaction/merge logs for skipped tombstones or exceptions.

Continue troubleshooting

Matched from the title, description and tags