prestodb/presto · warning · UncheckedIOException

java.io.IOException (wrapped in UncheckedIOException)

Error message

java.io.IOException (wrapped in UncheckedIOException)

What it means

LongSelectiveStreamReader.close registers its child stream readers' close methods with a Guava Closer; if closing an underlying ORC data stream raises IOException, it is rethrown wrapped in UncheckedIOException. This means resource cleanup of the column's underlying streams failed — usually a low-level I/O problem (closed channel, disk error) rather than a data-format issue.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/reader/LongSelectiveStreamReader.java:126

    {
        return toStringHelper(this)
                .addValue(context.getStreamDescriptor())
                .toString();
    }

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

    @Override
    public long getRetainedSizeInBytes()
    {
        return INSTANCE_SIZE +
                (directReader == null ? 0L : directReader.getRetainedSizeInBytes()) +
                (dictionaryReader == null ? 0L : dictionaryReader.getRetainedSizeInBytes());
    }

    @Override
    public int read(int offset, int[] positions, int positionCount)
            throws IOException
    {
        return currentReader.read(offset, positions, positionCount);
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Log and treat as secondary: this fires during cleanup, so the original query error (if any) is usually more relevant — preserve the first failure with Closer.rethrow semantics.
  2. Ensure the OrcDataSource is not closed before all readers are closed; enforce ordering in your page-source provider.
  3. Make custom stream implementations idempotent on close().
  4. Upgrade Presto if the unwrap reveals a known double-close bug.

Example fix

// before
reader.close();
dataSource.close();
// after — close the source only after all readers
closer.register(reader::close);
closer.register(dataSource::close); // Closer guarantees LIFO ordering
Defensive patterns

Strategy: try-catch

Try / catch

try {
    reader.close();
}
catch (UncheckedIOException e) {
    LOG.warn(e.getCause(), "Failed to close long selective reader; source may already be closed");
}

Prevention

When it happens

Trigger: Calling close() on a LongSelectiveStreamReader while its underlying OrcDataSource/InputStream is already closed or a disk/network I/O error occurs during stream teardown.

Common situations: Double-closing readers after an aborted query (driver already cancelled and closed the source); transient storage failures on HDFS/local disk during cleanup; custom datasource implementations that throw on repeated close.

Related errors


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