FULL AI ANALYSIS

Incremental vector index job creates duplicate vector IDs and stale text pointers — RAG assistant returns deleted passages

Generated Oct 17, 2026, 9:26:11 AM

Analysis summary

Evidence points to race conditions and non-atomic operations in the incremental pipeline: asynchronous upserts, retries, and non-idempotent operations allow upsert and delete to interleave, leaving orphaned vectors or duplicate vector entries referencing deleted doc IDs. The vector store and metadata DB are not updated atomically, so consistency gaps appear. Faiss itself may not enforce unique external IDs; the metadata store must be canonical.

Possible causes

Non-atomic incremental workflow: upserts, metadata updates, and delete operations interleave due to async workers and retries, producing orphaned/duplicate vectors

95%

Vector DB (Faiss) client library not using an external unique-id mapping layer, allowing duplicate internal IDs when same external id is upserted rapidly

60%

Embedding generation retries produce different vector IDs for same doc leading to stale pointers if metadata update fails

45%

Failed/deferred background compact/merge job leaves tombstones and old vectors until compaction runs

30%

Suggested fixes

1

Diagnostic step 1

Make the incremental update sequence atomic from the application's perspective: implement a two-phase update or a transaction-like pattern where metadata changes (in PostgreSQL) are only committed after successful vector upsert/remove. For example, write a change-log row and have a single worker apply vector-store changes in order.

2

Diagnostic step 2

Switch to idempotent operations: ensure upsert includes a deterministic external id and the vector DB client overwrites old vectors for the same external id rather than creating duplicates. If Faiss client doesn't support this, maintain a mapping table that records current vector internal id and update that atomically.

3

Diagnostic step 3

Add optimistic locking or processing queue: serialize updates per document (per-doc worker or consistent hashing) to avoid concurrent upsert/delete for same doc. Add dedupe check: before querying for vectors, verify metadata 'deleted' flag and skip entries.

4

Diagnostic step 4

Add post-incremental verification: a lightweight consistency check that scans for vector IDs referenced by queries that lack metadata or point to deleted docs; auto-remove or quarantined duplicates and log for investigation. Keep full reindex as last-resort but minimize need by improving pipeline.

5

Diagnostic step 5

If problem persists after these changes, collect sanitized logs (operation IDs, timestamps, not raw document content) and escalate to vector DB or embedding provider maintainers. Avoid sharing PII or document content in escalations.