{"record":{"id":"433f2164d10b2a7b","repo":"apache/hadoop","slug":"blockuri","errorCode":null,"errorMessage":"{blockURI}","messagePattern":"\\{blockURI\\}","errorType":"exception","errorClass":"FileNotFoundException","httpStatus":null,"severity":"critical","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java","lineNumber":2263,"sourceCode":"   *                                              was an error locating it.\n   * @throws EOFException                      If the replica length is too short.\n   * \n   * @throws IOException                       May be thrown from the methods called. \n   */\n  @Override // FsDatasetSpi\n  public void checkBlock(ExtendedBlock b, long minLength, ReplicaState state)\n      throws ReplicaNotFoundException, UnexpectedReplicaStateException,\n      FileNotFoundException, EOFException, IOException {\n    final ReplicaInfo replicaInfo = volumeMap.get(b.getBlockPoolId(), \n        b.getLocalBlock());\n    if (replicaInfo == null) {\n      throw new ReplicaNotFoundException(b);\n    }\n    if (replicaInfo.getState() != state) {\n      throw new UnexpectedReplicaStateException(b,state);\n    }\n    if (!replicaInfo.blockDataExists()) {\n      throw new FileNotFoundException(replicaInfo.getBlockURI().toString());\n    }\n    long onDiskLength = getLength(b);\n    if (onDiskLength < minLength) {\n      throw new EOFException(b + \"'s on-disk length \" + onDiskLength\n          + \" is shorter than minLength \" + minLength);\n    }\n  }\n\n  /**\n   * Check whether the given block is a valid one.\n   * valid means finalized\n   */\n  @Override // FsDatasetSpi\n  public boolean isValidBlock(ExtendedBlock b) {\n    // If block passed is null, we should return false.\n    if (b == null) {\n      return false;\n    }","sourceCodeStart":2245,"sourceCodeEnd":2281,"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#L2245-L2281","documentation":"FileNotFoundException thrown by FsDatasetImpl.checkBlock when the volumeMap contains the replica but its data file no longer exists on the filesystem (blockDataExists() is false; the thrown message is the block's URI). This is the classic signature of on-disk data loss or external interference with data directories: HDFS bookkeeping and the filesystem disagree.","triggerScenarios":"checkBlock(b, minLength, state) on a replica whose block file was deleted outside HDFS or lost - the volumeMap entry survives but replicaInfo.blockDataExists() returns false.","commonSituations":"Disk failure or corrupted filesystem; an operator/Nagios/backup job deleting files under dfs.datanode.data.dir; container ephemeral storage wiped on restart; partial restore from snapshot; fs corruption after power loss.","solutions":["Run hdfs fsck on affected paths to enumerate lost replicas and trigger re-replication.","Audit what deleted the files (outside processes must never touch data.dir; mount it read-only for non-HDFS users).","Check dmesg/smartctl for hardware errors; replace the failing disk and reformat the volume via DataNode re-registration.","Verify data directories are on persistent storage in containerized deployments (no emptyDir for data)."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":"boolean isMissingBlockFile(IOException e) {\n  return e instanceof java.io.FileNotFoundException\n      && e.getMessage() != null && e.getMessage().startsWith(\"file:\"); // block URI\n}","tryCatchPattern":"try {\n  dataset.checkBlock(b, minLength, ReplicaState.FINALIZED);\n} catch (FileNotFoundException e) {\n  // on-disk loss: fall back to another replica AND raise a disk-integrity alert\n  diskIntegrityAlert(b, e);\n  return nextReplica(b);\n}","preventionTips":["Never allow external processes to write/delete inside dfs.datanode.data.dir.","Mount data directories so only the DataNode user can modify them.","Run hdfs fsck periodically to catch under-replicated/corrupt blocks early.","In containers/K8s, back dfs.datanode.data.dir with persistent volumes."],"tags":["hdfs","datanode","block-check","file-not-found","data-loss","disk-failure"],"backgroundTag":"missing-block-file","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}