Uploaded image for project: 'Hadoop HDFS'
  1. Hadoop HDFS
  2. HDFS-4522

LightWeightGSet expects incrementing a volatile to be atomic

    XMLWordPrintableJSON

    Details

    • Type: Bug
    • Status: Closed
    • Priority: Minor
    • Resolution: Fixed
    • Affects Version/s: 2.1.0-beta
    • Fix Version/s: 2.1.0-beta
    • Component/s: None
    • Labels:
      None
    • Target Version/s:
    • Hadoop Flags:
      Reviewed

      Description

      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:

           //insert the element to the head of the linked list
           modification++;
           size++;
      

      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.

        Attachments

        1. HDFS-4522.002.patch
          0.7 kB
          Colin McCabe
        2. HDFS-4522.001.patch
          3 kB
          Colin McCabe

          Issue Links

            Activity

              People

              • Assignee:
                cmccabe Colin McCabe
                Reporter:
                cmccabe Colin McCabe
              • Votes:
                0 Vote for this issue
                Watchers:
                7 Start watching this issue

                Dates

                • Created:
                  Updated:
                  Resolved: