apache/hadoop · error · CorruptMetaHeaderException
EOF while reading header from meta. The meta file may be tru
Error message
EOF while reading header from meta. The meta file may be truncated or corrupt
What it means
The stream-based BlockMetadataHeader.readHeader(DataInputStream) caught an EOFException while reading the version short (or checksum fields): the meta file holds fewer bytes than the minimal header. The EOFException is wrapped in CorruptMetaHeaderException so callers treat the replica metadata as unusable rather than a plain stream error.
Source
Thrown at hadoop-hdfs-project/hadoop-hdfs-client/src/main/java/org/apache/hadoop/hdfs/server/datanode/BlockMetadataHeader.java:151
throw new CorruptMetaHeaderException("The block meta file header is "+
"corrupt", e);
}
return new BlockMetadataHeader(version, dataChecksum);
}
/**
* This reads all the fields till the beginning of checksum.
* @return Metadata Header
* @throws IOException
*/
public static BlockMetadataHeader readHeader(DataInputStream in)
throws IOException {
try {
return readHeader(in.readShort(), in);
} catch (EOFException eof) {
// The attempt to read the header threw EOF, indicating there are not
// enough bytes in the meta file for the header.
throw new CorruptMetaHeaderException("EOF while reading header from meta"+
". The meta file may be truncated or corrupt", eof);
}
}
/**
* Reads header at the top of metadata file and returns the header.
* Closes the input stream after reading the header.
*
* @return metadata header for the block
* @throws IOException
*/
public static BlockMetadataHeader readHeader(
FileInputStream fis) throws IOException {
try (DataInputStream in = new DataInputStream(
new BufferedInputStream(fis))) {
return readHeader(in);
}
}View on GitHub (pinned to 2add963021)
Solutions
- Check the file size of the reported .meta - anything below the header size (version short + checksum header) is unrecoverable
- Delete the block/meta pair and let the NameNode re-replicate
- Fix the crash/disk-full condition that produced the truncated file
Defensive patterns
Strategy: validation
Validate before calling
if (fileLength(metaFile) < BlockMetadataHeader.getHeaderSize()) {
// too short even for version+checksum header: skip readHeader, quarantine
quarantine(metaFile);
} Try / catch
catch (CorruptMetaHeaderException e) { /* truncated meta: delete pair, re-replicate */ } Prevention
- Check file length before parsing meta headers in custom tooling
- Avoid leaving partial .meta files: shut down DataNodes cleanly before maintenance
When it happens
Trigger: readHeader(DataInputStream) is called on a 0- or 1-byte .meta file - e.g. by DataNode verification paths or tools that scan replica metadata after a crash or disk-full event.
Common situations: Empty .meta files left after kill -9, disk-full writes, or truncated files copied across volumes.
Related errors
- {b}'s on-disk length {onDiskLength} is shorter than minLengt
- EOF while reading header from the metadata file. The meta fi
- The block meta file header is corrupt
- Premature EOF from inputStream
- Premature EOF from inputStream after skipping {len-amt} byte
AI-assisted analysis of apache/hadoop@2add963021 (2026-08-22).
Data as JSON: /api/errors/788afae348357949.
Report an issue: GitHub.