prestodb/presto · error · OrcCorruptionException

Reading RLE byte got EOF

Error message

Reading RLE byte got EOF

What it means

Thrown by ByteInputStream.readNextBlock after a valid RLE run-control byte was read but the repeated value byte itself hit EOF (-1). The RLE header promised a run of control+MIN_REPEAT_SIZE bytes, yet the single value byte is missing, so the stream is malformed or truncated mid-run.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/stream/ByteInputStream.java:61

            throws IOException
    {
        lastReadInputCheckpoint = input.getCheckpoint();

        int control = input.read();
        if (control == -1) {
            throw new OrcCorruptionException(input.getOrcDataSourceId(), "Read past end of buffer RLE byte");
        }

        offset = 0;

        // if byte high bit is not set, this is a repetition; otherwise it is a literal sequence
        if ((control & 0x80) == 0) {
            length = control + MIN_REPEAT_SIZE;

            // read the repeated value
            int value = input.read();
            if (value == -1) {
                throw new OrcCorruptionException(input.getOrcDataSourceId(), "Reading RLE byte got EOF");
            }

            // fill buffer with the value
            Arrays.fill(buffer, 0, length, (byte) value);
        }
        else {
            // length is 2's complement of byte
            length = 0x100 - control;

            // read the literals into the buffer
            input.readFully(buffer, 0, length);
        }
    }

    @Override
    public Class<ByteStreamCheckpoint> getCheckpointType()
    {
        return ByteStreamCheckpoint.class;

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Confirm truncation with orc-tools meta/orc-dump and compare the declared stream length with the actual byte length.
  2. Re-copy the file from a good source and verify checksums before querying again.
  3. Re-write the file from source data with the current Presto/Hive writer.
  4. Enable storage checksums (HDFS CRC, S3 ETag) so corruption is surfaced where it occurred.
  5. Avoid querying tables while a transactional writer (insert into the same table) is still running.
Defensive patterns

Strategy: try-catch

Try / catch

try {
    stream.next(values, count);
} catch (OrcCorruptionException e) {
    if (e.getMessage().contains("Reading RLE byte got EOF")) {
        log.error("ORC file truncated mid-RLE-run: {}", path, e);
        alerts.fire(Severity.HIGH, path);
    }
    throw e;
}

Prevention

When it happens

Trigger: ByteInputStream.next/skip triggers readNextBlock; control byte reads fine (high bit clear, i.e. repeat mode), but the immediately following input.read() returns -1 because the stream ends between the control byte and the value byte.

Common situations: Truncated ORC files (cut exactly inside an RLE run); interrupted file copies; corrupted network blocks stored without checksums; reading a snapshot of an in-progress ORC write.

Related errors


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