Dead-letter Kafka records individually within a batch#33
Open
mcruzdev wants to merge 4 commits into
Open
Conversation
The consumer now reads records in batches (Message<ConsumerRecords>). Batch ack/nack apply to the whole batch, so a single bad record cannot be nacked on its own without affecting the rest. Instead of nacking, each failed record is produced to the data-index-events-dlq topic via a dedicated emitter, and the batch is acked exactly once after all dead-letter writes complete. The batch offset is committed only after every dead-letter write has finished, so a failed record is never dropped: if a dead-letter write itself fails the batch is not committed (failure-strategy=fail) and the records are reprocessed. Successfully processed records remain committed via the same ack. Replaces the incoming dead-letter-queue failure strategy with an outgoing data-index-events-dlq channel. Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
f069f64 to
e108a5e
Compare
Contributor
|
@mcruzdev I have add this PR mcruzdev#2 that batches both workflow and task persistence. In my benchmark, after adding this fix, we got a great improvement for "fork10" scenario with 40 requests/second: Before persistence batch:
After persistence batch:
|
The batched task upsert (persistBatch) cannot create the placeholder workflow needed when a task event arrives before its workflow, so the whole batch failed with a foreign key violation and was retried forever. On a FK violation, roll back and fall back to per-record persistence, which already creates placeholders idempotently. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
fjtirado
reviewed
Jun 24, 2026
Signed-off-by: Matheus Cruz <matheuscruz.dev@gmail.com>
fjtirado
approved these changes
Jun 25, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Changes
The consumer now reads records in batches (
Message<ConsumerRecords>). Batchack/nackapply to the whole batch, so a single bad record cannot be nacked on its own without affecting the rest.Instead of nacking, each failed record is produced to the
data-index-events-dlqtopic via a dedicated emitter, and the batch is acked exactly once after all dead-letter writes complete.The batch offset is committed only after every dead-letter write has finished, so a failed record is never dropped: if a dead-letter write itself fails the batch is not committed (failure-strategy=fail) and the records are reprocessed.
Successfully processed records remain committed via the same ack.
Replaces the incoming
dead-letter-queuefailure strategy with an outgoingdata-index-events-dlqchannel.Closes #32