prestodb/presto · error · IOException
Unexpected error in parquet metadata reading after cache mis
Error message
Unexpected error in parquet metadata reading after cache miss
What it means
CachingParquetMetadataSource.getParquetMetadata() delegates to a LoadingCache of file metadata; on a cache miss the loader calls the delegate metadata reader. Any ExecutionException or UncheckedExecutionException escaping the cache is unwrapped: IOException causes are rethrown as-is, while any other cause is wrapped in a new IOException("Unexpected error in parquet metadata reading after cache miss", e.getCause()). This signals an unexpected (non-IO) failure — a bug or corrupt metadata — while loading Parquet footer/metadata through the cache, not a cache-miss itself.
Source
Thrown at presto-parquet/src/main/java/com/facebook/presto/parquet/cache/CachingParquetMetadataSource.java:68
throws IOException
{
try {
if (cacheable) {
ParquetFileMetadata fileMetadataCache = cache.get(
parquetDataSource.getId(),
() -> delegate.getParquetMetadata(parquetDataSource, fileSize, cacheable, modificationTime, fileDecryptor, readMaskedValue));
if (fileMetadataCache.getModificationTime() != modificationTime) {
cache.invalidate(parquetDataSource.getId());
fileMetadataCache = delegate.getParquetMetadata(parquetDataSource, fileSize, cacheable, modificationTime, fileDecryptor, readMaskedValue);
cache.put(parquetDataSource.getId(), fileMetadataCache);
}
return fileMetadataCache;
}
return delegate.getParquetMetadata(parquetDataSource, fileSize, cacheable, modificationTime, fileDecryptor, readMaskedValue);
}
catch (ExecutionException | UncheckedExecutionException e) {
throwIfInstanceOf(e.getCause(), IOException.class);
throw new IOException("Unexpected error in parquet metadata reading after cache miss", e.getCause());
}
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Inspect e.getCause() of the IOException to find the real underlying failure type.
- Validate the Parquet file (footer readable, non-zero size, correct magic number) with parquet-tools or by re-reading it directly.
- Check encryption configuration — wrong/missing decryption keys produce non-IO failures in the metadata loader.
- Upgrade Presto; if the cause is a genuine bug in the metadata reader, it may already be fixed.
- Bypass the cache temporarily (or clear the metadata cache) to rule out cache-state issues and confirm the failure is in file parsing.
Example fix
// before: opaque wrap
// IOException: Unexpected error in parquet metadata reading after cache miss
// after: diagnose root cause
catch (IOException e) {
Throwable cause = e.getCause();
if (cause != null) {
logger.error(cause, "Metadata load failed for %s", dataSource.getId());
}
throw e; // or retry on transient storage errors
} Defensive patterns
Strategy: try-catch
Validate before calling
// Pre-flight the file before asking the cached source for metadata
long size = dataSource.getFileSize();
if (size < 8) {
throw new IOException("File too small to be Parquet: " + dataSource.getId());
} Try / catch
try {
return cachingSource.getParquetMetadata(dataSource, size, cacheable, mtime, decryptor, mask);
} catch (IOException e) {
Throwable cause = e.getCause();
if (cause instanceof RuntimeException) {
logger.error(cause, "Metadata loader bug for %s", dataSource.getId());
}
throw e; // retry upstream on transient storage errors
} Prevention
- Inspect getCause() of the wrapped IOException to identify the real failure.
- Verify encryption key/decryptor configuration before reading encrypted footers.
- Validate file integrity (footer magic, size) before metadata cache loads.
- Keep Presto patched — some metadata-loader crashes are fixed in later releases.
When it happens
Trigger: Calling getParquetMetadata(parquetDataSource, fileSize, cacheable, modificationTime, fileDecryptor, readMaskedValue) when the metadata cache misses and the underlying loader (MetadataReader.readFooter / delegate) throws a non-IOException (RuntimeException, corrupt metadata NPE, decryption error) — the exception surfaces wrapped in this IOException.
Common situations: Corrupt or zero-byte Parquet files causing NPEs in footer parsing; encryption key/decryptor misconfiguration (fileDecryptor fails outside IOException); cache loader bugs after a concurrent eviction; file truncated between size check and footer read.
Related errors
- HUDI_CANNOT_OPEN_SPLIT
- Failed to read %d bytes from file %s : %d bytes read.
- Failed to decode.
- PARQUET_IO_READ_ERROR
- PARQUET_IO_READ_ERROR
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/8e5ebac1e9c11753.
Report an issue: GitHub.