apache/hadoop · error · EOFException
{b}'s on-disk length {onDiskLength} is shorter than minLengt
Error message
{b}'s on-disk length {onDiskLength} is shorter than minLength {minLength} What it means
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.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs/src/main/java/org/apache/hadoop/hdfs/server/datanode/fsdataset/impl/FsDatasetImpl.java:2267
*/
@Override // FsDatasetSpi
public void checkBlock(ExtendedBlock b, long minLength, ReplicaState state)
throws ReplicaNotFoundException, UnexpectedReplicaStateException,
FileNotFoundException, EOFException, IOException {
final ReplicaInfo replicaInfo = volumeMap.get(b.getBlockPoolId(),
b.getLocalBlock());
if (replicaInfo == null) {
throw new ReplicaNotFoundException(b);
}
if (replicaInfo.getState() != state) {
throw new UnexpectedReplicaStateException(b,state);
}
if (!replicaInfo.blockDataExists()) {
throw new FileNotFoundException(replicaInfo.getBlockURI().toString());
}
long onDiskLength = getLength(b);
if (onDiskLength < minLength) {
throw new EOFException(b + "'s on-disk length " + onDiskLength
+ " is shorter than minLength " + minLength);
}
}
/**
* Check whether the given block is a valid one.
* valid means finalized
*/
@Override // FsDatasetSpi
public boolean isValidBlock(ExtendedBlock b) {
// If block passed is null, we should return false.
if (b == null) {
return false;
}
return isValid(b, ReplicaState.FINALIZED);
}
/**View on GitHub (pinned to 2add963021)
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.
Defensive patterns
Strategy: try-catch
Validate before calling
// Read only up to the length actually on disk when tolerating partial data:
long visible = dataset.getReplicaInfo(b) != null ? dataset.getLength(b) : -1;
if (visible >= 0 && visible < minLength) {
// truncated: choose another replica rather than provoking EOFException
} Try / catch
try {
dataset.checkBlock(b, minLength, ReplicaState.FINALIZED);
} catch (EOFException e) {
// truncated on disk: rotate replica; if last copy, escalate to fsck/block salvage
return nextReplicaOrEscalate(b);
} Prevention
- 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.
When it happens
Trigger: 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.
Common situations: 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.
Related errors
- Failed to create directory {}
- Mkdirs failed to create {}
- Mkdirs failed to create ${dir}
- Failed to move block file for ${this} from ${srcfile} to ${d
- Failed to copy {srcReplica} block file to {dstFile}
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/c763e984f137b52a.
Report an issue: GitHub.