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

Piotr Nowojski commented on FLINK-21365:
----------------------------------------

This is some implementation detail of either the CPU caching and/or JVM 
implementation. Based on the provided guarantees in Java, we programmers do not 
have to care about those. It doesn't matter if two threads are updating two 
different variables, or a different position in some array. Both of those cases 
are just two different writes to some memory address, between we (Java 
developers) need to establish happens-before relationship.

The minor difference with the array case is that you need to have happens 
before relationship also to the array variable and array index, instead of just 
to a variable.

And practically speaking on x86, JVM will just insert memory fences 
before/after touching `numCompleted`, that would flush all of the cached 
writes/sync reads that code has done so far.

(*as far as I understand it)

> Visibility issue in FutureUtils.ResultConjunctFuture.handleCompletedFuture 
> ---------------------------------------------------------------------------
>
>                 Key: FLINK-21365
>                 URL: https://issues.apache.org/jira/browse/FLINK-21365
>             Project: Flink
>          Issue Type: Bug
>          Components: Runtime / Coordination
>    Affects Versions: 1.11.3, 1.12.1
>            Reporter: Roman Khachatryan
>            Assignee: Roman Khachatryan
>            Priority: Major
>             Fix For: 1.11.4, 1.12.2, 1.13.0
>
>
> * FutureUtils.ResultConjunctFuture.handleCompletedFuture can update *results* 
> array from multiple threads
> * The array is declared as volatile but this only means the reference is 
> volatile, not the contents
> * There are no other guards



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to