hadoop-hdfs-issues mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Aaron T. Myers (JIRA)" <j...@apache.org>
Subject [jira] [Commented] (HDFS-4522) LightWeightGSet expects incrementing a volatile to be atomic
Date Mon, 25 Feb 2013 19:44:14 GMT

    [ https://issues.apache.org/jira/browse/HDFS-4522?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=13586199#comment-13586199

Aaron T. Myers commented on HDFS-4522:

Seems to me like we should just use AtomicInteger, as the current patch does.
> LightWeightGSet expects incrementing a volatile to be atomic
> ------------------------------------------------------------
>                 Key: HDFS-4522
>                 URL: https://issues.apache.org/jira/browse/HDFS-4522
>             Project: Hadoop HDFS
>          Issue Type: Bug
>    Affects Versions: 2.0.4-beta
>            Reporter: Colin Patrick McCabe
>            Assignee: Colin Patrick McCabe
>            Priority: Minor
>         Attachments: HDFS-4522.001.patch
> LightWeightGSet uses a volatile integer to track the current modification number (kind
of an epoch number).
> Unfortunately, it includes code like this, that increments this volatile int:
> {code}
>      //insert the element to the head of the linked list
>      modification++;
>      size++;
> {code}
> The bug here is that in between reading the value of modification, incrementing it, and
storing it back in the variable, another thread may have modified it.  This could lead to
lost updates.
> We should use {{AtomicInteger}} for these cases.

This message is automatically generated by JIRA.
If you think it was sent incorrectly, please contact your JIRA administrators
For more information on JIRA, see: http://www.atlassian.com/software/jira

View raw message