prestodb/presto · warning · UncheckedIOException

java.io.IOException (wrapped in UncheckedIOException)

Error message

java.io.IOException (wrapped in UncheckedIOException)

What it means

SliceBatchStreamReader.close() delegates closing of its direct and dictionary sub-readers. If one of those throws an IOException while releasing resources, it is rethrown wrapped in an UncheckedIOException so the close() signature (no checked exceptions) is preserved.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/SliceBatchStreamReader.java:162

        if (isCharType) {
            // truncate the characters and then remove the trailing white spaces
            return byteCountWithoutTrailingSpace(slice, offset, length, maxCodePointCount);
        }
        if (maxCodePointCount >= 0 && length > maxCodePointCount) {
            return byteCount(slice, offset, length, maxCodePointCount);
        }
        return length;
    }

    @Override
    public void close()
    {
        try (Closer closer = Closer.create()) {
            closer.register(directReader::close);
            closer.register(dictionaryReader::close);
        }
        catch (IOException e) {
            throw new UncheckedIOException(e);
        }
    }

    @Override
    public long getRetainedSizeInBytes()
    {
        return INSTANCE_SIZE + directReader.getRetainedSizeInBytes() + dictionaryReader.getRetainedSizeInBytes();
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the wrapped IOException cause to identify the failing underlying stream or data source.
  2. Ensure the OrcDataSource is not closed before the reader's close() is called (close in reverse order of creation).
  3. Avoid calling close() twice; use try-with-resources so cleanup happens exactly once.
  4. If the I/O error is transient (network filesystem), the data itself is usually already read; treat as cleanup noise and log rather than fail the query.

Example fix

// before
reader.close(); // may throw UncheckedIOException
// after
try (SliceBatchStreamReader reader = createReader()) {
    // read blocks
} // deterministic single close via try-with-resources
Defensive patterns

Strategy: try-catch

Try / catch

try {
    reader.close();
} catch (UncheckedIOException e) {
    log.warn("Reader close failed; underlying cause: %s", e.getCause());
    // cleanup errors are usually non-fatal after data was read
}

Prevention

When it happens

Trigger: Calling close() on a SliceBatchStreamReader whose underlying directReader or dictionaryReader streams fail during close, e.g. because the ORC data source is already closed or an I/O error occurs on the underlying channel.

Common situations: Double-close of an OrcDataSource; closing readers after a query was cancelled and resources were already released; filesystem/network errors (HDFS disconnection, S3 timeouts) surfacing during cleanup.

Related errors


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