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

  1. Inspect e.getCause() of the IOException to find the real underlying failure type.
  2. Validate the Parquet file (footer readable, non-zero size, correct magic number) with parquet-tools or by re-reading it directly.
  3. Check encryption configuration — wrong/missing decryption keys produce non-IO failures in the metadata loader.
  4. Upgrade Presto; if the cause is a genuine bug in the metadata reader, it may already be fixed.
  5. 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

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


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/8e5ebac1e9c11753. Report an issue: GitHub.