Skip to content
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

Expose user exception thrown during rebalance #2667

Merged
merged 1 commit into from
May 8, 2023

Conversation

michaldo
Copy link
Contributor

@michaldo michaldo commented Apr 25, 2023

As a user, I do not want my exception be effectively ignored by framework by logging them on debug level

As a user, I do not want exception my exception be effectively ignored by framework by logging them on debug level
@@ -52,7 +52,7 @@ default void onPartitionsRevokedBeforeCommit(Consumer<?, ?> consumer, Collection
onPartitionsRevoked(partitions);
}
catch (Exception e) { // NOSONAR
LOGGER.debug(e, "User method threw exception");
LOGGER.error(e, "User method threw exception");
Copy link
Member

Choose a reason for hiding this comment

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

I don't think that this is what we want to have as a default behavior.
If you are not OK with debug, you always can override this method in your impl and error() it instead.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

A callback interface that the user can implement to trigger custom actions when the set of partitions assigned to the consumer changes.
(...)
There are many uses for this functionality. One common use is saving offsets in a custom store. By saving offsets in the onPartitionsRevoked(Collection) call we can ensure that any time partition assignment changes the offset gets saved.
Another use is flushing out any kind of cache of intermediate results the consumer may be keeping.

I can't imagine any scenario when I implement callback and is OK that framework silently ignores the exception thrown by callback.
I always prefer rely on framework default when unexpected error appears rather than reinvent the wheel. That's idea of framework: focus on business and leave all rest default.
Swallow user exception is not good default in any framework

Copy link
Member

Choose a reason for hiding this comment

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

OK. Let's hear then back from @garyrussell who did that logic in the ConsumerAwareRebalanceListener!

Copy link
Contributor

Choose a reason for hiding this comment

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

I have no trouble with this; user listeners should never throw exceptions; this code was added "just in case".

Copy link
Contributor

@garyrussell garyrussell May 1, 2023

Choose a reason for hiding this comment

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

Just to clarify; this was also to protect against a strange use case where the user implements ConsumerAwareRebalanceListener but actually overrides one or more of the ConsumerRebalanceListener methods (without a Consumer).

artembilan@5879b41

@garyrussell garyrussell added this to the 3.0.7 milestone May 8, 2023
@garyrussell garyrussell merged commit 01c68fc into spring-projects:main May 8, 2023
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.

3 participants