You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@kafka.apache.org by "Aditya A Auradkar (JIRA)" <ji...@apache.org> on 2015/01/21 02:15:34 UTC

[jira] [Commented] (KAFKA-1886) SimpleConsumer swallowing ClosedByInterruptException

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

Aditya A Auradkar commented on KAFKA-1886:
------------------------------------------

Did a good bit of poking around. Basically, I wrote a test that runs a SimpleConsumer inside a thread and interrupts that thread from the main thread. This forces a ClosedByInterruptException that we catch in the SimpleConsumer:sendRequest method. Catching this exception does not reset the interrupt status of the Thread. The returned exception is a ClosedChannelException and the original exception is swallowed.

I can't spot any bug in Kafka here. I can suggest a couple of improvements:
- Don't retry inside SimpleConsumer if we catch a ClosedByInterruptException. Seems like extra work for nothing.
- Inspect code to check if we are catching InterruptedException somewhere. Based on a cursory inspection, I couldn't find anything.

> SimpleConsumer swallowing ClosedByInterruptException
> ----------------------------------------------------
>
>                 Key: KAFKA-1886
>                 URL: https://issues.apache.org/jira/browse/KAFKA-1886
>             Project: Kafka
>          Issue Type: Bug
>          Components: producer 
>            Reporter: Aditya A Auradkar
>            Assignee: Jun Rao
>
> This issue was originally reported by a Samza developer. I've included an exchange of mine with Chris Riccomini. I'm trying to reproduce the problem on my dev setup.
> From: criccomi
> Hey all,
> Samza's BrokerProxy [1] threads appear to be wedging randomly when we try to interrupt its fetcher thread. I noticed that SimpleConsumer.scala catches Throwable in its sendRequest method [2]. I'm wondering: if blockingChannel.send/receive throws a ClosedByInterruptException
> when the thread is interrupted, what happens? It looks like sendRequest will catch the exception (which I
> think clears the thread's interrupted flag), and then retries the send. If the send succeeds on the retry, I think that the ClosedByInterruptException exception is effectively swallowed, and the BrokerProxy will continue
> fetching messages as though its thread was never interrupted.
> Am I misunderstanding how things work?
> Cheers,
> Chris
> [1] https://github.com/apache/incubator-samza/blob/master/samza-kafka/src/main/scala/org/apache/samza/system/kafka/BrokerProxy.scala#L126
> [2] https://github.com/apache/kafka/blob/0.8.1/core/src/main/scala/kafka/consumer/SimpleConsumer.scala#L75



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)