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

Add Precondition check to LocatedBlock#addCachedLoc

    Details

    • Target Version/s:

      Description

      We may see the following exception:

      java.lang.ArrayStoreException
      at java.util.ArrayList.toArray(ArrayList.java:389)
      at org.apache.hadoop.hdfs.protocol.LocatedBlock.addCachedLoc(LocatedBlock.java:205)
      at org.apache.hadoop.hdfs.server.namenode.CacheManager.setCachedLocations(CacheManager.java:907)
      at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocationsUpdateTimes(FSNamesystem.java:1974)
      at org.apache.hadoop.hdfs.server.namenode.FSNamesystem.getBlockLocationsInt(FSNamesystem.java:1873)
      

      The cause is that in LocatedBlock.java, when addCachedLoc:

      • Passed in parameter loc, which is type DatanodeDescriptor, is added to cachedList
      • cachedList was assigned to EMPTY_LOCS, which is type DatanodeInfoWithStorage.

      Both DatanodeDescriptor and DatanodeInfoWithStorage are subclasses of DatanodeInfo but do not inherit from each other, resulting in the ArrayStoreException.

        Attachments

        1. HDFS-9250.001.patch
          3 kB
          Xiao Chen
        2. HDFS-9250.002.patch
          3 kB
          Xiao Chen

          Activity

            People

            • Assignee:
              xiaochen Xiao Chen
              Reporter:
              xiaochen Xiao Chen
            • Votes:
              0 Vote for this issue
              Watchers:
              5 Start watching this issue

              Dates

              • Created:
                Updated:
                Resolved: