fix: UncaughtExceptionHandler not being set for Persistent Queries #4087
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #4079
It looks like from the original PR https://github.com/confluentinc/ksql/pull/3425/files to master, there was some refactoring done with how the Streams app is created which inadvertently changed the UncaughtExceptionHandler's behavior. The refactor changed https://github.com/confluentinc/ksql/pull/3425/files#diff-ef0765548f1131d562da8a8ef9edad73R285 was doing. The UncaughtExceptionHandler needs to be set for PersistentQueries (It's set in
QueryStreamWriter.java
for transient), which is why previously there's an explicit call in thebuildPlanForStructuredOutputNode
method (this was the pre-refactor method for creating PersistentQueries). The refactor resulted insetUncaughtExceptionHandler()
being moved to thebuildTransientQuery
when it should've been moved tobuildQuery
We need to be setting a exception handler for streams threads because they shouldn't pick up the global uncaught exception handler (which terminates the server when hit).
I've moved setting the handler to
KafkaStreamsBuilderImpl
which is called before creating every Streams App.This may also need to be backported to 5.4.x as the refactor was before that branch was cut.
Testing done
Tried the scenario outlined in the Github Issue and the server didn't shut down after this change.
Also, manually verified in debug mode that the handlers were set for the streams threads.
Reviewer checklist