-
Notifications
You must be signed in to change notification settings - Fork 1.6k
Losing messages in RetryingBatchErrorHandler/ErrorHandlingUtils during rebalancing #2340
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
Comments
Thanks for reporting; this is indeed a bug. Please note that the |
Thank you for your answer @garyrussell In spring-kafka 2.8.x: Default fallback is And |
Yes; I agree; I was just pointing out that the recovering mechanism is preferred to the (older) retrying mechanism that suffers from this bug. I will have a fix soon. |
Gotcha, thank you! |
Resolves spring-projects#2340 The `RetryingBatchErrorHandler` - now called the `FallbackBatchErrorHandler` pauses and resumes the consumer during retries, to allow it to poll the consumer to avoid a forced rebalance. However, if a normal rebalance occurs, for example if a new member joins, the error handler does not re-pause the consumer and silently consumes new records. Add a mechanism to always re-pause the consume when in this retry mode. **cherry-pick to 2.9.x, 2.8.x**
Resolves #2340 The `RetryingBatchErrorHandler` - now called the `FallbackBatchErrorHandler` pauses and resumes the consumer during retries, to allow it to poll the consumer to avoid a forced rebalance. However, if a normal rebalance occurs, for example if a new member joins, the error handler does not re-pause the consumer and silently consumes new records. Add a mechanism to always re-pause the consume when in this retry mode. **cherry-pick to 2.9.x, 2.8.x**
Resolves #2340 The `RetryingBatchErrorHandler` - now called the `FallbackBatchErrorHandler` pauses and resumes the consumer during retries, to allow it to poll the consumer to avoid a forced rebalance. However, if a normal rebalance occurs, for example if a new member joins, the error handler does not re-pause the consumer and silently consumes new records. Add a mechanism to always re-pause the consume when in this retry mode. **cherry-pick to 2.9.x, 2.8.x**
Resolves #2340 The `RetryingBatchErrorHandler` - now called the `FallbackBatchErrorHandler` pauses and resumes the consumer during retries, to allow it to poll the consumer to avoid a forced rebalance. However, if a normal rebalance occurs, for example if a new member joins, the error handler does not re-pause the consumer and silently consumes new records. Add a mechanism to always re-pause the consume when in this retry mode. **cherry-pick to 2.9.x, 2.8.x**
@vooft 2.8.8 with the fix is now in Maven Central. |
In what version(s) of Spring for Apache Kafka are you seeing this issue?
For example:
2.3.7+ (since introduction of
RetryingBatchErrorHandler
)Describe the bug
If a listener doing a retry and rebalancing kicks in, then the consumer will be unpaused and every keep-alive
consumer.poll()
invocation in the error handler will start returning records and the error handler will throw them away.spring-kafka/spring-kafka/src/main/java/org/springframework/kafka/listener/ErrorHandlingUtils.java
Line 69 in e4d9641
It seems that the rebalancing listener
KafkaMessageListenerContainer
can re-pause the consumer again, but it is not aware that the error handler paused it.To Reproduce
Create a listener with infinite retry
RetryingBatchErrorHandler
that will be constantly failing and force rebalancing. After rebalancing finishedRetryingBatchErrorHandler
will drain all the messages from assigned partitions without any processing.Expected behavior
RetryingBatchErrorHandler should re-pause consumer after rebalancing.
Sample
Test is using
RetryingBatchErrorHandler
, but logic inErrorHandlingUtils
is essentially the samehttps://github.com/vooft/kafka-retry-issue/blob/master/src/test/java/com/example/kafkaissue/KafkaIssueTest.java
The text was updated successfully, but these errors were encountered: