Ao Li created KAFKA-17371:
-----------------------------

             Summary: Flaky test in 
DefaultTaskExecutorTest.shouldUnassignTaskWhenRequired
                 Key: KAFKA-17371
                 URL: https://issues.apache.org/jira/browse/KAFKA-17371
             Project: Kafka
          Issue Type: Bug
            Reporter: Ao Li


Please see this fork https://github.com/aoli-al/kafka/tree/KAFKA-251 for a 
deterministic reproduction.  

The test failed with 

{code}
expected: not <null>
org.opentest4j.AssertionFailedError: expected: not <null>
        at 
org.junit.jupiter.api.AssertionFailureBuilder.build(AssertionFailureBuilder.java:152)
        at 
org.junit.jupiter.api.AssertionFailureBuilder.buildAndThrow(AssertionFailureBuilder.java:132)
        at org.junit.jupiter.api.AssertNotNull.failNull(AssertNotNull.java:49)
        at 
org.junit.jupiter.api.AssertNotNull.assertNotNull(AssertNotNull.java:35)
        at 
org.junit.jupiter.api.AssertNotNull.assertNotNull(AssertNotNull.java:30)
        at org.junit.jupiter.api.Assertions.assertNotNull(Assertions.java:304)
        at 
org.apache.kafka.streams.processor.internals.tasks.DefaultTaskExecutorTest.shouldUnassignTaskWhenRequired(DefaultTaskExecutorTest.java:233)
        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)
{code}

The root cause of the failure is that `currentTask = 
taskManager.assignNextTask(DefaultTaskExecutor.this);` is not an atomic 
operation. This means that calling `taskManager.assignNextTask` will unblock 
the `verify(taskManager, 
timeout(VERIFICATION_TIMEOUT)).assignNextTask(taskExecutor);` statement in the 
test method. 

If `assertNotNull(taskExecutor.currentTask());` is executed before the 
assignment `currentTaks = [...]` the test will fail. 



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to