{"record":{"id":"93c8d4b5eef18ba9","repo":"prestodb/presto","slug":"failed-to-read-or-decrypt-filestatistics-for-node","errorCode":null,"errorMessage":"Failed to read or decrypt FileStatistics for node %s","messagePattern":"Failed to read or decrypt FileStatistics for node (.+?)","errorType":"exception","errorClass":"OrcCorruptionException","httpStatus":null,"severity":"error","filePath":"presto-orc/src/main/java/com/facebook/presto/orc/metadata/DwrfMetadataReader.java","lineNumber":254,"sourceCode":"                        orcDataSource.getId(),\n                        // Memory is not accounted as the buffer is expected to be tiny and will be immediately discarded\n                        new SharedBuffer(NOOP_ORC_LOCAL_MEMORY_CONTEXT),\n                        new BasicSliceInput(encryptedFileStats),\n                        decompressor,\n                        Optional.of(decryptor),\n                        NOOP_ORC_AGGREGATED_MEMORY_CONTEXT,\n                        encryptedFileStats.length())) {\n                    CodedInputStream input = CodedInputStream.newInstance(inputStream);\n                    DwrfProto.FileStatistics nodeStats = DwrfProto.FileStatistics.parseFrom(input);\n\n                    // FileStatistics contains ColumnStatistics for the node and all its child nodes (subtree)\n                    for (int statsIdx = 0; statsIdx < nodeStats.getStatisticsCount(); statsIdx++) {\n                        decryptedFileStats[nodeId + statsIdx] =\n                                toColumnStatistics(hiveWriterVersion, nodeStats.getStatistics(statsIdx), false, null);\n                    }\n                }\n                catch (IOException e) {\n                    throw new OrcCorruptionException(e, orcDataSource.getId(), \"Failed to read or decrypt FileStatistics for node %s\", nodeId);\n                }\n            }\n        }\n\n        return ImmutableList.copyOf(decryptedFileStats);\n    }\n\n    private static DwrfEncryption toEncryption(DwrfProto.Encryption encryption)\n    {\n        KeyProvider keyProvider = toKeyProvider(encryption.getKeyProvider());\n        List<EncryptionGroup> encryptionGroups = toEncryptionGroups(encryption.getEncryptionGroupsList());\n        return new DwrfEncryption(keyProvider, encryptionGroups);\n    }\n\n    private static List<EncryptionGroup> toEncryptionGroups(List<DwrfProto.EncryptionGroup> encryptionGroups)\n    {\n        ImmutableList.Builder<EncryptionGroup> encryptionGroupBuilder = ImmutableList.builderWithExpectedSize(encryptionGroups.size());\n        for (DwrfProto.EncryptionGroup dwrfEncryptionGroup : encryptionGroups) {","sourceCodeStart":236,"sourceCodeEnd":272,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-orc/src/main/java/com/facebook/presto/orc/metadata/DwrfMetadataReader.java#L236-L272","documentation":"DwrfMetadataReader.decryptAndCombineFileStatistics reads and optionally decrypts per-node FileStatistics from the metadata. If reading or decrypting those protobuf statistics raises IOException, it is wrapped into OrcCorruptionException because the file statistics section is unreadable (corrupt bytes or decryption failure).","triggerScenarios":"readFooter calls decryptAndCombineFileStatistics on a DWRF file whose metadata section fails protobuf parse or decryption (wrong encryption keys/kek material), producing IOException.","commonSituations":"DWRF encryption configured with different/rotated keys on read side, corrupted metadata blocks, files copied across clusters without key material, or truncated metadata.","solutions":["Verify the encryption keys/key material available to the reader match those used by the writer (update kek metadata / key provider config).","Validate the file metadata section with DWRF tooling to distinguish corruption from decryption failure.","Restore the file from a known-good copy if the metadata block is corrupt.","Ensure the writer that produced the file completed successfully and the full metadata was flushed."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// ensure decryption keys are configured before reading\ncheckState(encryptionKeyMaterialPresent(), \"DWRF decryption keys unavailable for %s\", dataSourceId);","typeGuard":null,"tryCatchPattern":"try { footer = metadataReader.readFooter(...); }\ncatch (OrcCorruptionException e) {\n    if (e.getMessage().contains(\"FileStatistics\")) { reloadKeysAndRetryOnce(); }\n    else throw e;\n}","preventionTips":["Provision writer-matching encryption keys on reader nodes","Rotate keys only after all dependent files are rewritten","Verify post-write metadata readability in pipelines"],"tags":["orc","dwrf","encryption","file-statistics"],"backgroundTag":"orc-decryption-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"}