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

LightWeightGSet expects incrementing a volatile to be atomic

    XMLWordPrintableJSON

Details

    • Bug
    • Status: Closed
    • Minor
    • Resolution: Fixed
    • 2.1.0-beta
    • 2.1.0-beta
    • None
    • None
    • 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

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

              Dates

                Created:
                Updated:
                Resolved: