You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@flink.apache.org by "Jubin Soni (Jira)" <ji...@apache.org> on 2026/06/05 22:18:00 UTC

[jira] [Commented] (FLINK-39875) Restore thread interrupt status in ResultStore.processRecord() after catching InterruptedException

    [ https://issues.apache.org/jira/browse/FLINK-39875?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=18086498#comment-18086498 ] 

Jubin Soni commented on FLINK-39875:
------------------------------------

I'm working on this

> Restore thread interrupt status in ResultStore.processRecord() after catching InterruptedException
> --------------------------------------------------------------------------------------------------
>
>                 Key: FLINK-39875
>                 URL: https://issues.apache.org/jira/browse/FLINK-39875
>             Project: Flink
>          Issue Type: Bug
>          Components: Table SQL / Gateway
>    Affects Versions: 2.4.0
>            Reporter: Jubin Soni
>            Priority: Minor
>
> *Summary*
> The {{processRecord()}} method in {{ResultStore}} catches {{InterruptedException}} without restoring the thread's interrupt status. This violates Java concurrency best practices and may prevent the result retrieval thread from responding correctly to shutdown or cancellation requests.
> *Description*
> In {{{}ResultStore.processRecord(){}}}, the thread waits when the result buffer reaches its maximum size:
>  
> {{try \{
>     resultLock.wait();
> } catch (InterruptedException e) \{
>     // ignore
> }}}
> When {{wait()}} throws {{{}InterruptedException{}}}, the thread's interrupt status is cleared. Since the exception is currently ignored, the interrupt signal is effectively lost.
> *Impact*
>  * The {{ResultRetrievalThread}} may not respond promptly to interruption requests.
>  * The {{close()}} method interrupts the retrieval thread during shutdown, but the interrupt can be swallowed while waiting on {{{}resultLock{}}}.
>  * Higher-level cancellation and shutdown mechanisms may not behave as expected.
>  * Ignoring interrupts can lead to delayed shutdowns and make thread lifecycle management less reliable.
> *Proposed Fix*
> Restore the interrupt status when handling {{{}InterruptedException{}}}:
>  
> {{try \{
>     resultLock.wait();
> } catch (InterruptedException e) \{
>     Thread.currentThread().interrupt();
>     return;
> }}}
> Alternatively, propagate the interruption to the caller if the surrounding design allows it.
> Acceptance Criteria
>  * Interrupt status is preserved when {{InterruptedException}} is caught in {{{}processRecord(){}}}.
>  * {{ResultRetrievalThread}} responds correctly to shutdown and cancellation requests.
>  * Thread interruption behavior follows Java concurrency best practices.



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