{"record":{"id":"2951856c5dd3d55e","repo":"prestodb/presto","slug":"reset-stream-has-a-block-offset-but-stream-is-not","errorCode":null,"errorMessage":"Reset stream has a block offset but stream is not compressed or encrypted","messagePattern":"Reset stream has a block offset but stream is not compressed or encrypted","errorType":"error_code","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/stream/OrcInputStream.java","lineNumber":213,"sourceCode":"    {\n        // if the decompressed buffer is empty, return a checkpoint starting at the next block\n        if (buffer == null || (position == 0 && available() == 0)) {\n            return createInputStreamCheckpoint(toIntExact(compressedSliceInput.position()), 0);\n        }\n        // otherwise return a checkpoint at the last compressed block read and the current position in the buffer\n        // If we have uncompressed data uncompressedOffset is not included in the offset.\n        return createInputStreamCheckpoint(currentCompressedBlockOffset, toIntExact(position - uncompressedOffset));\n    }\n\n    public boolean seekToCheckpoint(long checkpoint)\n            throws IOException\n    {\n        int compressedBlockOffset = decodeCompressedBlockOffset(checkpoint);\n        int decompressedOffset = decodeDecompressedOffset(checkpoint);\n        boolean discardedBuffer;\n        if (compressedBlockOffset != currentCompressedBlockOffset) {\n            if (!decompressor.isPresent() && !dwrfDecryptor.isPresent()) {\n                throw new OrcCorruptionException(orcDataSourceId, \"Reset stream has a block offset but stream is not compressed or encrypted\");\n            }\n            compressedSliceInput.setPosition(compressedBlockOffset);\n            buffer = new byte[0];\n            memoryUsage.setBytes(getRetainedSizeInBytes());\n            position = 0;\n            length = 0;\n            uncompressedOffset = 0;\n            discardedBuffer = true;\n        }\n        else {\n            discardedBuffer = false;\n        }\n\n        if (decompressedOffset != position - uncompressedOffset) {\n            position = uncompressedOffset;\n            if (available() < decompressedOffset) {\n                decompressedOffset -= available();\n                advance();","sourceCodeStart":195,"sourceCodeEnd":231,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/stream/OrcInputStream.java#L195-L231","documentation":"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.","triggerScenarios":"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.","commonSituations":"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).","solutions":["Ensure checkpoints are only used with the exact stream/file that produced them.","Verify compression (compression kind) of the file matches what the checkpoint assumed.","Clear stale cached checkpoints/split metadata after changing compression settings.","Regenerate checkpoints by re-reading the stream from the start."],"exampleFix":"// before: reusing checkpoint from a compressed file on an uncompressed file\nstream.seekToCheckpoint(cachedCheckpoint);\n// after\nif (streamCompression == UNCOMPRESSED) {\n    stream.seekToCheckpoint(new StreamCheckpoint(0, decompressedOffset));\n} else {\n    stream.seekToCheckpoint(cachedCheckpoint);\n}","handlingStrategy":"validation","validationCode":"boolean compressed = streamCompression != CompressionKind.NONE;\nboolean encrypted = dwrfKeyPresent;\nif (!compressed && !encrypted) checkpoint = new StreamCheckpoint(0, decompressedOffsetOnly);","typeGuard":null,"tryCatchPattern":"try { stream.seekToCheckpoint(cp); } catch (OrcCorruptionException e) {\n    // fall back: re-read stream from start and skip\n    stream.seekToCheckpoint(new StreamCheckpoint(0, 0));\n}","preventionTips":["Never reuse checkpoints across files or compression configs.","Key caches by (fileId, compressionKind).","Invalidate cached checkpoints when compression settings change.","Regenerate checkpoints from the live file footer."],"tags":["orc","checkpoint","corruption","compression"],"backgroundTag":"invalid-stream-checkpoint","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}