[ 
https://issues.apache.org/jira/browse/KAFKA-17113?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Ao Li updated KAFKA-17113:
--------------------------
    Description: 
The `shouldThrowStreamsExceptionOnStartupIfExceptionOccurred` test expects `
globalStreamThread.start` throws `startupException` when startup fails. This 
may not be true in some slow machines. 

 
```
class GlobalStreamThread {
  Exception startupException;
  void initialize() {
    try {
      ...
    } catch (Exception e) {
      startupException = e;
    }
    ...
    setState(State.DEAD);
  }
  void start() {
    super.start();
    while (stillInitializing()) {
      Utils.sleep(1);
      if (startupException != null) {
        throw startupexception;
      }
    }
    if (inErrorState()) {
      throw new IllegalStateException("Initialization for the global stream 
thread failed");
    }
  }
}
```

Consider the following schedule:

```
main:start:`startupException != null`
GlobalStreamThread:initialize:`startupException = e;`
GlobalStreamThread:initialize:`setState(State.DEAD);`
main:start:`inErrorState()`
main:start:`throw new IllegalStateException`
```
 
The function throws `IllegalStateException("Initialization for the global 
stream thread failed")` instead of `startupexception`

  was:
The `shouldThrowStreamsExceptionOnStartupIfExceptionOccurred` test expects `
globalStreamThread.start` throws `startupException` when startup fails. This 
may not be true in some slow machines. 

 
```
class GlobalStreamThread {
  Exception startupException;
  void initialize() {
    try {
      ...
    } catch (Exception e) {
      startupException = e;
    }
    ...
    setState(State.DEAD);
  }

 

  void start() {
    super.start();
    while (stillInitializing()) {
      Utils.sleep(1);
      if (startupException != null) {
        throw startupexception;
      }
    }

    if (inErrorState()) {
      throw new IllegalStateException("Initialization for the global stream 
thread failed");
    }
  }
}
```

Consider the following interleaving: 
 
```
main:start:19
GlobalStreamThread:initialize:7
GlobalStreamThread:initialize:10
main:start:24
main:start:25
```
 
The function throws `IllegalStateException("Initialization for the global 
stream thread failed")` instead of `startupexception`


> Flaky Test in 
> GlobalStreamThreadTest#shouldThrowStreamsExceptionOnStartupIfExceptionOccurred
> --------------------------------------------------------------------------------------------
>
>                 Key: KAFKA-17113
>                 URL: https://issues.apache.org/jira/browse/KAFKA-17113
>             Project: Kafka
>          Issue Type: Bug
>          Components: streams
>            Reporter: Ao Li
>            Priority: Minor
>
> The `shouldThrowStreamsExceptionOnStartupIfExceptionOccurred` test expects `
> globalStreamThread.start` throws `startupException` when startup fails. This 
> may not be true in some slow machines. 
>  
> ```
> class GlobalStreamThread {
>   Exception startupException;
>   void initialize() {
>     try {
>       ...
>     } catch (Exception e) {
>       startupException = e;
>     }
>     ...
>     setState(State.DEAD);
>   }
>   void start() {
>     super.start();
>     while (stillInitializing()) {
>       Utils.sleep(1);
>       if (startupException != null) {
>         throw startupexception;
>       }
>     }
>     if (inErrorState()) {
>       throw new IllegalStateException("Initialization for the global stream 
> thread failed");
>     }
>   }
> }
> ```
> Consider the following schedule:
> ```
> main:start:`startupException != null`
> GlobalStreamThread:initialize:`startupException = e;`
> GlobalStreamThread:initialize:`setState(State.DEAD);`
> main:start:`inErrorState()`
> main:start:`throw new IllegalStateException`
> ```
>  
> The function throws `IllegalStateException("Initialization for the global 
> stream thread failed")` instead of `startupexception`



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

Reply via email to