Uploads That Heal Themselves¶
Learning objectives
By the end of this module you should be able to:
- Explain why treating every ingestion failure the same way — retry forever, or give up immediately — is wrong in both directions, and what a bounded, automatic retry policy buys instead.
- Describe the difference between a transient failure and a permanent one, and why a system doesn't need to tell them apart in advance to handle both correctly.
- Argue why a terminal failure state should reclaim resources without ever reclaiming the record — and why "the file just disappeared" is a worse outcome than "the file failed, and here's why."
Getting documents in is not the easy part¶
A retrieval system that reasons over thousands of documents needs those thousands of documents to actually arrive intact. That sounds like a solved problem — upload a file, store it — until you look at what happens at real batch scale. Parsing a large or scanned document is genuinely resource-intensive work, and running that work concurrently across a big batch means some individual attempts will, ordinarily and expectedly, hit a moment where the service doing the work is busy, or a connection stalls briefly. None of that has anything to do with whether the file itself is good. A system that can't tell the difference between "this file is bad" and "this attempt was unlucky" will get the response wrong for one of them.
Two failure modes, one naive mistake¶
There are exactly two kinds of ingestion failure worth distinguishing:
- Transient — a busy moment, a brief network stall, ordinary load. The content is fine; the attempt just didn't land. Retrying resolves it.
- Permanent — a corrupted file, an unsupported format, content with nothing extractable in it. No number of retries changes the outcome.
In the moment a failure happens, both look identical: the upload didn't finish. The naive designs both get this wrong. Retry forever, and a permanent failure silently consumes capacity indefinitely while never resolving — the user is left staring at something that will never complete. Retry zero times, and a transient hiccup becomes a false failure for a file that would have worked a moment later.
Bounded, not zero and not infinite¶
The design that actually works doesn't try to distinguish the two failure types in advance — it lets a bounded retry policy sort them out by what actually happens. Every ingestion attempt — however it was triggered — counts against one shared limit. A file gets a small, fixed number of real attempts. If one of those attempts succeeds, it's done. If all of them are exhausted, the system stops trying and treats the failure as genuinely permanent, whether or not it actually was — a cap that's never reached is not actually a cap, it's an aspiration, exactly the same lesson a bounded reasoning loop teaches in a different context.
This is worth naming precisely as a harness concern, in the same sense a retrieval system's rerank step or citation check is: it's scaffolding around the core operation (parsing a file), not a change to what the parsing itself does. The retry count lives in the system, not in the parsing logic — the same discipline that keeps a reasoning loop's iteration cap enforced by the surrounding system rather than left to a model's own sense of when to stop.
Recovery that doesn't require a person to notice¶
A bounded retry limit only helps if something actually uses the remaining attempts. The stronger design runs recovery automatically, in the background, triggered by ordinary activity rather than a dedicated schedule or a user action — a file that stumbled gets picked back up the next time there's a natural opportunity to check on it, with no button to click and no ticket to file. This matters more, not less, at batch scale: a user uploading two thousand files and going back to their actual work should be the normal path, not something that only works if nothing goes wrong.
The terminal state: reclaim the resource, never the record¶
Eventually, some failures really are permanent, and the bounded retry limit gets reached. What happens next is the design decision most worth getting right. Reclaiming the underlying resource — deleting content that has failed every real attempt — is reasonable; there's no reason to hold onto something indefinitely once it's genuinely exhausted its chances. But the record of the attempt, and the real reason it failed, should never disappear along with it. A file that silently vanishes is a worse outcome than a file that stays visible with an honest "here's what went wrong" — the first leaves a user wondering if they imagined uploading it at all; the second at least tells the truth.
Key takeaways¶
- A single retry policy has to handle two genuinely different failure types without needing to distinguish them in advance. Bounded, automatic retry does this by letting the outcome — not a guess made beforehand — sort transient failures from permanent ones.
- A cap that isn't actually enforced by the surrounding system is not a cap. The same discipline that bounds a reasoning loop's iteration count applies to a retry policy: the limit has to live outside the thing being retried, counted once regardless of how many different paths can trigger an attempt.
- Reclaiming a resource and reclaiming its record are different decisions, and conflating them is the more common mistake. A permanent failure can reasonably free up storage; it should never also erase the evidence of what happened and why.
For further study¶
- A bounded retry policy assumes every attempt is independent — one attempt failing doesn't make the next one more or less likely to succeed for a transient failure, and doesn't help at all for a permanent one. Design a scenario where that independence assumption would be wrong, and explain what the retry policy should do differently in that case.
- The module argues a permanently-failed record should stay visible with its real failure reason rather than disappearing. Construct the strongest counter-argument for why silently removing it might be preferable in some context, and explain specifically why ingestion at scale isn't that context.
- Automatic background recovery is triggered by ordinary system activity rather than a dedicated schedule. Propose a scenario where that choice under-recovers compared to a dedicated schedule, and one where it over-recovers (retries more aggressively than intended) — and suggest a design that addresses both.
Next: Retrieval That Checks Its Own Work — the same bounded-loop discipline applied to reasoning over what's already been ingested, not just getting it in the door.