{"record":{"id":"39dc18cc2d8fb801","repo":"apache/hadoop","slug":"replica-does-not-exist","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":894,"sourceCode":"    }\n    return info.getDataInputStream(seekOffset);\n  }\n\n  /**\n   * Get the meta info of a block stored in volumeMap. To find a block,\n   * block pool Id, block Id and generation stamp must match.\n   * @param b extended block\n   * @return the meta replica information\n   * @throws ReplicaNotFoundException if no entry is in the map or \n   *                        there is a generation stamp mismatch\n   */\n  ReplicaInfo getReplicaInfo(ExtendedBlock b)\n      throws ReplicaNotFoundException {\n    ReplicaInfo info = volumeMap.get(b.getBlockPoolId(), b.getLocalBlock());\n    if (info == null) {\n      if (volumeMap.get(b.getBlockPoolId(), b.getLocalBlock().getBlockId())\n          == null) {\n        throw new ReplicaNotFoundException(\n            ReplicaNotFoundException.NON_EXISTENT_REPLICA + b);\n      } else {\n        throw new ReplicaNotFoundException(\n            ReplicaNotFoundException.UNEXPECTED_GS_REPLICA + b);\n      }\n    }\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   */","sourceCodeStart":876,"sourceCodeEnd":912,"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#L876-L912","documentation":"Thrown as ReplicaNotFoundException (NON_EXISTENT_REPLICA prefix) from FsDatasetImpl.getReplicaInfo(ExtendedBlock) when volumeMap.get(bpid, localBlock) returns null and a second lookup by blockId alone also returns null — proving the block ID itself is unknown, not just the generation stamp. This distinguishes a genuinely absent replica from the UNEXPECTED_GS case (error 2406).","triggerScenarios":"Any internal FsDatasetImpl path that resolves a replica before operating: append, recoverBlock, finalizeBlock, moveBlockAcrossStorage, getMetaDataInputStream, etc., invoked for a block ID with no volumeMap entry in that block pool.","commonSituations":"Client retries/append after the replica was deleted; DataNode failed volumes removed replicas from the map; block invalidated (datanode 'deleting block' log lines) while a writer still holds it; wrong-blockpool ExtendedBlock after cluster re-format.","solutions":["Check the DataNode log for 'Deleting block' / invalidation messages around the block ID to confirm intentional removal.","Force a block report from the DataNode (hdfs dfsadmin -triggerBlockReport) so NameNode state matches reality, then retry the client operation.","For appends: recover the lease (hdfs debug recoverLease -path <file>) so the NameNode re-establishes a valid pipeline instead of hammering the stale replica.","If replicas are genuinely missing, run hdfs fsck -blocks and let HDFS re-replicate from healthy replicas."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Guard append/recover-style calls: confirm the replica exists first.\nReplicaInfo info = fsDataset.getReplica(b.getBlockPoolId(), b.getBlockId());\nif (info == null) {\n  // block gone on this DN: get fresh targets from the NameNode\n  return reestablishPipeline(dfsClient, b);\n}","typeGuard":null,"tryCatchPattern":"// ReplicaNotFoundException is the specific signal; recover at the NN level.\ntry {\n  return fsDataset.getReplicaInfo(b);\n} catch (ReplicaNotFoundException e) {\n  // NON_EXISTENT vs UNEXPECTED_GS differ by message prefix in the cause\n  LOG.warn(\"Replica missing on DN, recovering pipeline: {}\", e.getMessage());\n  return recoverViaNameNode(dfsClient, b);\n}","preventionTips":["Call FsDatasetSpi.getReplica(bpid, blkId) before replica-scoped operations and handle null explicitly.","After lease recovery or append failures, re-fetch block info instead of reusing the caller's ExtendedBlock.","Monitor DataNode 'deleting block' logs to correlate removals with downstream ReplicaNotFoundExceptions."],"tags":["hadoop","hdfs","datanode","fsdataset","replica","replica-not-found"],"backgroundTag":"replica-not-found","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}