Hadoop Common
  1. Hadoop Common
  2. HADOOP-9152

HDFS can report negative DFS Used on clusters with very small amounts of data

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Minor Minor
    • Resolution: Fixed
    • Affects Version/s: 2.0.2-alpha
    • Fix Version/s: 2.0.3-alpha, 0.23.6
    • Component/s: fs
    • Labels:
      None

      Description

      I had a near empty HDFS instance where I was creating a file and deleting it very quickly. I noticed that HDFS sometimes reported a negative DFS used.

      root@brock0-1 ~]# sudo -u hdfs -i hdfs dfsadmin -report
      Configured Capacity: 97233235968 (90.56 GB)
      Present Capacity: 84289609707 (78.5 GB)
      DFS Remaining: 84426645504 (78.63 GB)
      DFS Used: -137035797 (-133824.02 KB)
      DFS Used%: -0.16%
      Under replicated blocks: 0
      Blocks with corrupt replicas: 0
      Missing blocks: 0
      
      -------------------------------------------------
      Datanodes available: 1 (1 total, 0 dead)
      
      Live datanodes:
      Name: 127.0.0.1:50010 (localhost)
      Hostname: brock0-1.ent.cloudera.com
      Decommission Status : Normal
      Configured Capacity: 97233235968 (90.56 GB)
      DFS Used: -137035797 (-133824.02 KB)
      Non DFS Used: 12943626261 (12.05 GB)
      DFS Remaining: 84426645504 (78.63 GB)
      DFS Used%: -0.14%
      DFS Remaining%: 86.83%
      Last contact: Thu Nov 22 18:25:37 PST 2012
      
      
      
      
      [root@brock0-1 ~]# sudo -u hdfs -i hdfs dfsadmin -report
      Configured Capacity: 97233235968 (90.56 GB)
      Present Capacity: 84426973184 (78.63 GB)
      DFS Remaining: 84426629120 (78.63 GB)
      DFS Used: 344064 (336 KB)
      DFS Used%: 0%
      Under replicated blocks: 0
      Blocks with corrupt replicas: 0
      Missing blocks: 0
      
      -------------------------------------------------
      Datanodes available: 1 (1 total, 0 dead)
      
      Live datanodes:
      Name: 127.0.0.1:50010 (localhost)
      Hostname: brock0-1.ent.cloudera.com
      Decommission Status : Normal
      Configured Capacity: 97233235968 (90.56 GB)
      DFS Used: 344064 (336 KB)
      Non DFS Used: 12806262784 (11.93 GB)
      DFS Remaining: 84426629120 (78.63 GB)
      DFS Used%: 0%
      DFS Remaining%: 86.83%
      Last contact: Thu Nov 22 18:28:47 PST 2012
      

        Activity

        Brock Noland created issue -
        Hide
        Brock Noland added a comment -

        Looks like there might be a race in FsDatasetAsyncDiskService -> ReplicaFileDeleteTask.run

        Scenario:

        1) blockFile.delete()
        2) DU thread runs setting disk usage number which (deleted block not included)
        3) volume.decDfsUsed(...) decrements the block from the used amount

        Show
        Brock Noland added a comment - Looks like there might be a race in FsDatasetAsyncDiskService -> ReplicaFileDeleteTask.run Scenario: 1) blockFile.delete() 2) DU thread runs setting disk usage number which (deleted block not included) 3) volume.decDfsUsed(...) decrements the block from the used amount
        Hide
        Brock Noland added a comment -

        From a user perspective, I am not expecting a negative number and as such, a simple solution such as Math.max(used, 0) would be acceptable.

        Show
        Brock Noland added a comment - From a user perspective, I am not expecting a negative number and as such, a simple solution such as Math.max(used, 0) would be acceptable.
        Hide
        Brock Noland added a comment -

        The patch attached changes the DU class in common. I think making the change their is appropriate because a drive should never have a negative amount "used". Should I create a HADOOP jira for this? I wasn't able to detect based on (http://wiki.apache.org/hadoop/HowToContribute)

        Details on the change:

        The change to the DU class simply wraps the getUsed() return statement in a Math.max(used, 0L) to ensure that the getUsed method never returns negative.

        Another option would be when getUsed() would return negative to re-run the DU command. I do not feel that change is appropriate because there are still races mean we would have to loop until we obtain a positive value. The scenario where getUsed() can return negative occurs when there is a very small, possibly zero, amount actually used. As such reporting a perfectly correct number is of little value.

        Show
        Brock Noland added a comment - The patch attached changes the DU class in common. I think making the change their is appropriate because a drive should never have a negative amount "used". Should I create a HADOOP jira for this? I wasn't able to detect based on ( http://wiki.apache.org/hadoop/HowToContribute ) Details on the change: The change to the DU class simply wraps the getUsed() return statement in a Math.max(used, 0L) to ensure that the getUsed method never returns negative. Another option would be when getUsed() would return negative to re-run the DU command. I do not feel that change is appropriate because there are still races mean we would have to loop until we obtain a positive value. The scenario where getUsed() can return negative occurs when there is a very small, possibly zero, amount actually used. As such reporting a perfectly correct number is of little value.
        Brock Noland made changes -
        Field Original Value New Value
        Attachment HDFS-4229-0.patch.txt [ 12561135 ]
        Hide
        Brock Noland added a comment -

        Marking patch available.

        Show
        Brock Noland added a comment - Marking patch available.
        Brock Noland made changes -
        Status Open [ 1 ] Patch Available [ 10002 ]
        Assignee Brock Noland [ brocknoland ]
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12561135/HDFS-4229-0.patch.txt
        against trunk revision .

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 1 new or modified test files.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 eclipse:eclipse. The patch built with eclipse:eclipse.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed unit tests in hadoop-common-project/hadoop-common.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: https://builds.apache.org/job/PreCommit-HDFS-Build/3670//testReport/
        Console output: https://builds.apache.org/job/PreCommit-HDFS-Build/3670//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall . Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12561135/HDFS-4229-0.patch.txt against trunk revision . +1 @author . The patch does not contain any @author tags. +1 tests included . The patch appears to include 1 new or modified test files. +1 javac . The applied patch does not increase the total number of javac compiler warnings. +1 javadoc . The javadoc tool did not generate any warning messages. +1 eclipse:eclipse . The patch built with eclipse:eclipse. +1 findbugs . The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit . The applied patch does not increase the total number of release audit warnings. +1 core tests . The patch passed unit tests in hadoop-common-project/hadoop-common. +1 contrib tests . The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-HDFS-Build/3670//testReport/ Console output: https://builds.apache.org/job/PreCommit-HDFS-Build/3670//console This message is automatically generated.
        Aaron T. Myers made changes -
        Project Hadoop HDFS [ 12310942 ] Hadoop Common [ 12310240 ]
        Key HDFS-4229 HADOOP-9152
        Affects Version/s 2.0.2-alpha [ 12322473 ]
        Affects Version/s 2.0.2-alpha [ 12322472 ]
        Component/s fs [ 12310689 ]
        Component/s namenode [ 12312926 ]
        Aaron T. Myers made changes -
        Target Version/s 2.0.3-alpha [ 12323273 ]
        Hide
        Aaron T. Myers added a comment -

        The patch looks pretty good to me, Brock. I agree with you that this issue doesn't warrant as heavyweight a solution as the other one you proposed.

        Can you comment on whether or not running with this patch addressed the actual issue you noticed? i.e. running with a near-empty HDFS instance, creating and deleting a single file very quickly?

        Show
        Aaron T. Myers added a comment - The patch looks pretty good to me, Brock. I agree with you that this issue doesn't warrant as heavyweight a solution as the other one you proposed. Can you comment on whether or not running with this patch addressed the actual issue you noticed? i.e. running with a near-empty HDFS instance, creating and deleting a single file very quickly?
        Hide
        Hadoop QA added a comment -

        +1 overall. Here are the results of testing the latest attachment
        http://issues.apache.org/jira/secure/attachment/12561135/HDFS-4229-0.patch.txt
        against trunk revision .

        +1 @author. The patch does not contain any @author tags.

        +1 tests included. The patch appears to include 1 new or modified test files.

        +1 javac. The applied patch does not increase the total number of javac compiler warnings.

        +1 javadoc. The javadoc tool did not generate any warning messages.

        +1 eclipse:eclipse. The patch built with eclipse:eclipse.

        +1 findbugs. The patch does not introduce any new Findbugs (version 1.3.9) warnings.

        +1 release audit. The applied patch does not increase the total number of release audit warnings.

        +1 core tests. The patch passed unit tests in hadoop-common-project/hadoop-common.

        +1 contrib tests. The patch passed contrib unit tests.

        Test results: https://builds.apache.org/job/PreCommit-HADOOP-Build/1902//testReport/
        Console output: https://builds.apache.org/job/PreCommit-HADOOP-Build/1902//console

        This message is automatically generated.

        Show
        Hadoop QA added a comment - +1 overall . Here are the results of testing the latest attachment http://issues.apache.org/jira/secure/attachment/12561135/HDFS-4229-0.patch.txt against trunk revision . +1 @author . The patch does not contain any @author tags. +1 tests included . The patch appears to include 1 new or modified test files. +1 javac . The applied patch does not increase the total number of javac compiler warnings. +1 javadoc . The javadoc tool did not generate any warning messages. +1 eclipse:eclipse . The patch built with eclipse:eclipse. +1 findbugs . The patch does not introduce any new Findbugs (version 1.3.9) warnings. +1 release audit . The applied patch does not increase the total number of release audit warnings. +1 core tests . The patch passed unit tests in hadoop-common-project/hadoop-common. +1 contrib tests . The patch passed contrib unit tests. Test results: https://builds.apache.org/job/PreCommit-HADOOP-Build/1902//testReport/ Console output: https://builds.apache.org/job/PreCommit-HADOOP-Build/1902//console This message is automatically generated.
        Hide
        Brock Noland added a comment -

        Yes, I was unable to reproduce with the patch applied!

        Show
        Brock Noland added a comment - Yes, I was unable to reproduce with the patch applied!
        Hide
        Aaron T. Myers added a comment -

        Great, thanks for confirming that.

        +1, the patch looks good to me. I'm going to commit this momentarily.

        Show
        Aaron T. Myers added a comment - Great, thanks for confirming that. +1, the patch looks good to me. I'm going to commit this momentarily.
        Hide
        Aaron T. Myers added a comment -

        I've just committed this to trunk and branch-2.

        Thanks a lot for the contribution, Brock.

        Show
        Aaron T. Myers added a comment - I've just committed this to trunk and branch-2. Thanks a lot for the contribution, Brock.
        Aaron T. Myers made changes -
        Status Patch Available [ 10002 ] Resolved [ 5 ]
        Hadoop Flags Reviewed [ 10343 ]
        Fix Version/s 2.0.3-alpha [ 12323273 ]
        Resolution Fixed [ 1 ]
        Hide
        Brock Noland added a comment -

        Thank you!

        Show
        Brock Noland added a comment - Thank you!
        Hide
        Hudson added a comment -

        Integrated in Hadoop-trunk-Commit #3137 (See https://builds.apache.org/job/Hadoop-trunk-Commit/3137/)
        HADOOP-9152. HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602)

        Result = SUCCESS
        atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602
        Files :

        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Show
        Hudson added a comment - Integrated in Hadoop-trunk-Commit #3137 (See https://builds.apache.org/job/Hadoop-trunk-Commit/3137/ ) HADOOP-9152 . HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602) Result = SUCCESS atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602 Files : /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Yarn-trunk #70 (See https://builds.apache.org/job/Hadoop-Yarn-trunk/70/)
        HADOOP-9152. HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602)

        Result = SUCCESS
        atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602
        Files :

        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Show
        Hudson added a comment - Integrated in Hadoop-Yarn-trunk #70 (See https://builds.apache.org/job/Hadoop-Yarn-trunk/70/ ) HADOOP-9152 . HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602) Result = SUCCESS atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602 Files : /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Hdfs-trunk #1259 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk/1259/)
        HADOOP-9152. HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602)

        Result = FAILURE
        atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602
        Files :

        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Show
        Hudson added a comment - Integrated in Hadoop-Hdfs-trunk #1259 (See https://builds.apache.org/job/Hadoop-Hdfs-trunk/1259/ ) HADOOP-9152 . HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602) Result = FAILURE atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602 Files : /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Mapreduce-trunk #1290 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk/1290/)
        HADOOP-9152. HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602)

        Result = SUCCESS
        atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602
        Files :

        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java
        • /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Show
        Hudson added a comment - Integrated in Hadoop-Mapreduce-trunk #1290 (See https://builds.apache.org/job/Hadoop-Mapreduce-trunk/1290/ ) HADOOP-9152 . HDFS can report negative DFS Used on clusters with very small amounts of data. Contributed by Brock Noland. (Revision 1423602) Result = SUCCESS atm : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1423602 Files : /hadoop/common/trunk/hadoop-common-project/hadoop-common/CHANGES.txt /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java /hadoop/common/trunk/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Thomas Graves made changes -
        Fix Version/s 0.23.6 [ 12323504 ]
        Hide
        Hudson added a comment -

        Integrated in Hadoop-Hdfs-0.23-Build #471 (See https://builds.apache.org/job/Hadoop-Hdfs-0.23-Build/471/)
        HADOOP-9152. HDFS can report negative DFS Used on clusters with very small amounts of data (Brock Noland via tgraves) (Revision 1425095)

        Result = UNSTABLE
        tgraves : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1425095
        Files :

        • /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt
        • /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java
        • /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Show
        Hudson added a comment - Integrated in Hadoop-Hdfs-0.23-Build #471 (See https://builds.apache.org/job/Hadoop-Hdfs-0.23-Build/471/ ) HADOOP-9152 . HDFS can report negative DFS Used on clusters with very small amounts of data (Brock Noland via tgraves) (Revision 1425095) Result = UNSTABLE tgraves : http://svn.apache.org/viewcvs.cgi/?root=Apache-SVN&view=rev&rev=1425095 Files : /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/CHANGES.txt /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/main/java/org/apache/hadoop/fs/DU.java /hadoop/common/branches/branch-0.23/hadoop-common-project/hadoop-common/src/test/java/org/apache/hadoop/fs/TestDU.java
        Arun C Murthy made changes -
        Status Resolved [ 5 ] Closed [ 6 ]

          People

          • Assignee:
            Brock Noland
            Reporter:
            Brock Noland
          • Votes:
            0 Vote for this issue
            Watchers:
            6 Start watching this issue

            Dates

            • Created:
              Updated:
              Resolved:

              Development