[
https://issues.apache.org/jira/browse/KAFKA-19724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18022529#comment-18022529
]
Matthias J. Sax commented on KAFKA-19724:
-----------------------------------------
Not sure if I can follow [~mikkolaj]? All exception that go into the
StreamsUncaughtExceptionHandler are fatal exception. Or course, there is still
different "classes" of fatal ones, but not sure if it would really matter much?
KS tries to call the handler in any case and let the user react to it.
{quote}The error occurs when {{setUncaughtExceptionHandler()}} is called
{quote}
Yes, that's "just" a bug. By default, when you call `new KafkaStreams()` there
is a default exception handler set (also on the GlobalThreadThread; for this
case, via the constructor). When you call
`KafkaStreams#setUncaughExceptionHandler()` the issue happens because we first
set the user provided handler correctly
([https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java#L467-L471)]
but later overwrite it incorrectly
([https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java#L475-L478)|https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/KafkaStreams.java#L475-L478]
Nevertheless, the initialization phase is not covered:
[https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java#L276-L292]
and I would assume that `UnsatisfiedLinkError` would be thrown here, not
invoking any handler. The regular processing-loop is covered though, and we
call the handler (however, we don't catch Throwable):
[https://github.com/apache/kafka/blob/trunk/streams/src/main/java/org/apache/kafka/streams/processor/internals/GlobalStreamThread.java#L295-L343]
> Global stream thread ignores all exceptions
> -------------------------------------------
>
> Key: KAFKA-19724
> URL: https://issues.apache.org/jira/browse/KAFKA-19724
> Project: Kafka
> Issue Type: Bug
> Components: streams
> Affects Versions: 3.4.0
> Reporter: Mikołaj Bul
> Assignee: Fatih Celik
> Priority: Major
> Labels: beginner, newbie
>
> {{globalStreamThread}} in {{KafkaStreams}} class ignores all exceptions and
> fails to apply the user-provided {{StreamsUncaughtExceptionHandler}} in:
> {code:java}
> public void setUncaughtExceptionHandler(final StreamsUncaughtExceptionHandler
> userStreamsUncaughtExceptionHandler)
> {code}
> This can lead to streams being stuck in faulty state after an exception is
> thrown during their initialization phase (e.g. failure to load the RocksDB
> native library). The exception isn't logged, so debugging such problem is
> difficult.
> From my understanding of the {{b62d8b97}} commit message, the following code
> is unnecessary as the {{globalStreamThread}} can't be replaced and the issue
> description from KAFKA-12699 doesn't apply to it. Removing it should help.
> {code:java}
> if (globalStreamThread != null) {
> globalStreamThread.setUncaughtExceptionHandler((t, e) -> { }
> );
> }
> {code}
--
This message was sent by Atlassian Jira
(v8.20.10#820010)