prestodb/presto · error · OrcCorruptionException
Invalid footer length %s
Error message
Invalid footer length %s
What it means
After decoding the PostScript, the library extracts footerLength and metadataLength. A negative footer length is structurally impossible in a valid ORC file, so OrcCorruptionException is thrown. This means the postscript bytes decoded to an implausible value — the file tail is corrupt or the writer was incompatible.
Source
Thrown at presto-orc/src/main/java/com/facebook/presto/orc/cache/StorageOrcFileTailSource.java:114
}
// verify this is a supported version
checkOrcVersion(orcDataSource, postScript.getVersion());
validateWrite(writeValidation, orcDataSource, validation -> validation.getVersion().equals(postScript.getVersion()), "Unexpected version");
int bufferSize = toIntExact(postScript.getCompressionBlockSize());
// check compression codec is supported
CompressionKind compressionKind = postScript.getCompression();
validateWrite(writeValidation, orcDataSource, validation -> validation.getCompression() == compressionKind, "Unexpected compression");
PostScript.HiveWriterVersion hiveWriterVersion = postScript.getHiveWriterVersion();
int footerSize = toIntExact(postScript.getFooterLength());
int metadataSize = toIntExact(postScript.getMetadataLength());
if (footerSize < 0) {
throw new OrcCorruptionException(orcDataSource.getId(), "Invalid footer length %s", footerSize);
}
if (metadataSize < 0) {
throw new OrcCorruptionException(orcDataSource.getId(), "Invalid metadata length %s", metadataSize);
}
// read DWRF stripe cache only if this feature is enabled and it has meaningful data
boolean readDwrfStripeCache = dwrfStripeCacheEnabled
&& postScript.getDwrfStripeCacheLength().isPresent()
&& postScript.getDwrfStripeCacheMode().isPresent()
&& postScript.getDwrfStripeCacheMode().get() != DwrfStripeCacheMode.NONE;
int dwrfStripeCacheSize = 0;
if (readDwrfStripeCache) {
dwrfStripeCacheSize = postScript.getDwrfStripeCacheLength().getAsInt();
checkSizes(orcDataSource, metadataSize, dwrfStripeCacheSize);
}
// check if extra bytes need to be read
Slice completeFooterSlice;View on GitHub (pinned to 55bb57d202)
Solutions
- Validate the file with orc-tools (java -jar orc-tools-*-uber.jar meta file.orc) to pinpoint the corruption.
- Re-generate or re-copy the file; postscript/footer corruption is not repairable in place.
- Check storage layer (disk/HDFS) for silent corruption; enable checksum verification.
- Compare the writer version/implementation that produced the file against supported versions.
Defensive patterns
Strategy: try-catch
Try / catch
try { tail = source.getOrcFileTail(ds, reader, validation, false, time); }
catch (OrcCorruptionException e) { failQueryWithFileLocation(ds.getId(), e); } Prevention
- Enable storage checksums to detect silent corruption
- Keep writer and reader ORC versions compatible
- Regularly validate archival files with orc-tools
When it happens
Trigger: getOrcFileTail decodes a PostScript whose getFooterLength() is negative (value parsed from corrupt tail bytes).
Common situations: Bit-flip corruption on storage, truncated-then-partially-overwritten files, files written by non-Hive ORC variants with unsupported postscript fields.
Related errors
- File has no columns
- Invalid file size %s
- Invalid postscript length %s
- Invalid metadata length %s
- Invalid ORC metadata %s or DWRF stripe cache size %s
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/d59aff670dd6b30a.
Report an issue: GitHub.