AAI Agentic Handbook
Question 03 · Production RAG Systems

How would you handle document ingestion failures?

Reviewed Oct 2026
How to spend the time
  1. 1 min — durable state machine per document.
  2. 2 min — failure classes and the response to each.
  3. 2 min — silent-success quality gates.
  4. 1 min — customer-visible status and ownership.
01Concept

Treat ingestion as a durable pipeline with per-document state, not a script. Each document moves through states (received → parsed → chunked → embedded → indexed) persisted in the registry. Retries with exponential backoff for transient failures, a dead-letter queue for permanent ones, idempotency so replay is safe, and partial-success handling so one bad page doesn't drop a 400-page document.

02Practical use case

Classify failures, because they need different responses: transient (rate limit, timeout) → retry; data quality (corrupt file, unsupported format, scanned image) → DLQ with a user-visible reason; systemic (parser crash on a whole document class) → alert a human, because retrying won't help and will burn budget.

03Staff framing

The real failure mode is silent success — a document that ingests "fine" and produces empty or garbage chunks. Add quality gates at ingestion: text density per page, chunk count sanity, embedding norm checks. And surface per-document status to the customer; "47 of 50 documents indexed, 3 failed because they're scanned images" is a vastly better product than a system that quietly knows less than the user thinks.

Org scope: buy the durable-queue primitives (SQS, Pub/Sub, Kafka, or a workflow engine like Temporal) and build the per-document state machine. The platform owns the pipeline and DLQ triage; source-system owners are paged when their export format breaks.

01Received
02Parsed
03Chunked
04Embedded
05Indexed
↺ retry w/ backoff → DLQ
State persisted per document; each stage is idempotent.

What the answer sounds like at each level

Mid

Retry failed documents and log errors so someone can fix them.

Senior

Persists per-document state, classifies failures into transient, data-quality and systemic, with backoff, DLQ, idempotent replay and partial success.

Staff

Adds quality gates against silent success, exposes per-document status to customers, and assigns DLQ triage and source-format breakage to named owners.

Follow-ups the interviewer will push

1The embedding API rate-limits you during a 2M-document backfill. What happens?

Workers back off exponentially with jitter, the queue absorbs the backlog, and a token-bucket limiter caps concurrency below the provider's limit. Live updates go on a separate priority queue so fresh documents aren't stuck behind the backfill.

2How do you make replay idempotent?

Chunk ids derived from (document id, chunk position, content hash), upserts instead of inserts, and a registry state check so a re-run skips stages already completed for the same hash.

Red flags interviewers listen for

  • Retries everything, including permanent data-quality failures.
  • No idempotency, so replays create duplicate chunks.
  • Treats 'no error' as success without content-quality checks.

How it's scored

DimensionWhat strong looks like
DurabilityPer-document state, idempotent replay, partial success.
Failure taxonomyDifferent handling for transient, data-quality and systemic failures.
Silent failuresQuality gates that catch empty or garbage chunks.

Sources

  1. Using dead-letter queues in Amazon SQS — AWS, 2024docs