FDE Times dataFDE jobs open 932▼14 Change in open roles over 7 days, like-for-like: roles from companies we started tracking this week are left outNew in 7 days 62Companies hiring 202Remote-friendly 24%Median US pay $201kTop hirer Databricks 92
中文VI

The newspaper of the Forward Deployed Engineer

Guides

Where bad records go when a client's pipeline cannot stop

A dead letter queue can hold broken data safely, but only if retries, retention and an on-call owner are set up correctly.

ShareLinkedInFacebookX

In brief

  • By default Kafka Connect stops when it hits an error. With errors.tolerance=all, the connector drops bad records without logging them. Both are dangerous for client data.
  • A DLQ is only safe when retries leave enough room for transient errors, the DLQ keeps messages longer than the source queue, and the DLQ topic has a subscription.
  • A DLQ is a debugging tool: always write the failure reason into the message, make sure someone reads it, and redrive only after the fault is fixed.
Timeline from day 0 to day 4. An order enters the queue on day 0, is retried in the source queue until day 3, then moves to the DLQ. Because the message keeps its original timestamp and both queues retain messages for 4 days, it has only 1 day left in the DLQ before it expires on day 4.
In SQS standard queues, a message moved to a DLQ keeps the timestamp from when it entered the source queue, which shortens the time available to investigate. Hypothetical example from the article. Source: AWS SQS documentation, as cited in the article.

At two in the morning, a retail client calls to say the orders table in its data warehouse has not moved since the evening. The cause is a single record with a badly formatted date field. The connector hit it and stopped, and tens of thousands of healthy records behind it are stuck waiting too.

Many engineers’ first reflex is to switch on error skipping so the pipeline keeps running. That creates the second problem: a month later the client’s finance team finds revenue that does not reconcile, and nobody can explain it, because no trace remains that the record ever existed.

Working on site as an FDE, you will hit this bind again and again: the pipeline must not stop, and the data must not be lost. A dead letter queue (DLQ) gets you out of it, provided you know where it can fail.

Stop or skip, the client loses either way

When a message cannot be processed, a system has only three options: stop, skip it, or move it somewhere else. Kafka Connect stops by default. Set errors.tolerance=all and the connector skips bad records instead, an approach a Confluent analysis calls “YOLO”.

“Silently” is meant literally here. According to Confluent, once error tolerance is on, the connector by default does not log that it is dropping messages. Without a DLQ or logging configured, you lose data with no way of knowing.

The third option is to route the record into a separate queue. AWS’s SQS documentation describes a DLQ first and foremost as a debugging tool: messages that cannot be consumed are isolated so you can work out why processing failed. Treat a DLQ as a quarantine ward with a doctor on duty, not as a bin.

An orders pipeline, configured line by line

Back to the retail client: orders flow through Kafka Connect into the warehouse. For that connector, a sensible configuration looks like this:

errors.tolerance=all
errors.deadletterqueue.topic.name=dlq-orders-sink
errors.deadletterqueue.context.headers.enable=true
errors.log.enable=true

The third line is the most valuable. Kafka Connect can write the reason a message was rejected into that message’s own headers. When you open the DLQ the next morning, you see at once which record failed and why, with no need to rerun anything to guess.

As noted above, with tolerance enabled the connector does not log dropped messages by default. The last line adds a trace in the logs alongside the DLQ, so data loss cannot happen in silence.

On Confluent Cloud, serde (serialize/deserialize) errors do not stop the connector either: it keeps running and sends the failed records to a DLQ topic.

Suppose the client’s order handling ran on SQS instead. Then the key number is maxReceiveCount in the redrive policy, the number of times a consumer may receive a message before it is moved to the DLQ:

{
  "deadLetterTargetArn": "arn:aws:sqs:...:orders-dlq",
  "maxReceiveCount": 5
}

AWS advises leaving enough room for retries. Set this value to 1 and a single failure, say a database flickering for a few seconds, is enough to push a message into the DLQ. The DLQ then fills with perfectly valid orders, and the handful of genuinely broken records get lost among them.

The retention arithmetic that loses messages

The hardest trap to spot is retention. With SQS standard queues, a message moved to a DLQ keeps the timestamp from when it entered the source queue. That is why AWS recommends always setting the DLQ’s retention longer than the source queue’s.

A hypothetical example makes it concrete: both queues keep messages for 4 days. An order enters the queue on day 0 and retries until day 3, when it is finally moved to the DLQ.

The clock does not restart, so you have only 1 day left to investigate. If that day falls on a weekend, the message may expire before anyone opens it.

Google Pub/Sub has a different trap. The maximum number of delivery attempts before a message moves to the dead-letter topic must be an integer from 5 to 100. But if the dead-letter topic has no subscription, messages forwarded there are lost, so Google’s documentation reminds you to add a subscription to that topic.

Platform Settings to tune Where data is easily lost
SQS maxReceiveCount, DLQ retention DLQ retention equal to or shorter than the source queue’s
Kafka Connect errors.tolerance, DLQ topic, failure-reason headers Tolerance enabled with no DLQ or logging
Pub/Sub Maximum delivery attempts, from 5 to 100 Dead-letter topic without a subscription

In what order to roll it out on site?

Start by asking the client one question: does message order matter to them? AWS warns against attaching a DLQ to a FIFO queue if you do not want to break the exact order of messages or operations. A sequence of account balance updates is a very different thing from a stream of event logs, and the answer shapes the whole design.

Next, choose the retry count based on the kinds of transient errors the client’s systems tend to hit. Set the DLQ’s retention longer than the source queue’s, turn on failure-reason recording, and check that the DLQ has a subscription or consumer. Then set an alert for new messages in the DLQ, and agree with the client on who receives it.

The last step is the runbook. On SQS, once the investigation is done you can send messages back with DLQ redrive. The right order is to read the reason, fix the code or the data, and only then redrive. Do it the other way round and the message just goes round once more and lands back in the DLQ.

Mistakes that recur across projects

The most common is treating the DLQ as a box to tick: configured, but with no alert, no owner, and nobody opening it for weeks.

Next comes setting retries too low, which fills the DLQ with transient errors. Then the retention and subscription arithmetic described above, since both lose messages without any warning.

There is also a communication mistake: not telling the client the DLQ exists. Put the DLQ record count in your regular reports. A client will trust the system more after reading “12 records with a bad date format, fixed and reprocessed” than after stumbling on a revenue figure nobody can explain.

For your career, this is a skill worth spelling out on a CV. Instead of “built data pipelines”, write that you designed DLQ-based error handling, with a redrive runbook, for a production system. In a system design interview, when asked “what if a record is corrupt?”, do not just say “retry it”.

Name all three settings: retries generous enough for transient errors, DLQ retention longer than the source queue’s, and the failure reason written into headers plus a subscription so the DLQ actually gets read.

An exercise for this week

Set up a test queue with a DLQ, then send it a message that deliberately violates the schema. Follow it through each retry, read the failure reason in the DLQ, fix the consumer, then redrive and confirm the message reaches its destination.

Once you have been round that loop, the next time a client calls at two in the morning you will be able to show them exactly where every failed record is.

Was this article useful?

Use with your AI assistantAsk Claude ↗Ask ChatGPT ↗
4 sources
Read next on the roadmap · Stage 5: DeploymentA patch for one customer can break three othersSemantic versioning, changelogs and maintenance windows tell each customer in advance when they will be upgraded and what will change.