kafka-jira mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Ted Yu (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (KAFKA-5818) KafkaStreams state transitions not correct
Date Thu, 31 Aug 2017 23:38:00 GMT

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

Ted Yu commented on KAFKA-5818:
-------------------------------

Looking at StreamThread, in the call chain run() -> runLoop() -> runOnce() , there is
statement accessing state (line 753) without synchronized keyword on any of the method:
{code}
        if (state == State.PARTITIONS_ASSIGNED) {
{code}
Is this intentional ?

> KafkaStreams state transitions not correct
> ------------------------------------------
>
>                 Key: KAFKA-5818
>                 URL: https://issues.apache.org/jira/browse/KAFKA-5818
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>    Affects Versions: 0.11.0.1, 1.0.0
>            Reporter: Matthias J. Sax
>            Assignee: Matthias J. Sax
>             Fix For: 0.11.0.1, 1.0.0
>
>
> There is a race condition revealed by failing test {{KafkaStreamsTest#testCannotStartTwise}}.
It fails with:
> {noformat}
> java.lang.Exception: Unexpected exception, expected<java.lang.IllegalStateException>
but was<java.lang.IllegalThreadStateException>
> Caused by: java.lang.IllegalThreadStateException
> 	at java.lang.Thread.start(Thread.java:705)
> 	at org.apache.kafka.streams.KafkaStreams.start(KafkaStreams.java:590)
> 	at org.apache.kafka.streams.KafkaStreamsTest.testCannotStartTwice(KafkaStreamsTest.java:251)
> {noformat}
> The race condition is a follows:
> 1) test calls {{KafkaStreams#start()}} for the first time and state transits from CREATED
-> RUNNING
> 2) First poll triggers a rebalance and {{StreamThread}} put {{KafkaStreams}} into state
REBALANCING
> 3) before REBALANCING completes, the main test thread calls {{KafkaStream#start()}} again.
As current state is REBALANCING, the transition to RUNNING is valid and {{start()}} does not
fail with {{IllegalStateException}} but resumes. When it tries to start internal streams,
we get {{IllegalThreadStateException}} as thread are already running.



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

Mime
View raw message