Dead Letter Queues (DLQ)
A poison message should never take a healthy pipeline down with it — and it
should never disappear silently either. ArkFlow's structured DLQ gives every
operator an explicit error policy, routes failed records to the stream's
error_output in one fixed envelope schema, bounds what a single failure
can write, and trips a circuit breaker before a bad stream can empty itself
into the DLQ unnoticed.
error_output:
type: kafka
brokers: [localhost:9092]
topic:
type: value
value: dead-letters
dlq:
max_payload_bytes: 65536
max_consecutive_errors: 100
The on_error policy
Every processor, the input codec, and the output accept an on_error key:
| Value | Meaning |
|---|---|
| (omitted) | Legacy behavior. Processors route the failed batch to error_output when one is configured (otherwise fail); codecs and outputs fail. |
fail | Fail the operator. Never routes to error_output, even when one is configured. |
dlq | Route failed records to error_output as dead-letter envelope rows. |
drop | Discard failed records (with a warning) and continue. Valid without error_output. |
error_column | Processors only. Failed rows continue downstream with the reason in an __error column. Requires a processor that implements the row-error protocol. |
The input codec also accepts skip as an alias of drop (the legacy
plugin-level spelling). The codec policy is engine-level: it applies to
every codec, not just the ones that implement isolation themselves.
streams:
- id: on-error-example
input:
type: kafka
brokers: [localhost:9092]
topics: [orders]
consumer_group: arkflow-on-error
pipeline:
processors:
- type: sql
query: "SELECT order_id, amount FROM flow WHERE amount > 5"
on_error: dlq
output:
type: stdout
error_output:
type: stdout
What gets routed
- Codec failures. Under
on_error: dlq, a message that fails to decode is carried through the pipeline as a marker row and routed toerror_outputwith its raw bytes; messages that decode keep flowing. One bad message never discards the good batch around it. - Processor failures. A processor without row support is re-invoked on
halves of the failing batch until the failing rows are isolated (good rows
are never probed again individually). Processors that implement the
row-error protocol —
llmships with it in V1 — report failing rows directly, so nothing is re-invoked at all. - Output failures. Failures are classified by their error variant: outage-class errors (lost connection, authentication, the sink-write timeout) stay fatal under every policy — an outage must never be converted into dead letters, the remedy is restart and replay. Deterministic failures and rate limits, once the connector's own retries are exhausted, are dead-lettered (or dropped).
The dead-letter envelope
In a stream where any operator declares on_error: dlq, every delivery
routed to error_output — including legacy-routed ones — is wrapped into one
row per failed record with this fixed schema:
| Column | Type | Content |
|---|---|---|
__dlq_job_id | Utf8 | The stream/Job identifier. |
__dlq_operator | Utf8 | <kind>:<name or type> — codec:json, processor:llm-1, output:clickhouse. |
__dlq_error_kind | Utf8 | parse_error, transform_error, sink_error, or timeout. |
__dlq_error_msg | Utf8 | The error text, truncated. |
__dlq_timestamp_ms | Int64 | Wall-clock routing time. |
__dlq_payload | Binary | Raw bytes at the codec stage; the failed row as a JSON object otherwise (__meta_* included). |
__dlq_truncated | Boolean | Set when payload or message was cut. |
Truncation
dlq.max_payload_bytes (default 65536) bounds both __dlq_payload and
__dlq_error_msg, so an oversized poison pill cannot break the DLQ sink
itself. Raw payloads cut on a byte boundary; JSON payloads on a UTF-8
boundary.
Delivery guarantees
When one delivery splits into a main part and a DLQ part, both parts share a fan-out acknowledgement: the source cursor and the WAL position advance only after both the main sink and the DLQ sink confirm their writes. A slow DLQ sink backpressures the pipeline through the bounded error edge; a failing one is retried with capped backoff (30 attempts) before the job fails — and a delivery that never reached the DLQ is never acknowledged.
Circuit breaker
dlq.max_consecutive_errors (unset by default — the breaker is off) bounds
silent diversion. The streak folds in row order per delivery: any
successfully processed record resets it, each disposed record — routed,
dropped, or legacy-routed — extends it, and interleaved failures never build
a streak. When a delivery would cross the threshold, nothing from that
delivery is routed or dropped: the operator fails (the fail behavior), an
error-level log names the operator and threshold, and the
circuit_breaker_trips counter increments.
Metrics
Each chain exports arkflow_job_chain_dlq_routed_total,
arkflow_job_chain_dlq_dropped_total and
arkflow_job_chain_circuit_breaker_trips_total, labeled by Job and chain
only. See Observability.
Validation
--validate rejects: on_error: dlq without error_output, a dlq block
without error_output, a policy other than fail on error_output itself
or on an output-side codec, max_payload_bytes: 0,
max_consecutive_errors: 0, and error_column on a processor that does not
implement the row-error protocol.
Rollback
Older binaries parse the new keys as unknown and ignore them. Before rolling
back, remove on_error and dlq from the configuration.