Skip to content

[#574] Evict corrupted transactional producers from the pool - #575

Merged
smcvb merged 2 commits into
AxonFramework:mainfrom
agrancaric:bugfix/transactional-producer-fatal-state-recover
May 1, 2026
Merged

smcvb merged 2 commits into
AxonFramework:mainfrom
agrancaric:bugfix/transactional-producer-fatal-state-recover

Conversation

@agrancaric

Copy link
Copy Markdown
Contributor

Closes #574.

When a transactional Producer enters fatal state (e.g. ProducerFencedException from beginTransaction / commitTransaction / abortTransaction), PoolableProducer was still returned to the cache. The next caller would then pick up the invalid producer and any send would block until delivery.timeout.ms expired.

PoolableProducer now marks itself corrupted when one of those transactional operations throws an exception, and on close() it closes the delegate producer instead of returning it to the pool.

Added an integration test that reproduces the fencing path by starting a second factory with the same transactional.id prefix to bump the broker-side epoch, then asserts the corrupted producer is not returned to the pool when closed.

Note

This branch also includes a commit that explicitly defines a version for the KafkaContainer. Without that change the integration tests don't start locally. That's the last version that still uses Zookeeper. I didn't switch the container from KafkaContainer to ConfluentKafkaContainer since it uses KRaft and in that case the tests in ConsumerSeekUtilIntegrationTest fail.

@agrancaric
agrancaric requested a review from a team as a code owner April 27, 2026 08:09
@agrancaric
agrancaric requested review from MateuszNaKodach, abuijze and hatzlj and removed request for a team April 27, 2026 08:09
@hatzlj hatzlj added this to the Release 4.12.1 milestone Apr 30, 2026

@hatzlj hatzlj left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@smcvb smcvb left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me 👍

@smcvb
smcvb merged commit 34f85e6 into AxonFramework:main May 1, 2026
5 of 7 checks passed
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.

DefaultProducerFactory (when using transactional mode) caches producers in fatal state

3 participants