prestodb/presto · error · OrcCorruptionException

Reset stream has a block offset but stream is not compressed

Error message

Reset stream has a block offset but stream is not compressed or encrypted

What it means

seekToCheckpoint decodes a checkpoint into a compressed-block offset and decompressed offset. A nonzero compressed block offset is only valid when the stream is compressed or encrypted; otherwise the checkpoint cannot be applied and this OrcCorruptionException is thrown.

Source

Thrown at presto-orc/src/main/java/com/facebook/presto/orc/stream/OrcInputStream.java:213

    {
        // if the decompressed buffer is empty, return a checkpoint starting at the next block
        if (buffer == null || (position == 0 && available() == 0)) {
            return createInputStreamCheckpoint(toIntExact(compressedSliceInput.position()), 0);
        }
        // otherwise return a checkpoint at the last compressed block read and the current position in the buffer
        // If we have uncompressed data uncompressedOffset is not included in the offset.
        return createInputStreamCheckpoint(currentCompressedBlockOffset, toIntExact(position - uncompressedOffset));
    }

    public boolean seekToCheckpoint(long checkpoint)
            throws IOException
    {
        int compressedBlockOffset = decodeCompressedBlockOffset(checkpoint);
        int decompressedOffset = decodeDecompressedOffset(checkpoint);
        boolean discardedBuffer;
        if (compressedBlockOffset != currentCompressedBlockOffset) {
            if (!decompressor.isPresent() && !dwrfDecryptor.isPresent()) {
                throw new OrcCorruptionException(orcDataSourceId, "Reset stream has a block offset but stream is not compressed or encrypted");
            }
            compressedSliceInput.setPosition(compressedBlockOffset);
            buffer = new byte[0];
            memoryUsage.setBytes(getRetainedSizeInBytes());
            position = 0;
            length = 0;
            uncompressedOffset = 0;
            discardedBuffer = true;
        }
        else {
            discardedBuffer = false;
        }

        if (decompressedOffset != position - uncompressedOffset) {
            position = uncompressedOffset;
            if (available() < decompressedOffset) {
                decompressedOffset -= available();
                advance();

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Ensure checkpoints are only used with the exact stream/file that produced them.
  2. Verify compression (compression kind) of the file matches what the checkpoint assumed.
  3. Clear stale cached checkpoints/split metadata after changing compression settings.
  4. Regenerate checkpoints by re-reading the stream from the start.

Example fix

// before: reusing checkpoint from a compressed file on an uncompressed file
stream.seekToCheckpoint(cachedCheckpoint);
// after
if (streamCompression == UNCOMPRESSED) {
    stream.seekToCheckpoint(new StreamCheckpoint(0, decompressedOffset));
} else {
    stream.seekToCheckpoint(cachedCheckpoint);
}
Defensive patterns

Strategy: validation

Validate before calling

boolean compressed = streamCompression != CompressionKind.NONE;
boolean encrypted = dwrfKeyPresent;
if (!compressed && !encrypted) checkpoint = new StreamCheckpoint(0, decompressedOffsetOnly);

Try / catch

try { stream.seekToCheckpoint(cp); } catch (OrcCorruptionException e) {
    // fall back: re-read stream from start and skip
    stream.seekToCheckpoint(new StreamCheckpoint(0, 0));
}

Prevention

When it happens

Trigger: seekToCheckpoint called with a checkpoint whose compressedBlockOffset != currentCompressedBlockOffset while neither decompressor nor DWRF decryptor is present — i.e., a checkpoint produced for a different stream configuration.

Common situations: Mixing checkpoints across files/streams with different compression settings; stale cached checkpoints after compression config change; passing an uncompressed stream's checkpoint to a compressed-format code path (or vice versa).

Related errors


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