You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "Antony Stubbs (JIRA)" <ji...@apache.org> on 2018/05/25 12:24:00 UTC

[jira] [Comment Edited] (KAFKA-6943) Have option to shutdown KS cleanly if any task crashes, or if all tasks crash

    [ https://issues.apache.org/jira/browse/KAFKA-6943?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16490638#comment-16490638 ] 

Antony Stubbs edited comment on KAFKA-6943 at 5/25/18 12:23 PM:
----------------------------------------------------------------

Sorry, should have said thread, not task. For catching in the UncaughtExceptionHandler...

{code:java}
myKafkaStream.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

    @Override
    void uncaughtException(Thread t, Throwable e) {
        if(config.dieOnAnyUncaughtException){
	log.error("Uncaught exception in Kafka Streams thread: " t.toString + ". Shutting down...", e)
        def state = myKafkaStream.state()
        log.debug("State is: " + state)
        if (state != KafkaStreams.State.PENDING_SHUTDOWN) {
        	log.debug("Started...")
			def threadCloseTimeoutMs = 1
            myKafkaStream.close(threadCloseTimeoutMs, TimeUnit.MILLISECONDS)
        	log.debug("Finished...")
        }
        }
    }

});
{code}

sort of thing..


was (Author: astubbs):
Sorry, should have said thread, not task. For catching in the UncaughtExceptionHandler...

{code:java}
myKafkaStream.setUncaughtExceptionHandler(new Thread.UncaughtExceptionHandler() {

    @Override
    void uncaughtException(Thread t, Throwable e) {
        if(config.dieOnAnyUncaughtException){
	log.error("Uncaught exception in Kafka Streams thread: " t.toString + ". Shutting down...", e)
        def state = myKafkaStream.state()
        log.debug("State is: " + state)
        if (state != KafkaStreams.State.PENDING_SHUTDOWN) {
        	log.debug("Started...")
			def threadCloseTimeoutMs = 1
            myKafkaStream.close(threadCloseTimeoutMs, TimeUnit.MILLISECONDS)
        	log.debug("Finished...")
        }
        }
    }

});
{code:java}

sort of thing..

> Have option to shutdown KS cleanly if any task crashes, or if all tasks crash
> -----------------------------------------------------------------------------
>
>                 Key: KAFKA-6943
>                 URL: https://issues.apache.org/jira/browse/KAFKA-6943
>             Project: Kafka
>          Issue Type: Improvement
>          Components: streams
>    Affects Versions: 1.1.0
>            Reporter: Antony Stubbs
>            Priority: Major
>
> ATM users have to implement this themselves. Might be nice to have an option to configure that if all tasks crash, or if any crash, to initiate clean shutdown.
> This also has a gotcha where atm if you call KS#close without a timeout, from the uncaught exception handler, you dead lock.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)