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

ASF GitHub Bot updated FLINK-39875:
-----------------------------------
    Labels: pull-request-available  (was: )

> 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
>              Labels: pull-request-available
>
> *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)

Reply via email to