{"record":{"id":"b35008fd9ac88c51","repo":"prestodb/presto","slug":"write-side-compression-verification-failed-chunk","errorCode":null,"errorMessage":"Write-side compression verification failed: chunk does not decode back to the original bytes (uncompressedSize=%s compressedSize=%s decompressedSize=%s)","messagePattern":"Write-side compression verification failed: chunk does not decode back to the original bytes \\(uncompressedSize=(.+?) compressedSize=(.+?) decompressedSize=(.+?)\\)","errorType":"exception","errorClass":"OrcCompressionVerificationException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/OrcOutputBuffer.java","lineNumber":639,"sourceCode":"        byte[] decompressed = decompressionBufferPool.checkOut(length);\n        try {\n            int decompressedLength;\n            try {\n                decompressedLength = verifyDecompressor.decompress(compressed, 0, compressedLength, decompressed, 0, length);\n            }\n            catch (RuntimeException e) {\n                // Any decode failure (ZstdException, MalformedInputException, ...) means the\n                // freshly compressed chunk is not decodable. Chain the cause so the original\n                // decoder stack trace is preserved.\n                throw new OrcCompressionVerificationException(\n                        e,\n                        \"Write-side compression verification failed: %s (uncompressedSize=%s compressedSize=%s)\",\n                        e.getMessage(),\n                        length,\n                        compressedLength);\n            }\n            if (decompressedLength != length || !Arrays.equals(decompressed, 0, length, original, offset, offset + length)) {\n                throw new OrcCompressionVerificationException(\n                        \"Write-side compression verification failed: chunk does not decode back to the original bytes (uncompressedSize=%s compressedSize=%s decompressedSize=%s)\",\n                        length,\n                        compressedLength,\n                        decompressedLength);\n            }\n        }\n        finally {\n            decompressionBufferPool.checkIn(decompressed);\n        }\n    }\n\n    @VisibleForTesting\n    int getBufferCapacity()\n    {\n        return slice.length();\n    }\n}\n","sourceCodeStart":621,"sourceCodeEnd":657,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/OrcOutputBuffer.java#L621-L657","documentation":"After decompressing a freshly written chunk, verifyCompressedChunk compares the decompressed length and content against the original bytes. If they differ, the chunk does not round-trip and OrcCompressionVerificationException is thrown to prevent writing corrupt data.","triggerScenarios":"writeChunkToOutputStream verifies a chunk and decompressedLength != original length, or Arrays.equals fails between the decompressed bytes and the original input region.","commonSituations":"Buggy or misconfigured compressor/decompressor pairs, native library bugs, byte-range comparison bugs, or concurrent modification of buffers during compression.","solutions":["Check the reported sizes to determine whether it is a length or content mismatch","Test with a different compression kind to isolate the buggy codec","Update the codec library (e.g. aircompressor, zstd-jni) to the latest version","Disable write-side compression verification if the codec is trusted and verification is too strict"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try { orcWriter.write(page); }\ncatch (OrcCompressionVerificationException e) {\n    if (e.getMessage().contains(\"does not decode back\")) {\n        /* switch codec or rewrite with verification disabled after root-cause */\n    }\n}","preventionTips":["Regression-test compress/decompress round-trips per codec version","Pin codec library versions","Enable verification in CI to catch codec bugs early"],"tags":["orc","compression","write-path","round-trip","data-corruption"],"backgroundTag":"compression-verification-failed","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"}