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

Steve Loughran commented on HADOOP-12593:
-----------------------------------------

I knew some were tagged, and others not. I think my main concern was whether 
writes to a 64 bit value were atomic at all —but roman corrected me there. 
Which leaves the issue of: are there any operations which cause problems, with 
++, += and the equivalents being it.

I think we should just review them, and for all that we deem safe, add that in 
big comments.

Life would be easier if java had an {{atomic}} type alongside {{volatile}}, 
atomic add/subtract operations are only a couple of cycles on a modern part, 
plus the same impact on OoO scheduling that volatile r/w ops have.

> multiple "volatile long" field declarations exist in the Hadoop codebase
> ------------------------------------------------------------------------
>
>                 Key: HADOOP-12593
>                 URL: https://issues.apache.org/jira/browse/HADOOP-12593
>             Project: Hadoop Common
>          Issue Type: Bug
>    Affects Versions: 2.8.0
>            Reporter: Steve Loughran
>            Priority: Minor
>
> If you get your IDE to scan for "volatile long", you find 20-30 entries. 
> Volatile operations on `long` variables are not guaranteed to be atomic, so 
> these usages can be vulnerable to race conditions generating invalid data.
> they need to be replaced by AtomicLong references, except in the specific 
> case that you want performance values for statistics, and are prepared to 
> take the risk



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

Reply via email to