You are viewing a plain text version of this content. The canonical link for it is here.
Posted to hdfs-dev@hadoop.apache.org by "Colin Patrick McCabe (JIRA)" <ji...@apache.org> on 2013/02/22 20:44:13 UTC
[jira] [Created] (HDFS-4522) LightWeightGSet expects incrementing a
volatile to be atomic
Colin Patrick McCabe created HDFS-4522:
------------------------------------------
Summary: 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
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