Hadoop HDFS
  1. Hadoop HDFS
  2. HDFS-812

FSNamesystem#internalReleaseLease throws NullPointerException on a single-block file's lease recovery

    Details

    • Type: Bug Bug
    • Status: Closed
    • Priority: Blocker Blocker
    • Resolution: Fixed
    • Affects Version/s: 0.21.0, 0.22.0
    • Fix Version/s: 0.21.0
    • Component/s: namenode
    • Labels:
      None
    • Hadoop Flags:
      Reviewed

      Description

      FSNamesystem.internalReleaseLease() uses the result of iFile#numBlocks(); call to get a number of an under construction file's blocks. numBlock() can return 0 if the file doesn't have any blocks yet. This will cause internalReleaseLease() to throw ArrayIndexOutOfBoundException.

      In case of a single block file, the same method will throw NullPointerException because the penultimate block is going to be null according to the logic of INodeFile#getPenultimateBlock().

      1. HDFS-812.patch
        2 kB
        Konstantin Boudnik
      2. HDFS-812.patch
        2 kB
        Konstantin Boudnik
      3. HDFS-812.patch
        9 kB
        Konstantin Boudnik
      4. HDFS-812.patch
        5 kB
        Konstantin Boudnik
      5. HDFS-812.patch
        5 kB
        Konstantin Boudnik

        Issue Links

          Activity

          Hide
          Hudson added a comment -

          Integrated in Hdfs-Patch-h2.grid.sp2.yahoo.net #94 (See http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-h2.grid.sp2.yahoo.net/94/)

          Show
          Hudson added a comment - Integrated in Hdfs-Patch-h2.grid.sp2.yahoo.net #94 (See http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-h2.grid.sp2.yahoo.net/94/ )
          Hide
          Hudson added a comment -

          Integrated in Hdfs-Patch-h5.grid.sp2.yahoo.net #148 (See http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-h5.grid.sp2.yahoo.net/148/)

          Show
          Hudson added a comment - Integrated in Hdfs-Patch-h5.grid.sp2.yahoo.net #148 (See http://hudson.zones.apache.org/hudson/job/Hdfs-Patch-h5.grid.sp2.yahoo.net/148/ )
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Hdfs-trunk #172 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Hdfs-trunk/172/)
          . FSNamesystem#internalReleaseLease throws NullPointerException on a single-block file's lease recovery. Contributed by Konstantin Boudnik

          Show
          Hudson added a comment - Integrated in Hadoop-Hdfs-trunk #172 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Hdfs-trunk/172/ ) . FSNamesystem#internalReleaseLease throws NullPointerException on a single-block file's lease recovery. Contributed by Konstantin Boudnik
          Hide
          Konstantin Boudnik added a comment -

          I forgot to mention that this JIRA doesn't have results of test-patch because the build has been broken because of HDFS-832.

          Show
          Konstantin Boudnik added a comment - I forgot to mention that this JIRA doesn't have results of test-patch because the build has been broken because of HDFS-832 .
          Hide
          Konstantin Boudnik added a comment -

          I've ran all unit tests and all HDFS tests. All seemed Ok except for 4 testcases in TestHDFSFileContextMainOperations which have failed for unrelated reasons.

          I've just committed this and merged back to branch-0.21.

          Show
          Konstantin Boudnik added a comment - I've ran all unit tests and all HDFS tests. All seemed Ok except for 4 testcases in TestHDFSFileContextMainOperations which have failed for unrelated reasons. I've just committed this and merged back to branch-0.21.
          Hide
          Hudson added a comment -

          Integrated in Hadoop-Hdfs-trunk-Commit #148 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Hdfs-trunk-Commit/148/)

          Show
          Hudson added a comment - Integrated in Hadoop-Hdfs-trunk-Commit #148 (See http://hudson.zones.apache.org/hudson/job/Hadoop-Hdfs-trunk-Commit/148/ )
          Hide
          Hairong Kuang added a comment -

          +1

          Show
          Hairong Kuang added a comment - +1
          Hide
          Konstantin Boudnik added a comment -

          Great catch, Hairong! Thank you. Attached is the patch with fixed test case for 0 blocks and FSNamesystem modification to handle a single-block file.

          Show
          Konstantin Boudnik added a comment - Great catch, Hairong! Thank you. Attached is the patch with fixed test case for 0 blocks and FSNamesystem modification to handle a single-block file.
          Hide
          Hairong Kuang added a comment -

          In case of 0 block, the original code seems to handle correctly. The NPE is thrown in finalizeINodeFileUnderConstruction:
          java.lang.NullPointerException
          at java.util.TreeMap.getEntry(TreeMap.java:324)
          at java.util.TreeMap.get(TreeMap.java:255)
          at org.apache.hadoop.hdfs.server.namenode.LeaseManager.getLease(LeaseManager.java:82)
          at org.apache.hadoop.hdfs.server.namenode.LeaseManager.removeLease(LeaseManager.java:140)
          at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.finalizeINodeFileUnderConstruction(FSNamesystem.java:2037)
          at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.internalReleaseLease(FSNamesystem.java:1939)
          at org.apache.hadoop.hdfs.server.namenode.TestNNLeaseRecovery.testInternalReleaseLease_0blocks(TestNNLeaseRecovery.java:179)
          Is it a test set up problem?

          Show
          Hairong Kuang added a comment - In case of 0 block, the original code seems to handle correctly. The NPE is thrown in finalizeINodeFileUnderConstruction: java.lang.NullPointerException at java.util.TreeMap.getEntry(TreeMap.java:324) at java.util.TreeMap.get(TreeMap.java:255) at org.apache.hadoop.hdfs.server.namenode.LeaseManager.getLease(LeaseManager.java:82) at org.apache.hadoop.hdfs.server.namenode.LeaseManager.removeLease(LeaseManager.java:140) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.finalizeINodeFileUnderConstruction(FSNamesystem.java:2037) at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.internalReleaseLease(FSNamesystem.java:1939) at org.apache.hadoop.hdfs.server.namenode.TestNNLeaseRecovery.testInternalReleaseLease_0blocks(TestNNLeaseRecovery.java:179) Is it a test set up problem?
          Hide
          Konstantin Boudnik added a comment -

          I've ran hdfs tests with this patch in place and it went fine. The only seen problem is that testBlockReplacement is failing. However, this test is failing on the current trunk without the patch being applied.

          Show
          Konstantin Boudnik added a comment - I've ran hdfs tests with this patch in place and it went fine. The only seen problem is that testBlockReplacement is failing. However, this test is failing on the current trunk without the patch being applied.
          Hide
          Konstantin Boudnik added a comment -

          Corrected version of the patch: if penultimate block is missing (e.g. in case of single block file) then its minimal replication factor should be considered as met.

          Show
          Konstantin Boudnik added a comment - Corrected version of the patch: if penultimate block is missing (e.g. in case of single block file) then its minimal replication factor should be considered as met.
          Hide
          Konstantin Boudnik added a comment -

          This patch fixes both issues in the FSNamesystem and provides correct unit tests for the problem.

          Show
          Konstantin Boudnik added a comment - This patch fixes both issues in the FSNamesystem and provides correct unit tests for the problem.
          Hide
          Konstantin Boudnik added a comment -

          I believe, this test version better reflects the expected reaction of FSnamesystem in case of 0 blocks length. Lease needs to be removed and file to be closed.

          Show
          Konstantin Boudnik added a comment - I believe, this test version better reflects the expected reaction of FSnamesystem in case of 0 blocks length. Lease needs to be removed and file to be closed.
          Hide
          Konstantin Boudnik added a comment -

          This patch includes new test which illustrate the problem. NB: the test's contract might have to be changed depending on the resolution of the JIRA itself.

          Show
          Konstantin Boudnik added a comment - This patch includes new test which illustrate the problem. NB: the test's contract might have to be changed depending on the resolution of the JIRA itself.

            People

            • Assignee:
              Konstantin Boudnik
              Reporter:
              Konstantin Boudnik
            • Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved:

                Development