Skip to content

Verify DLT partition in batch recovery - #4891

Merged
sobychacko merged 1 commit into
spring-projects:mainfrom
beyondwin:verify-dlt-partition-batch
Nov 10, 2026
Merged

sobychacko merged 1 commit into
spring-projects:mainfrom
beyondwin:verify-dlt-partition-batch

Conversation

@beyondwin

Copy link
Copy Markdown
Contributor

Auto-cherry-pick to 4.1.x & 4.0.x

The batch fallback of DefaultErrorHandler and the batch recovery of
DefaultAfterRollbackProcessor recovered records with the 2-arg
accept(), so a DeadLetterPublishingRecoverer got no consumer and
skipped its DLT partition check. For a record on a partition that the
DLT does not have, the publication failed and the batch was
redelivered forever, while a record listener with the same setup
reaches the DLT.

Pass the consumer to a ConsumerAwareRecordRecoverer, as
FailedRecordTracker does since GH-1700. As on the record path, a
DeadLetterPublishingRecoverer subclass that overrides only the
2-arg accept() is no longer called on these paths and should
override the 3-arg method; the integration test overrides switch to
it, as GH-1700 did.

@beyondwin

Copy link
Copy Markdown
Contributor Author

DefaultBatchToRecordAdapter makes the same 2-arg call. It is a separate component, so I left it for a follow-up.

On 4.1.x and 4.0.x, a DeadLetterPublishingRecoverer subclass that overrides only the 2-arg accept() stops being called on these two batch paths, as it already is on the record path. If that is too much for a patch release, the fix can stay on main.

The batch fallback of `DefaultErrorHandler` and the batch recovery of
`DefaultAfterRollbackProcessor` recovered records with the 2-arg
`accept()`, so a `DeadLetterPublishingRecoverer` got no consumer and
skipped its DLT partition check. For a record on a partition that the
DLT does not have, the publication failed and the batch was
redelivered forever, while a record listener with the same setup
reaches the DLT.

Pass the consumer to a `ConsumerAwareRecordRecoverer`, as
`FailedRecordTracker` does since spring-projectsGH-1700. As on the record path, a
`DeadLetterPublishingRecoverer` subclass that overrides only the
2-arg `accept()` is no longer called on these paths and should
override the 3-arg method; the integration test overrides switch to
it, as spring-projectsGH-1700 did. Document the change in the reference guide and
in the what's new.

Signed-off-by: WooSeung Kim <wooseung.dev@gmail.com>
Co-authored-by: Soby Chacko <soby.chacko@broadcom.com>
@sobychacko
sobychacko force-pushed the verify-dlt-partition-batch branch from 12d5909 to 227dcbf Compare November 9, 2026 22:58
@sobychacko sobychacko added this to the 4.2.0 milestone Nov 10, 2026
@sobychacko
sobychacko merged commit 6568e23 into spring-projects:main Nov 10, 2026
3 checks passed
@sobychacko

Copy link
Copy Markdown
Contributor

Thanks @beyondwin! This is merged into main and will go out in 4.2.

We decided not to backport it to 4.1.x/4.0.x. It changes which accept() method the batch paths call, so a DeadLetterPublishingRecoverer subclass that only overrides the 2-arg accept() would stop being called after a patch upgrade, without any error or log message. We'd rather not make that change in a patch release. On the older lines you can work around the issue by giving the DLT at least as many partitions as the source topic, or by using a destination resolver that returns a negative partition so the producer picks one. I also added an upgrade note to the reference docs and the "What's New" for 4.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants