[
https://issues.apache.org/jira/browse/KAFKA-19724?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18021835#comment-18021835
]
Mikołaj Bul commented on KAFKA-19724:
-------------------------------------
It is both missing logging and stream not going into {{ERROR}} state.
Replication of {{UnsatisfiedLinkError}} hitting the no-op error handler:
# Include {{kafka-streams-scala}} dependency in {{4.1.0}} version
# Create a Scala app with a KafkaStreams topology which relies on RocksDB
global state store, e.g:
{code:scala}
val builder = new StreamsBuilder()
val input: KStream[String, String] = builder.stream[String,
String]("input-topic")
val globalTable: GlobalKTable[String, Int] = builder.globalTable[String,
Int]("global-table-topic")
val joinedStream: KStream[String, Int] = input.join(globalTable)((key, _)
=> key, (_, joinedValue) => joinedValue)
joinedStream.to("output-topic")
val streams: KafkaStreams = new KafkaStreams(builder.build(), config)
streams.setUncaughtExceptionHandler { _ =>
// currently I won't be called
SHUTDOWN_APPLICATION
}
streams.start()
{code}
# Set up required topics
# Run the app on Linux with {{/tmp}} directory mounted with {{noexec}} option
(or set {{ROCKSDB_SHAREDLIB_DIR}} env variable to point to such directory)
# No error logging present and stream is stuck in `REBALANCING` state
Catching {{Throwable}} as you suggested will fix my issue but I'm not sure if
it's a good solution in general. Will it work in more serious cases, e.g.
{{OutOfMemoryError}} being thrown? As per [Java
docs|https://docs.oracle.com/javase/8/docs/api/java/lang/Error.html] in general
{{Error}} shouldn't be caught (and in Scala I've usually seen
[NonFatal|https://www.scala-lang.org/api/2.13.3/scala/util/control/NonFatal$.html]
extractor being used instead of catching {{{}Throwable{}}}.
> 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)