{"record":{"id":"9ab213be73ad84f1","repo":"prestodb/presto","slug":"hive-writer-close-error-9ab213","errorCode":"HIVE_WRITER_CLOSE_ERROR","errorMessage":"Error committing write to Hive. %s","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/OrcFileWriter.java","lineNumber":257,"sourceCode":"            throw new PrestoException(HIVE_WRITER_DATA_ERROR, e);\n        }\n    }\n\n    @Override\n    public Optional<Page> commit()\n    {\n        try {\n            orcWriter.close();\n        }\n        catch (IOException | UncheckedIOException | PrestoException e) {\n            try {\n                rollbackAction.call();\n            }\n            catch (Exception ignored) {\n                // ignore\n            }\n            throwIfInstanceOf(e, PrestoException.class);\n            throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, \"Error committing write to Hive. \" + e.getMessage(), e);\n        }\n\n        if (validationInputFactory.isPresent()) {\n            try {\n                try (OrcDataSource input = validationInputFactory.get().get()) {\n                    long startThreadCpuTime = THREAD_MX_BEAN.getCurrentThreadCpuTime();\n                    orcWriter.validate(input);\n                    validationCpuNanos += THREAD_MX_BEAN.getCurrentThreadCpuTime() - startThreadCpuTime;\n                }\n            }\n            catch (IOException | UncheckedIOException e) {\n                throw new PrestoException(HIVE_WRITE_VALIDATION_FAILED, e);\n            }\n        }\n\n        return Optional.of(createFileStatisticsPage(getFileSizeInBytes(), rowCount));\n    }\n","sourceCodeStart":239,"sourceCodeEnd":275,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/OrcFileWriter.java#L239-L275","documentation":"OrcFileWriter.commit() finalizes the ORC/DWRF file: it closes the writer and calls the rollback action bookkeeping. If an exception escapes commit and it is not already a PrestoException, Presto rolls back (best-effort) and wraps the cause in HIVE_WRITER_CLOSE_ERROR with 'Error committing write to Hive'. The original IOException or other failure is attached as the cause.","triggerScenarios":"commit() when the OrcWriter close/finish fails with a non-PrestoException (e.g. IOException flushing ORC footers/statistics to the filesystem) or any other RuntimeException during commit; PrestoExceptions are rethrown as-is via throwIfInstanceOf.","commonSituations":"HDFS/S3 write failures when flushing the ORC footer and stripe metadata, quota or disk-full conditions at commit time, S3 throttling during multipart completion, node loss while finishing the file.","solutions":["Inspect the cause attached to the exception for the root storage failure and fix it (permissions, quota, connectivity).","Retry the query/transaction; commit-time IO failures are often transient (S3 timeouts, HDFS retries).","Ensure sufficient space/quota on the destination filesystem before large writes.","Tune S3/HDFS client timeouts and retry counts for large ORC files with big footers."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    insertInto(orcTable, data);\n} catch (PrestoException e) {\n    if (\"HIVE_WRITER_CLOSE_ERROR\".equals(e.getErrorCode().getName())\n            && e.getCause() instanceof IOException && isTransient(e.getCause())) {\n        retry(insertInto, attempts = 3, backoff = exponential());\n    } else {\n        throw e;\n    }\n}","preventionTips":["Ensure ample disk/quota on destination storage before large ORC writes.","Enable retries/timeouts on HDFS/S3 clients; footer flushes are IO heavy.","Schedule large writes outside of storage maintenance windows."],"tags":["hive","orc","commit","io","writer"],"backgroundTag":"file-commit-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"}