-
Notifications
You must be signed in to change notification settings - Fork 1.7k
GH-2184 KafkaBackOffException logged as ERROR #2185
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
Conversation
The change looks good to me. Out of curiosity, why does |
@v-chernyshev thanks for looking into this. I don't have a proper answer to your question, so I defer to @garyrussell on this one. |
It's historical; before 2.7, the method was called On reflection, it could (and maybe should) be refactored to use the newer |
I agree there's room for streamlining this code a bit, and it would help keeping consistency between the various scenarios. |
Right, but not in this PR; I'll add an issue to the backlog. |
I think we should consider not calling the retry listeners for these exceptions, but that would be a different issue/PR. |
...and back-ported to 2.8.x as da0b820 |
Sure. I was thinking something along these lines: Would still need to nitpick if there's any behavior change, but all tests are passing, and we make sure that all scenarios are using the same recovery logic. A possible improvement would be having the exception classification inside the Of course, this is just a suggestion, if anyone else has a different idea that's ok. Thanks. |
A version without the inner class - it has less changes and should be better to review. |
I was thinking something like this...
But your way works too. |
Sure, this looks good too, and has the benefit of not having to expose the recovery logic to the I'm ok with both approaches, as both will let us have a single recovery logic for all paths. So go ahead with yours if you prefer, no worries, or let me know and I can wrap up mine and open a PR. |
Resolves spring-projects#2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here spring-projects#2185 (comment)
Resolves spring-projects#2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here spring-projects#2185 (comment) The new logic is disabled by default, we can consider enabling it in 3.0 and remove the deprecations.
Resolves spring-projects#2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here spring-projects#2185 (comment) The new logic is disabled by default, we can consider enabling it in 3.0 and remove the deprecations.
Resolves spring-projects#2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here spring-projects#2185 (comment) The new logic is disabled by default, we can consider enabling it in 3.0 and remove the deprecations.
Resolves spring-projects#2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here spring-projects#2185 (comment) The new logic is disabled by default, we can consider enabling it in 3.0 and remove the deprecations.
Resolves spring-projects#2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here spring-projects#2185 (comment) The new logic is disabled by default, we can consider enabling it in 3.0 and remove the deprecations.
Resolves #2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here #2185 (comment) The new logic is disabled by default, we can consider enabling it in 3.0 and remove the deprecations. * Fix race - do not call `resume()` on the container; the user might have paused after the error. * Change Since to 2.9. * Fix typos. Co-authored-by: Artem Bilan <[email protected]> * Remove unnecessary local variable; add docs. * Polishing - see commit comment for more details - move the resume logic to after the invokes and don't resume if pending records - don't check `isPaused()` after empty poll due to errors; always restore the pending records * Remove unnecessary boolean; fix deprecation warnings and delegating error handlers. * Emergency stop container if the consumer returns records while paused after an error. * Fix race in test - prevent consumer thread from changing pausedConsumers while the test thread is calling revoke/assign. * Remove System.out(). * Add diagnostics to test. * Fix race in test; wait until next poll after consumer thread pauses the partitions. * Fix stubbing in emergency stop test. * Remove unnecessary boolean. **Cherry-pick to `2.9.x`**
Resolves #2195 Add an option to avoid seeks after handling exceptions. Instead, pause the consumer for one `poll()` and use the remaining records as the result of that poll. New methods on `CommonErrorHandler` - `handleOne` for record listeners, returning a boolean to indicate whether the record was recovered and should not be redelivered. `handlaBatchAndReturnRemaining` for batch listeners, returning either the complete set or a subset, e.g. when the `DEH` receives a `BatchListenerExecutionFailedException` and commits a partial batch. Also includes the classifier refactoring discussed here #2185 (comment) The new logic is disabled by default, we can consider enabling it in 3.0 and remove the deprecations. * Fix race - do not call `resume()` on the container; the user might have paused after the error. * Change Since to 2.9. * Fix typos. Co-authored-by: Artem Bilan <[email protected]> * Remove unnecessary local variable; add docs. * Polishing - see commit comment for more details - move the resume logic to after the invokes and don't resume if pending records - don't check `isPaused()` after empty poll due to errors; always restore the pending records * Remove unnecessary boolean; fix deprecation warnings and delegating error handlers. * Emergency stop container if the consumer returns records while paused after an error. * Fix race in test - prevent consumer thread from changing pausedConsumers while the test thread is calling revoke/assign. * Remove System.out(). * Add diagnostics to test. * Fix race in test; wait until next poll after consumer thread pauses the partitions. * Fix stubbing in emergency stop test. * Remove unnecessary boolean. **Cherry-pick to `2.9.x`**
Fixes #2184
I also looked into leveraging
KafkaException
's self logging features here, but in order for it to work we'd need to make a few adjustments toKafkaMessageListenerContainer#decorateException
, and that looks like too much change for a bugfix to me.I still think we could have some configurable feature where a
KafkaException
could look into its causes, and use the deepest KE log level to self log. This way we could for example throw the originalKafkaBackOffException
asDEBUG
(or what the user configures), and leave all other exceptions asERROR
(or what the user configures), and no matter how many wrappings it goes through it'd still be logged asDEBUG
.Not sure if that's something that would be useful for scenarios other than KBE though.
Please let me know if there's anything to change.
Thanks