[jira] [Commented] (KAFKA-15205) Race condition in ShutdownableThread causes InterruptedException

2024-06-19 Thread Josep Prat (Jira)


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

Josep Prat commented on KAFKA-15205:


Changing target fix version to 3.9 since this is not a blocker and we are past 
code freeze

> Race condition in ShutdownableThread causes InterruptedException
> 
>
> Key: KAFKA-15205
> URL: https://issues.apache.org/jira/browse/KAFKA-15205
> Project: Kafka
>  Issue Type: Bug
>  Components: core
>Affects Versions: 3.3.2, 3.4.1, 3.6.0, 3.5.1
>Reporter: Divij Vaidya
>Priority: Major
> Fix For: 3.8.0
>
>
> In Shutdownable thread, during close, we call:
> initiateShutdown() -> which may interrupt the thread if 
> isInterruptible is set to true during construction.
> After that, we wait for proper shutdown using 
> awaitShutdown() which in-turn calls CountdownLatch#await(). On interruption, 
> which could be caused by initiateShutdown() earlier, await() throws an 
> InterruptedExeception. Hence, awaitShutdown() is going to exit by throwing an 
> interrupted exception.
> The sequence to reproduce this will be as follows:
> App-thread: Name of application thread which spawns and closes Shutdownable 
> thread
> Shut-thread: Name of the shutdownable thread.
> 1. App-thread calls ShutThread.initiateShutdown()
> 2. ShutThread.interrupt() is called. It informs the VM to interrupt but the 
> actual interrupt will be async. initiateShutdown() from step 1 returns.
> 3. App-thread calls ShutThread.awaitShutdown() 
> 4. App-thread waits on shutdownComplete.await() i.e. on CountdownLatch#await
> 5. VM decides to interrupt App-thread and there is a race condition now.
> Race condition:
> Condition 1: Shut-thread.doWork() gets interrupted exception, and decrements 
> the CountdownLatch
> Condition 2: App-thread waiting on Shut-thread.shutdownComplete.await() 
> throws an interruptedException as per the contract 
> [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#await--]
> *Solution*
>  
> In ShutDownableThread#awaitShutdown(), when calling await() we should catch 
> InterruptedException and eat it up (do nothing), if the thread has 
> isInterruptable set to true.



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


[jira] [Commented] (KAFKA-15205) Race condition in ShutdownableThread causes InterruptedException

2023-12-26 Thread Stanislav Kozlovski (Jira)


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

Stanislav Kozlovski commented on KAFKA-15205:
-

Changing target fix version to 3.8 since this is not a blocker and we are 
cutting a 3.7 RC

 

> Race condition in ShutdownableThread causes InterruptedException
> 
>
> Key: KAFKA-15205
> URL: https://issues.apache.org/jira/browse/KAFKA-15205
> Project: Kafka
>  Issue Type: Bug
>  Components: core
>Affects Versions: 3.3.2, 3.4.1, 3.6.0, 3.5.1
>Reporter: Divij Vaidya
>Priority: Major
> Fix For: 3.8.0
>
>
> In Shutdownable thread, during close, we call:
> initiateShutdown() -> which may interrupt the thread if 
> isInterruptible is set to true during construction.
> After that, we wait for proper shutdown using 
> awaitShutdown() which in-turn calls CountdownLatch#await(). On interruption, 
> which could be caused by initiateShutdown() earlier, await() throws an 
> InterruptedExeception. Hence, awaitShutdown() is going to exit by throwing an 
> interrupted exception.
> The sequence to reproduce this will be as follows:
> App-thread: Name of application thread which spawns and closes Shutdownable 
> thread
> Shut-thread: Name of the shutdownable thread.
> 1. App-thread calls ShutThread.initiateShutdown()
> 2. ShutThread.interrupt() is called. It informs the VM to interrupt but the 
> actual interrupt will be async. initiateShutdown() from step 1 returns.
> 3. App-thread calls ShutThread.awaitShutdown() 
> 4. App-thread waits on shutdownComplete.await() i.e. on CountdownLatch#await
> 5. VM decides to interrupt App-thread and there is a race condition now.
> Race condition:
> Condition 1: Shut-thread.doWork() gets interrupted exception, and decrements 
> the CountdownLatch
> Condition 2: App-thread waiting on Shut-thread.shutdownComplete.await() 
> throws an interruptedException as per the contract 
> [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#await--]
> *Solution*
>  
> In ShutDownableThread#awaitShutdown(), when calling await() we should catch 
> InterruptedException and eat it up (do nothing), if the thread has 
> isInterruptable set to true.



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


[jira] [Commented] (KAFKA-15205) Race condition in ShutdownableThread causes InterruptedException

2023-09-02 Thread Satish Duggana (Jira)


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

Satish Duggana commented on KAFKA-15205:


Moving it to 3.7.0 as we are near code freeze and it is not a blocker.

> Race condition in ShutdownableThread causes InterruptedException
> 
>
> Key: KAFKA-15205
> URL: https://issues.apache.org/jira/browse/KAFKA-15205
> Project: Kafka
>  Issue Type: Bug
>  Components: core
>Affects Versions: 3.3.2, 3.4.1, 3.6.0, 3.5.1
>Reporter: Divij Vaidya
>Priority: Major
> Fix For: 3.7.0
>
>
> In Shutdownable thread, during close, we call:
> initiateShutdown() -> which may interrupt the thread if 
> isInterruptible is set to true during construction.
> After that, we wait for proper shutdown using 
> awaitShutdown() which in-turn calls CountdownLatch#await(). On interruption, 
> which could be caused by initiateShutdown() earlier, await() throws an 
> InterruptedExeception. Hence, awaitShutdown() is going to exit by throwing an 
> interrupted exception.
> The sequence to reproduce this will be as follows:
> App-thread: Name of application thread which spawns and closes Shutdownable 
> thread
> Shut-thread: Name of the shutdownable thread.
> 1. App-thread calls ShutThread.initiateShutdown()
> 2. ShutThread.interrupt() is called. It informs the VM to interrupt but the 
> actual interrupt will be async. initiateShutdown() from step 1 returns.
> 3. App-thread calls ShutThread.awaitShutdown() 
> 4. App-thread waits on shutdownComplete.await() i.e. on CountdownLatch#await
> 5. VM decides to interrupt App-thread and there is a race condition now.
> Race condition:
> Condition 1: Shut-thread.doWork() gets interrupted exception, and decrements 
> the CountdownLatch
> Condition 2: App-thread waiting on Shut-thread.shutdownComplete.await() 
> throws an interruptedException as per the contract 
> [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#await--]
> *Solution*
>  
> In ShutDownableThread#awaitShutdown(), when calling await() we should catch 
> InterruptedException and eat it up (do nothing), if the thread has 
> isInterruptable set to true.



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


[jira] [Commented] (KAFKA-15205) Race condition in ShutdownableThread causes InterruptedException

2023-07-18 Thread Ismael Juma (Jira)


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

Ismael Juma commented on KAFKA-15205:
-

Have you seen this behavior in practice? We should definitely fix our error 
handling if it's not compliant, but it's not clear to me if this is more of a 
theoretical issue.

> Race condition in ShutdownableThread causes InterruptedException
> 
>
> Key: KAFKA-15205
> URL: https://issues.apache.org/jira/browse/KAFKA-15205
> Project: Kafka
>  Issue Type: Bug
>  Components: core
>Affects Versions: 3.3.2, 3.4.1, 3.6.0, 3.5.1
>Reporter: Divij Vaidya
>Priority: Major
> Fix For: 3.6.0
>
>
> In Shutdownable thread, during close, we call:
> initiateShutdown() -> which may interrupt the thread if 
> isInterruptible is set to true during construction.
> After that, we wait for proper shutdown using 
> awaitShutdown() which in-turn calls CountdownLatch#await(). On interruption, 
> which could be caused by initiateShutdown() earlier, await() throws an 
> InterruptedExeception. Hence, awaitShutdown() is going to exit by throwing an 
> interrupted exception.
> The sequence to reproduce this will be as follows:
> App-thread: Name of application thread which spawns and closes Shutdownable 
> thread
> Shut-thread: Name of the shutdownable thread.
> 1. App-thread calls ShutThread.initiateShutdown()
> 2. ShutThread.interrupt() is called. It informs the VM to interrupt but the 
> actual interrupt will be async. initiateShutdown() from step 1 returns.
> 3. App-thread calls ShutThread.awaitShutdown() 
> 4. App-thread waits on shutdownComplete.await() i.e. on CountdownLatch#await
> 5. VM decides to interrupt App-thread and there is a race condition now.
> Race condition:
> Condition 1: Shut-thread.doWork() gets interrupted exception, and decrements 
> the CountdownLatch
> Condition 2: App-thread waiting on Shut-thread.shutdownComplete.await() 
> throws an interruptedException as per the contract 
> [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#await--]
> *Solution*
>  
> In ShutDownableThread#awaitShutdown(), when calling await() we should catch 
> InterruptedException and eat it up (do nothing), if the thread has 
> isInterruptable set to true.



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


[jira] [Commented] (KAFKA-15205) Race condition in ShutdownableThread causes InterruptedException

2023-07-18 Thread Divij Vaidya (Jira)


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

Divij Vaidya commented on KAFKA-15205:
--

[~ijuma]  this looks like a nasty bug since we use this thread wrapper at 
multiple places in the code base. Thoughts?

> Race condition in ShutdownableThread causes InterruptedException
> 
>
> Key: KAFKA-15205
> URL: https://issues.apache.org/jira/browse/KAFKA-15205
> Project: Kafka
>  Issue Type: Bug
>  Components: core
>Affects Versions: 3.3.2, 3.4.1, 3.6.0, 3.5.1
>Reporter: Divij Vaidya
>Priority: Major
> Fix For: 3.6.0
>
>
> In Shutdownable thread, during close, we call:
> initiateShutdown() -> which may interrupt the thread if 
> isInterruptible is set to true during construction.
> After that, we wait for proper shutdown using 
> awaitShutdown() which in-turn calls CountdownLatch#await(). On interruption, 
> which could be caused by initiateShutdown() earlier, await() throws an 
> InterruptedExeception. Hence, awaitShutdown() is going to exit by throwing an 
> interrupted exception.
> The sequence to reproduce this will be as follows:
> App-thread: Name of application thread which spawns and closes Shutdownable 
> thread
> Shut-thread: Name of the shutdownable thread.
> 1. App-thread calls ShutThread.initiateShutdown()
> 2. ShutThread.interrupt() is called. It informs the VM to interrupt but the 
> actual interrupt will be async. initiateShutdown() from step 1 returns.
> 3. App-thread calls ShutThread.awaitShutdown() 
> 4. App-thread waits on shutdownComplete.await() i.e. on CountdownLatch#await
> 5. VM decides to interrupt App-thread and there is a race condition now.
> Race condition:
> Condition 1: Shut-thread.doWork() gets interrupted exception, and decrements 
> the CountdownLatch
> Condition 2: App-thread waiting on Shut-thread.shutdownComplete.await() 
> throws an interruptedException as per the contract 
> [https://docs.oracle.com/javase/8/docs/api/java/util/concurrent/CountDownLatch.html#await--]
> *Solution*
>  
> In ShutDownableThread#awaitShutdown(), when calling await() we should catch 
> InterruptedException and eat it up (do nothing), if the thread has 
> isInterruptable set to true.



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