-
Notifications
You must be signed in to change notification settings - Fork 112
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
When an exception is thrown from a @KafkaListener, the remaining messages in the poll loop are skipped #372
Comments
We have observed this behaviour as well on micronaut kafka version 3.3.3. Managed to set up an example application before finding that this issue was already reported: https://github.com/littlewoo/micronaut-kafka-message-skipping |
@jaksah I guess maybe I am misunderstanding something here, but consider this scenario:
At this point the act of committing the offset tells Kafka it has moved past the record both Record 1 and Record 2 does it not and hence Record 1 will never be processed? Or am I missing something? |
@graemerocher Our example application is adding a message to a map before throwing the exception, and at application shutdown it prints out what messages was received. The test is producing 50 messages but the consumer ends up stating it received ~40 messages (varies between runs). I think it's due to this line, returning |
Yes @jaksah , this is my understanding too. Hi @graemerocher , regarding your first bullet point - this isn't actually how it behaves (it will skip remaining messages in the poll loop). The example application has a test that demonstrates this. |
Given issue #315 I was curious about this as well. I updated
|
Faced the same issue.The application can have a feedback loop for the unprocessed messages but explicitly should not throw away rest of the messages in the poll. |
Any thoughts about a configuration property to seek back to the failed offset in the default exception handler if the exception is not a deserialisation error? |
that seems reasonable |
We've been discussing this and we think this would be better than skipping over messages due to order of consumption. I believe the We will look at contributing a PR to micronaut kafka with the proposed suggestion. |
I've also been discussing with a colleague and the point raised below by @jaksah is a decision that the user should make around prioritising consistency or availability.
My thoughts are that if we do not return false when consuming the polled records, we would skip that message (which is what Spring does by default), thus prioritising availability over consistency (especially when order is important). If we return false and seek back to the failed offset, we prioritise consistency but reduce availability (no more messages will be consumed). I think both options are sensible but depend on the use case. |
We have the |
Thanks, @cwebbtw summarizing the availability vs consistency. I see this in 4 ways how this can be improved.
To fix this bug , is it ok if we pick the first option and move on . The error handling can be a new feature request ? @graemerocher |
@vsulibhavi if option 1) is chosen I assume a subsequent poll loop will pick up the failed on again if the offsets are not committed? |
I like this a lot actually rather than a new configuration property - I think this is different to what retryable topics in spring does, which is what @vsulibhavi is referring to in point 4. I quite like
Referring to what @graemerocher added:
In the case where the consumer repeatedly errors for each record in the poll loop, nothing would be commit and the subsequent poll loop would pick up from the last commit offset. Transient errors in downstream APIs can cause havoc here though if messages are skipped (and logged) and this goes back to the point of prioritising availability over consistency. |
@cwebbtw Thanks for your contribution! I have combined your changes with my into a separate PR that should solve this by introducing error strategies. |
Steps to Reproduce
Expected Behaviour
The next message on the partition is processed
Actual Behaviour
The remaining messages in the poll loop are skipped, and message consumption resumes from the next poll.
For example:
Environment Information
Example Application
Thanks for taking a look at this issue, I'd be interested to hear your thoughts on this. I was not sure if this behaviour was intended, but I know that developers on teams I have worked on who are using
@KafkaListeners
would not expect this.'At least once' processing is probably the most common durability requirement when working with Kafka, so it would be good if it was not necessary to 'catch all' exceptions in a KafkaListener to achieve this.
The text was updated successfully, but these errors were encountered: