[
https://issues.apache.org/jira/browse/KAFKA-21522?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
이선민 resolved KAFKA-21522.
-------------------------
Fix Version/s: 4.5.0
Resolution: Fixed
> GlobalStreamThread runs the uncaught exception handler and its shutdown with
> the interrupt flag set
> ---------------------------------------------------------------------------------------------------
>
> Key: KAFKA-21522
> URL: https://issues.apache.org/jira/browse/KAFKA-21522
> Project: Kafka
> Issue Type: Bug
> Components: streams
> Reporter: 이선민
> Assignee: 이선민
> Priority: Minor
> Fix For: 4.5.0
>
>
> Follow-up of KAFKA-21070 (https://github.com/apache/kafka/pull/23549), as
> discussed there with [~lucasbru].
> The PR for KAFKA-21070 (not merged yet) changes {{StreamThread.run()}} to
> clear the interrupt flag before the uncaught exception handler and
> {{completeShutdown}} run, and to restore it when the shutdown is complete.
> {{GlobalStreamThread}} has its own {{run()}} and does not do this.
> If the global thread is interrupted while it is running, the interrupt
> surfaces as an {{InterruptException}}, for example from the global consumer's
> {{poll()}}. The constructor of {{InterruptException}} sets the flag again.
> {{GlobalStreamThread.run()}} catches the exception, calls
> {{streamsUncaughtExceptionHandler.accept(e)}} and then closes the state
> consumer in the {{finally}} block, all with the interrupt flag still set:
> * The user handler and the state listener run on an interrupted thread.
> * The work the handler triggers runs on the interrupted global thread. With a
> handler that returns {{SHUTDOWN_APPLICATION}} and a single stream thread,
> {{addStreamThread}} is called from there. In KAFKA-21070 the same call on an
> interrupted stream thread failed with the streams protocol, in
> {{ConsumerNetworkThread.start}} on {{initializationLatch.await()}}.
> * {{stateConsumer.close(wipeStateStore)}} runs interrupted, so closing the
> global consumer can be cut short. The state stores are flushed and closed on
> the interrupted thread as well.
> This is from reading the code on trunk. I have not reproduced it for the
> global thread.
> Proposed fix: handle it in {{GlobalStreamThread.run()}} the same way as the
> PR does in {{StreamThread.run()}}: record and clear the flag in the {{catch}}
> blocks before the handler runs and once more at the start of the {{finally}}
> block, and restore it when the shutdown is complete.
--
This message was sent by Atlassian Jira
(v10.3.26#10030026)