{"record":{"id":"98ebe8aded3372c2","repo":"apache/hadoop","slug":"no-data-exists-for-block","errorCode":null,"errorMessage":"No data exists for block {}","messagePattern":"No data exists for block (.+?)","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java","lineNumber":852,"sourceCode":"\n  @Override // FsDatasetSpi\n  public InputStream getBlockInputStream(ExtendedBlock b,\n      long seekOffset) throws IOException {\n\n    ReplicaInfo info;\n    try (AutoCloseableLock lock = lockManager.readLock(LockLevel.DIR,\n        b.getBlockPoolId(), getStorageUuidForLock(b),\n        datasetSubLockStrategy.blockIdToSubLock(b.getBlockId()))) {\n      info = volumeMap.get(b.getBlockPoolId(), b.getLocalBlock());\n    }\n\n    if (info != null && info.getVolume().isTransientStorage()) {\n      ramDiskReplicaTracker.touch(b.getBlockPoolId(), b.getBlockId());\n      datanode.getMetrics().incrRamDiskBlocksReadHits();\n    }\n\n    if (info == null) {\n      throw new IOException(\"No data exists for block \" + b);\n    }\n    return getBlockInputStreamWithCheckingPmemCache(info, b, seekOffset);\n  }\n\n  /**\n   * Check whether the replica is cached to persistent memory.\n   * If so, get DataInputStream of the corresponding cache file on pmem.\n   */\n  private InputStream getBlockInputStreamWithCheckingPmemCache(\n      ReplicaInfo info, ExtendedBlock b, long seekOffset) throws IOException {\n    String cachePath = cacheManager.getReplicaCachePath(\n        b.getBlockPoolId(), b.getBlockId());\n    if (cachePath != null) {\n      long addr = cacheManager.getCacheAddress(\n          b.getBlockPoolId(), b.getBlockId());\n      if (addr != -1) {\n        LOG.debug(\"Get InputStream by cache address.\");\n        return FsDatasetUtil.getDirectInputStream(","sourceCodeStart":834,"sourceCodeEnd":870,"githubUrl":"https://github.com/apache/hadoop/blob/2add9630210752f88ceb1bb74eb65e37bf41da8e/hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java#L834-L870","documentation":"Thrown as IOException from FsDatasetImpl.getBlockInputStream(ExtendedBlock, seekOffset) when the volumeMap lookup under the DIR read lock returns no replica for the block. Distinct from the pmem-cache path above it: the lock is taken, volumeMap.get is done, RAM_DISK touches are accounted for, and only then is a null info fatal. It means this DataNode holds no replica for the given ExtendedBlock at lookup time.","triggerScenarios":"Calling FsDatasetSpi.getBlockInputStream (client read with offset, e.g. transferBlock/serveBlock) for a block whose (bpid, block) is absent from volumeMap — deleted replica, unreported deletion, wrong DN in the pipeline, or a block pool not yet (or no longer) initialized on this DN.","commonSituations":"NameNode directed a reader to a DataNode whose replica was just deleted (balancer/mover or admin invalidation); DN restarted with missing volumes so its map is empty for those blocks; client uses a stale locatedBlocks after failover; block scanner iterating a stale block list.","solutions":["Re-fetch block locations from the NameNode and read from a different replica (getBlockLocations → pick another DN).","On the DataNode, run hdfs dfsadmin -fs <dn-host> ... or check the DN's block pool state; trigger a full block report (hdfs dfsadmin -triggerBlockReport -ip <dn>) so stale mappings converge.","Verify the ExtendedBlock's blockPoolId matches a block pool this DataNode serves.","If persistent, hdfs fsck the file to confirm replication health and let re-replication restore missing replicas."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check volumeMap-backed existence before opening an input stream.\nif (fsDataset.getReplica(b.getBlockPoolId(), b.getBlockId()) == null) {\n  // pick another replica from refreshed locations\n  LocatedBlock lb = dfsClient.getLocatedBlocks(\n      b.getBlockPoolId() + \"/path\", 0, 1).get(0);\n  return openFrom(lb);\n}","typeGuard":null,"tryCatchPattern":"// Generic IOException here means 'this DN has no replica' per the source;\n// fall back to another replica rather than failing the read.\ntry {\n  return fsDataset.getBlockInputStream(b, seekOffset);\n} catch (IOException e) {\n  if (String.valueOf(e.getMessage()).startsWith(\"No data exists for block\")) {\n    return readFromNextBestReplica(dfsClient, b, seekOffset);\n  }\n  throw e;\n}","preventionTips":["Client-side: always retry reads against the next LocatedBlock replica on IOException before surfacing errors.","Operator-side: keep 'DFS Remaining' and volume health monitored so DNs without replicas get dropped from location lists via block reports.","In tests, assert replica existence after write/close before attempting reads."],"tags":["hadoop","hdfs","datanode","fsdataset","read-path","replica","block-not-found"],"backgroundTag":"replica-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}