{"record":{"id":"88119705d2f46de7","repo":"apache/hadoop","slug":"replica-does-not-exist-881197","errorCode":null,"errorMessage":"Replica does not exist {}:{}","messagePattern":"Replica does not exist (.+?):(.+?)","errorType":"exception","errorClass":"ReplicaNotFoundException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java","lineNumber":918,"sourceCode":"    }\n    return info;\n  }\n\n  /**\n   * Get the meta info of a block stored in volumeMap. Block is looked up\n   * without matching the generation stamp.\n   * @param bpid block pool Id\n   * @param blkid block Id\n   * @return the meta replica information; null if block was not found\n   * @throws ReplicaNotFoundException if no entry is in the map or \n   *                        there is a generation stamp mismatch\n   */\n  @VisibleForTesting\n  ReplicaInfo getReplicaInfo(String bpid, long blkid)\n      throws ReplicaNotFoundException {\n    ReplicaInfo info = volumeMap.get(bpid, blkid);\n    if (info == null) {\n      throw new ReplicaNotFoundException(\n          ReplicaNotFoundException.NON_EXISTENT_REPLICA + bpid + \":\" + blkid);\n    }\n    return info;\n  }\n\n  String getStorageUuidForLock(ExtendedBlock b)\n      throws ReplicaNotFoundException {\n    return getReplicaInfo(b.getBlockPoolId(), b.getBlockId())\n        .getStorageUuid();\n  }\n\n  /**\n   * Returns handles to the block file and its metadata file\n   */\n  @Override // FsDatasetSpi\n  public ReplicaInputStreams getTmpInputStreams(ExtendedBlock b,\n      long blkOffset, long metaOffset) throws IOException {\n    try (AutoCloseDataSetLock l = lockManager.readLock(LockLevel.DIR,","sourceCodeStart":900,"sourceCodeEnd":936,"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#L900-L936","documentation":"Thrown as ReplicaNotFoundException (NON_EXISTENT_REPLICA prefix) from FsDatasetImpl.getReplicaInfo(String bpid, long blkid), the variant that looks up by block ID without matching generation stamp. If even this coarse lookup misses, the block ID simply has no replica in that block pool. It is also the resolver behind getStorageUuidForLock, so lock acquisition on an unknown block fails here first.","triggerScenarios":"Calling getReplicaInfo(bpid, blkid) (or APIs that lock by block, e.g. getStorageUuidForLock(ExtendedBlock)) for a block ID absent from volumeMap: invalidated replica, deleted block pool data, post-volume-failure map, or fabricated ID.","commonSituations":"Directory scanner/block report reconciling stale lists; recoverBlock for a block already deleted on this DN; tests probing unknown IDs; DN serving a block pool whose dirs were wiped but not re-formatted.","solutions":["Confirm the block exists on any replica: hdfs fsck <file> -files -blocks -locations for the owning file.","Trigger a block report so NameNode drops this DN from that block's locations (hdfs dfsadmin -triggerBlockReport).","If the DN's dirs were wiped/restored, re-register the block pool (restart DN) instead of trusting stale in-memory maps.","In code, prefer checking replica existence (fsDataset.getReplica(bpid, blkId)) before entering lock-by-block paths."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check by (bpid, blkId) before lock-by-block paths like\n// getStorageUuidForLock.\nif (fsDataset.getReplica(bpid, blkid) == null) {\n  return Optional.empty(); // caller skips instead of throwing\n}","typeGuard":null,"tryCatchPattern":"try {\n  String storageUuid = fsDataset.getStorageUuidForLock(b);\n} catch (ReplicaNotFoundException e) {\n  // coarse lookup already missed: block unknown in this bp, skip gracefully\n  LOG.debug(\"No replica {}/{}; skipping lock\", b.getBlockPoolId(), b.getBlockId());\n  return;\n}","preventionTips":["Filter block lists against current volumeMap state (via getReplica) before iterating lock-acquiring dataset calls.","In directory-scanner/balancer style loops, treat ReplicaNotFoundException as 'skip this block', not an abort.","Keep block reports frequent in dynamic clusters so stale IDs age out quickly."],"tags":["hadoop","hdfs","datanode","fsdataset","replica","replica-not-found","locking"],"backgroundTag":"replica-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-23T01:17:44.959Z"}