{"record":{"id":"feb9dde384503170","repo":"prestodb/presto","slug":"hive-writer-close-error-feb9dd","errorCode":"HIVE_WRITER_CLOSE_ERROR","errorMessage":"Error committing write to Hive","messagePattern":"Error committing write to Hive","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/SortingFileWriter.java","lineNumber":144,"sourceCode":"    @Override\n    public Optional<Page> commit()\n    {\n        if (!sortBuffer.isEmpty()) {\n            // skip temporary files entirely if the total output size is small\n            if (tempFiles.isEmpty()) {\n                sortBuffer.flushTo(outputWriter::appendRows);\n                return outputWriter.commit();\n            }\n\n            flushToTempFile();\n        }\n\n        try {\n            writeSorted();\n            return outputWriter.commit();\n        }\n        catch (UncheckedIOException e) {\n            throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, \"Error committing write to Hive\", e);\n        }\n    }\n\n    @Override\n    public void rollback()\n    {\n        if (!sortedWriteToTempPathEnabled) {\n            for (TempFile file : tempFiles) {\n                cleanupFile(file.getPath());\n            }\n        }\n\n        outputWriter.rollback();\n    }\n\n    @Override\n    public long getValidationCpuNanos()\n    {","sourceCodeStart":126,"sourceCodeEnd":162,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/SortingFileWriter.java#L126-L162","documentation":"SortingFileWriter.commit() first writes all buffered input in sorted order into the underlying output writer, then delegates commit to it. If the sorting/write phase throws UncheckedIOException, it is wrapped in HIVE_WRITER_CLOSE_ERROR with this message. The sorted output could not be produced or finalized, so the write fails at commit time.","triggerScenarios":"commit() on an INSERT using sorted output (sort properties on the table/session) where writeSorted() hits an I/O failure — e.g. disk full when spilling sorted data, or the underlying writer fails while writing sorted rows or committing.","commonSituations":"Very large single-partition sorts exhausting local temp/spill disk; HDFS write failure during the final sorted output; misconfigured sort memory buffers causing heavy spilling and eventual I/O errors; slow/unstable disks on temp space.","solutions":["Check local disk space for spill/temp directories and HDFS write health, then retry.","Reduce per-task sort size: increase writer count, lower per-task data volume, or split the INSERT.","Tune sort/writer memory configuration so writeSorted() does not exhaust buffers.","Inspect the wrapped UncheckedIOException for the precise I/O failure (disk, permissions, HDFS)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    executeInsert(sql);\n} catch (PrestoException e) {\n    if (e.getErrorCode() == HiveErrorCode.HIVE_WRITER_CLOSE_ERROR.toErrorCode().getId()) {\n        // check local spill disk space and HDFS health, then retry with reduced sort size\n    }\n}","preventionTips":["Monitor local temp/spill disk space on nodes running sorted writes.","Avoid single-partition inserts large enough to exhaust sort buffers.","Tune sort buffer/writer memory settings for your workload sizes."],"tags":["hive","sorting","writer","commit","io"],"backgroundTag":"writer-close-error","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"}