Guozhang Wang created KAFKA-5697:
------------------------------------

             Summary: StreamThread.close() need to interrupt the stream threads 
to break the loop
                 Key: KAFKA-5697
                 URL: https://issues.apache.org/jira/browse/KAFKA-5697
             Project: Kafka
          Issue Type: Bug
          Components: streams
            Reporter: Guozhang Wang


In {{StreamThread.close()}} we currently do nothing but set the state, hoping 
the stream thread may eventually check it and shutdown itself. However, under 
certain scenarios the thread may get blocked within a single loop and hence 
will never check on this state enum. For example, it's {{consumer.poll}} call 
trigger {{ensureCoordinatorReady()}} which will block until the coordinator can 
be found. If the coordinator broker is never up and running then the Stream 
instance will be blocked forever.

A simple way to produce this issue is to start the work count demo without 
starting the ZK / Kafka broker, and then it will get stuck in a single loop and 
even `ctrl-C` will not stop it since its set state will never be read by the 
thread:

{code}
[2017-08-03 15:17:39,981] WARN Connection to node -1 could not be established. 
Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2017-08-03 15:17:40,046] WARN Connection to node -1 could not be established. 
Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2017-08-03 15:17:40,101] WARN Connection to node -1 could not be established. 
Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2017-08-03 15:17:40,206] WARN Connection to node -1 could not be established. 
Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2017-08-03 15:17:40,261] WARN Connection to node -1 could not be established. 
Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2017-08-03 15:17:40,366] WARN Connection to node -1 could not be established. 
Broker may not be available. (org.apache.kafka.clients.NetworkClient)
[2017-08-03 15:17:40,472] WARN Connection to node -1 could not be established. 
Broker may not be available. (org.apache.kafka.clients.NetworkClient)
^C[2017-08-03 15:17:40,580] WARN Connection to node -1 could not be 
established. Broker may not be available. 
(org.apache.kafka.clients.NetworkClient)
{code}



--
This message was sent by Atlassian JIRA
(v6.4.14#64029)

Reply via email to