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

DefaultStateUpdater::handleRuntimeException should update isRunning before calling `addToExceptionsAndFailedTasksThenClearUpdatingAndPausedTasks`

    XMLWordPrintableJSON

Details

    • Test
    • Status: Resolved
    • Minor
    • Resolution: Fixed
    • 3.9.0
    • 4.1.0
    • streams, unit tests
    • None

    Description

      I saw a flaky test in DefaultStateUpdaterTest::shouldThrowIfAddingStandbyAndActiveTaskWithSameId recently.

      org.opentest4j.AssertionFailedError: expected: <false> but was: <true>
      	at org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:151)
      	at org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
      	at org.junit.jupiter.api.AssertFalse.failNotFalse(AssertFalse.java:63)
      	at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:36)
      	at org.junit.jupiter.api.AssertFalse.assertFalse(AssertFalse.java:31)
      	at org.junit.jupiter.api.Assertions.assertFalse(Assertions.java:231)
      	at org.apache.kafka.streams.processor.internals.DefaultStateUpdaterTest.shouldThrowIfAddingTasksWithSameId(DefaultStateUpdaterTest.java:294)
      	at org.apache.kafka.streams.processor.internals.DefaultStateUpdaterTest.shouldThrowIfAddingStandbyAndActiveTaskWithSameId(DefaultStateUpdaterTest.java:285)
      	at java.base/java.lang.reflect.Method.invoke(Method.java:580)
      	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
      	at java.base/java.util.ArrayList.forEach(ArrayList.java:1596)
      

      To make the bug more reproducible, you may add `Thread.sleep(5)` after `addToExceptionsAndFailedTasksThenClearUpdatingAndPausedTasks(runtimeException);` in DefaultStateUpdater::handleRuntimeException

      The test is flaky because `addToExceptionsAndFailedTasksThenClearUpdatingAndPausedTasks(runtimeException);` will unblock the `verifyFailedTasks(IllegalStateException.class, task1);` statement in DefaultStateUpdaterTest::shouldThrowIfAddingTasksWithSameId.

      If `assertFalse(stateUpdater.isRunning());` is executed before `isRunning.set(false);` the test will fail

      Attachments

        Activity

          People

            Unassigned Unassigned
            aoli-al Ao Li
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved: