-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix: isolate per-record failures in Kafka sink transformer and guard DLQ reporter #49286
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
xinlian12
merged 13 commits into
Azure:main
from
xinlian12:fix/issue-49268-single-record-dlq
May 29, 2026
Merged
Changes from all commits
Commits
Show all changes
13 commits
Select commit
Hold shift + click to select a range
672a8fe
fix: isolate per-record ID-generation failures in Kafka sink transfor…
xinlian12 cc8e58a
test: add SinkRecordTransformer per-record error isolation tests
xinlian12 d49548c
Guard ErrantRecordReporter.report() against exceptions
xinlian12 82946c1
Align transformer error handling with writer pattern; harden
xinlian12 4ac387b
fix: catch RuntimeException instead of Exception to fix compilation
xinlian12 e5f697d
fix: remove errantRecordReporter guard to match writer pattern; fix t…
xinlian12 7d45caa
Merge branch 'upstream-main' into fix/issue-49268-single-record-dlq
xinlian12 d5927e7
revert gitignore change
xinlian12 e040721
add changelog
xinlian12 3f89a6a
update changelog
xinlian12 023af38
fix: resolve PR review comments — guard DLQ reporter, fix comments, a…
xinlian12 f23cbad
docs: update changelog to reflect DLQ reporter guard in CosmosWriterBase
xinlian12 433fec1
refactor: extract shared DLQ reporting into DlqReportHelper
xinlian12 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
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
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
52 changes: 52 additions & 0 deletions
52
...ect/src/main/java/com/azure/cosmos/kafka/connect/implementation/sink/DlqReportHelper.java
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,52 @@ | ||
| // Copyright (c) Microsoft Corporation. All rights reserved. | ||
| // Licensed under the MIT License. | ||
|
|
||
| package com.azure.cosmos.kafka.connect.implementation.sink; | ||
|
|
||
| import org.apache.kafka.connect.sink.ErrantRecordReporter; | ||
| import org.apache.kafka.connect.sink.SinkRecord; | ||
| import org.slf4j.Logger; | ||
|
|
||
| /** | ||
| * Shared helper for DLQ (Dead Letter Queue) reporting. | ||
| * | ||
| * <p>Both {@link CosmosWriterBase} and {@link SinkRecordTransformer} need fire-and-forget | ||
| * DLQ reporting that guards against reporter failures. This helper centralises that logic. | ||
| */ | ||
| final class DlqReportHelper { | ||
|
|
||
| private DlqReportHelper() { | ||
| } | ||
|
|
||
| /** | ||
| * Reports a failed record to the DLQ if a reporter is configured. | ||
| * | ||
| * <p>Per Kafka Connect best practices, DLQ reporting is a side-effect for observability — | ||
| * reporter failures are swallowed so they do not mask the original processing error. | ||
| * | ||
| * @param reporter the errant record reporter, may be {@code null} | ||
| * @param record the sink record that failed processing | ||
| * @param error the original processing error | ||
| * @param logger the caller's logger for error reporting | ||
| */ | ||
| static void reportToDlqIfConfigured( | ||
| ErrantRecordReporter reporter, | ||
| SinkRecord record, | ||
| Throwable error, | ||
| Logger logger) { | ||
|
|
||
| if (reporter == null) { | ||
| return; | ||
| } | ||
| try { | ||
| reporter.report(record, error); | ||
| } catch (Exception reportException) { | ||
| logger.error( | ||
| "Failed to report errant record to DLQ for topic {}, partition {}, offset {}.", | ||
| record.topic(), | ||
| record.kafkaPartition(), | ||
| record.kafkaOffset(), | ||
| reportException); | ||
| } | ||
| } | ||
| } |
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
Oops, something went wrong.
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.