Quick revision
The short answer
First stop the source by rolling back the producer, then measure the damage from the dead-letter topics and their kafka_dlt-original-offset headers and list the affected order ids. Prefer correction at the source: the producing team publishes corrected events, or an OrderCorrected event, so every consumer, including analytics, gets the fix through the normal path. Any redrive of dead-letter records must be rate-limited, keep per-key order and skip orders that already have a newer version applied, since replaying old state over new is worse than the original failure. Analytics needs a targeted repair because its silent default hid the problem, and prevention means semantic validation before send, contract tests in the producer's CI, DLT alerts that page the producer, and full DLT headers.
What to remember
In this answer, we led the clean-up of 2.4 million bad OrderPlaced events. We stopped the source, measured the damage from dead-letter topics and their original-offset headers, and listed the affected order ids. We preferred correction at the source, so every consumer received fixed events through its normal path. Any redrive was rate-limited, ordered by key and skipped orders that already had newer versions. Analytics needed a targeted repair because its silent default hid the problem. Finally, semantic validation, contract tests, DLT alerts that page the producer and complete DLT headers stop the next bad release from spreading.
Your turn
Answer it aloud as you would in the interview, or type your answer below. Then show one part at a time and compare.
First stop the source by rolling back the producer, then measure the damage from the dead-letter topics and their kafka_dlt-original-offset headers and list the affected order ids. Prefer correction at the source: the producing team publishes corrected events, or an OrderCorrected event, so every consumer, including analytics, gets the fix through the normal path. Any redrive of dead-letter records must be rate-limited, keep per-key order and skip orders that already have a newer version applied, since replaying old state over new is worse than the original failure. Analytics needs a targeted repair because its silent default hid the problem, and prevention means semantic validation before send, contract tests in the producer's CI, DLT alerts that page the producer, and full DLT headers.
Why this question is asked
Bad data incidents are messier than outages, because the system keeps running while the damage spreads in different ways to different consumers. Here two consumers failed loudly and parked 2.4 million records, one consumer failed silently by loading wrong values, and newer events kept flowing for the same orders. Interviewers ask this scenario at senior level because the obvious move, replay everything from the dead-letter topics, can make things worse. In this answer, we will contain the incident, measure it, choose between correction at the source and redrive, repair the silent consumer, and change the system so a bad release cannot spread this way again.
1Stop the Source and Measure the Damage
The first action is to stop new bad records: roll back the producer release, or switch off the code path behind a feature flag. Every minute of delay adds about 13,000 more bad records, since 2.4 million over three hours is roughly 800 a minute.
Next we measure. The dead-letter topics of billing and fulfilment tell us what each failed on. Spring Kafka's DeadLetterPublishingRecoverer adds headers such as kafka_dlt-original-topic, kafka_dlt-original-partition and kafka_dlt-original-offset, so by reading the first and last records per partition we get exact offset ranges of the incident on the source topic. From those ranges we extract the set of affected order ids, which is the list every later step works from. We also check which of those orders have received newer events since, because those need special care.
- Roll back the producerstop new bad records
- Measure from DLTsoriginal offset ranges, affected order ids
- Producer publishes corrections
OrderCorrectedthrough the normal path - Redrive only what is still neededrate-limited, ordered, version-checked
- Repair analytics rowsdelete and reload affected orders
- Add preventionvalidation, contract tests, DLT alerts
6 steps in order. Play them, or step through them one at a time.
2Prefer Correction at the Source
The producing team owns the meaning of OrderPlaced, and it knows the right currency for each affected order, from its database or from the order's checkout context. So the cleanest fix is for the producer to publish corrected events: either OrderPlaced again with the currency filled in and a correction flag, or a dedicated OrderCorrected event carrying the fixed fields and the order's current version.
The advantage is that every consumer receives the fix through its normal path, with its normal validation and idempotency. That includes analytics, which never failed and therefore has nothing in a dead-letter topic to redrive. Billing and fulfilment can then discard their dead-letter records for the affected orders, because the corrected events supersede them.
3If We Redrive, Do It Carefully
Sometimes redriving dead-letter records is still needed, for example where the consumer has since been fixed to accept the record. The danger is that many of these orders have moved on. Order O-881 failed on OrderPlaced at 10:15, but at 11:30 it received OrderCancelled, which was processed normally. Replaying the old OrderPlaced now could resurrect a cancelled order. Replaying old state over newer state is worse than the original failure.
The tool rate-limits, so 2.4 million records do not swamp the consumers or their databases; at 200 records a second it takes about three and a half hours per consumer, which is acceptable for a clean-up. It keeps per-key order by processing the dead-letter topic partition by partition and producing with the same key. And it checks each order's applied version, skipping any record whose order already has a newer version. That check is only possible if events carry a per-order version, which is one of the lessons.
4Repair the Silent Consumer
Analytics did the worst thing: it loaded the records with a default currency, perhaps USD, so 2.4 million orders have amounts in the wrong currency in reports, and nothing alerted. It needs a targeted repair: delete the rows for the affected order ids, then reload them from the corrected events or from the order service's database.
The lesson is that silent defaults on required fields are dangerous. A missing currency is not a value to guess; it is invalid data. Analytics should reject such records into its own dead-letter topic, so the failure is visible and the same clean-up process applies.
5Preventing the Spread Next Time
Several layers stop this from happening again, each catching what the previous one missed. In the producer, validation before send should include semantic rules, not just schema types: a currency field that is a string but empty passes Avro, but should fail a rule like "currency is a three-letter ISO 4217 code". Consumer-driven contract tests, where consumers state the fields and rules they rely on and the producer's CI checks every build against them, would have failed this release before it shipped.
On the consumer side, alerts on dead-letter inflow should page the producing team, not just the consumer team, since the producer is usually the one who can fix it fast; an alert at 100 records in five minutes would have fired within minutes of the release instead of three hours later. And dead-letter records must always keep the original topic, partition, offset and exception headers, because without them the measurement step above becomes guesswork.
| Layer | Check | Would have caught it |
|---|---|---|
| Producer code | Semantic validation before send | At the first record |
| Producer CI | Consumer-driven contract tests | Before release |
| Consumers | Reject, never default, required fields | Analytics too |
| Monitoring | DLT inflow alert pages producer | Within minutes |
6Follow-up questions
Why not just replay the whole source topic for the incident window after the producer is fixed?
Because the source topic still contains the bad records; replaying them reproduces the failure. And replaying the newer events from the same window into consumers that already processed them relies on perfect idempotency everywhere. Corrected events for the affected orders, published fresh, are smaller, targeted and safe.
Who leads an incident like this?
Usually an incident lead from the platform or the producing team, with an owner per consumer. The lead's job is the order of steps above, a single list of affected order ids shared by everyone, and a post-incident review that turns the lessons into tracked changes.
7Conclusion
In this answer, we led the clean-up of 2.4 million bad OrderPlaced events. We stopped the source, measured the damage from dead-letter topics and their original-offset headers, and listed the affected order ids. We preferred correction at the source, so every consumer received fixed events through its normal path. Any redrive was rate-limited, ordered by key and skipped orders that already had newer versions. Analytics needed a targeted repair because its silent default hid the problem. Finally, semantic validation, contract tests, DLT alerts that page the producer and complete DLT headers stop the next bad release from spreading.
Open with
First I would stop the source by rolling back the producer release. Then I would measure: count affected records per consumer from the dead-letter topic sizes, use the kafka_dlt-original-offset headers to get the exact offset ranges on the source topic, and build one list of affected order ids that everyone works from.
Then, if they want more
I would prefer correction at the source: the producing team publishes corrected events, or an OrderCorrected event, so every consumer, including analytics which never failed, receives the fix through its normal path, and billing and fulfilment can discard their DLT records.
If we do redrive dead-letter records, I would use a tool that rate-limits, keeps per-key order, and skips any record whose order already has a newer version applied, because many orders received newer events in the meantime, and replaying old state over newer state is worse than the original failure.
Analytics needs a targeted repair, deleting and reloading the affected rows, because its silent default hid the problem; required fields should be rejected, never defaulted.
To prevent spread, I would add schema validation with semantic rules in the producer before send, consumer-driven contract tests in the producer's CI, alerts on DLT inflow that page the producing team, and make sure DLT records always keep the original topic, partition, offset and exception headers.
About this answer
- Last updated
- 13 November 2026
- Checked
- Its structure and format are checked automatically. Use it as a carefully prepared study note: where a detail matters, confirm it against the documentation below. What the checks cover
- Where the question comes from
- Written by Scrivio for practice. It is not taken from an interview.
- Official documentation
- Apache Kafka documentation
Report an issue with this answer
Copy the line below and send it to the author with what you found. It carries the address of this page.
Issue with "Billing and fulfilment sent them to their dead-letter topics, analytics loaded them with...": https://scrivio-interview-library.netlify.app/spring-boot/kafka-design/91a3948cee/