{"record":{"id":"65a74e984c73f2af","repo":"prestodb/presto","slug":"failed-to-close-row-encoders","errorCode":null,"errorMessage":"Failed to close row encoders","messagePattern":"Failed to close row encoders","errorType":"exception","errorClass":"UncheckedIOException","httpStatus":null,"severity":"error","filePath":"presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaPageSink.java","lineNumber":121,"sourceCode":"                    messageEncoder.appendColumnValue(page.getBlock(channel), position);\n                }\n            }\n            producer.send(new ProducerRecord<>(topicName, keyEncoder.toByteArray(), messageEncoder.toByteArray()), errorCounter);\n        }\n        return NOT_BLOCKED;\n    }\n\n    @Override\n    public CompletableFuture<Collection<Slice>> finish()\n    {\n        producer.flush();\n        producer.close();\n        try {\n            keyEncoder.close();\n            messageEncoder.close();\n        }\n        catch (IOException e) {\n            throw new UncheckedIOException(\"Failed to close row encoders\", e);\n        }\n\n        if (errorCounter.getErrorCount() > 0) {\n            throw new PrestoException(KAFKA_PRODUCER_ERROR, format(\"%d producer record('s) failed to send\", errorCounter.getErrorCount()));\n        }\n        return completedFuture(ImmutableList.of());\n    }\n\n    @Override\n    public void abort()\n    {\n        producer.close();\n    }\n}\n","sourceCodeStart":103,"sourceCodeEnd":136,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaPageSink.java#L103-L136","documentation":"In KafkaPageSink.finish(), after flushing and closing the Kafka producer, the key and message encoders are closed; an IOException during encoder close is rethrown as this UncheckedIOException. It signals that releasing the row-encoder resources failed while finishing a write, wrapping the checked IOException for use in the CompletableFuture-based sink API.","triggerScenarios":"Thrown at presto-kafka/src/main/java/com/facebook/presto/kafka/KafkaPageSink.java:121 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Inspect the wrapped IOException via getCause() for the encoder close failure","Ensure encoder output streams are healthy and not already closed before finish()","Catch UncheckedIOException where the sink's completion future is consumed"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"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"}