Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-5818

KafkaStreams state transitions not correct

Attach filesAttach ScreenshotVotersWatch issueWatchersCreate sub-taskLinkCloneUpdate Comment AuthorReplace String in CommentUpdate Comment VisibilityDelete Comments
    XMLWordPrintableJSON

Details

    • Bug
    • Status: Resolved
    • Major
    • Resolution: Fixed
    • 0.11.0.1, 1.0.0
    • 0.11.0.1, 1.0.0
    • streams
    • None

    Description

      There is a race condition revealed by failing test KafkaStreamsTest#testCannotStartTwise. It fails with:

      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)
      

      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.

      Attachments

        Issue Links

        Activity

          This comment will be Viewable by All Users Viewable by All Users
          Cancel

          People

            mjsax Matthias J. Sax
            mjsax Matthias J. Sax
            Votes:
            0 Vote for this issue
            Watchers:
            4 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Slack

                Issue deployment