{"record":{"id":"c763e984f137b52a","repo":"apache/hadoop","slug":"b-s-on-disk-length-ondisklength-is-shorter-tha","errorCode":null,"errorMessage":"{b}'s on-disk length {onDiskLength} is shorter than minLength {minLength}","messagePattern":"(.+?)'s on-disk length (.+?) is shorter than minLength (.+?)","errorType":"exception","errorClass":"EOFException","httpStatus":null,"severity":"error","filePath":"hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java","lineNumber":2267,"sourceCode":"   */\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    }\n    return isValid(b, ReplicaState.FINALIZED);\n  }\n  \n  /**","sourceCodeStart":2249,"sourceCodeEnd":2285,"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#L2249-L2285","documentation":"EOFException thrown by FsDatasetImpl.checkBlock when the block file exists but getLength(b) (actual on-disk bytes) is smaller than the minLength the caller requires. The replica is present yet truncated relative to the length the operation expects, so reading it would hit end-of-file prematurely.","triggerScenarios":"checkBlock(b, minLength, state) where minLength exceeds onDiskLength - e.g., a client requests a length up to the block's reported visible length but the file on disk is shorter after an unclean shutdown mid-write.","commonSituations":"DataNode crash between data write and meta/fsync leaving a short file; disk full condition truncated a write; VM snapshot rollback restoring an older, shorter block file; short read caused by faulty RAID controller.","solutions":["Run hdfs fsck -blocks to locate truncated replicas; the NameNode will re-replicate from healthy copies.","Investigate why the file is short: check for 'No space left on device' or I/O errors in DataNode logs around the write time.","If this replica is the only copy, consider block-recovery tooling (hdfs debug recoverLease, or manual salvage) before deleting it.","Free disk space / fix hardware and restart the DataNode to re-scan volumes."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Read only up to the length actually on disk when tolerating partial data:\nlong visible = dataset.getReplicaInfo(b) != null ? dataset.getLength(b) : -1;\nif (visible >= 0 && visible < minLength) {\n  // truncated: choose another replica rather than provoking EOFException\n}","typeGuard":null,"tryCatchPattern":"try {\n  dataset.checkBlock(b, minLength, ReplicaState.FINALIZED);\n} catch (EOFException e) {\n  // truncated on disk: rotate replica; if last copy, escalate to fsck/block salvage\n  return nextReplicaOrEscalate(b);\n}","preventionTips":["Monitor DataNode disks for full/dying conditions that truncate writes.","Use crash-consistent storage (journaling fs, battery/flash-backed write cache).","Avoid restoring data directories from non-atomic snapshots."],"tags":["hdfs","datanode","block-check","truncated-block","eof","disk-full"],"backgroundTag":"block-file-truncated","analyzedSha":"2add9630210752f88ceb1bb74eb65e37bf41da8e","analyzedAt":"2026-08-22T19:55:07.957Z","schemaVersion":2},"datasetVersion":"2026-08-22T20:17:22.307Z"}