{"record":{"id":"c79578814d63a63a","repo":"prestodb/presto","slug":"hive-writer-close-error-c79578","errorCode":"HIVE_WRITER_CLOSE_ERROR","errorMessage":"Error write zero-row file to Hive","messagePattern":"Error write zero-row file to Hive","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveZeroRowFileCreator.java","lineNumber":161,"sourceCode":"                deleteIfExists(tmpFilePath);\n            }\n            catch (IOException e) {\n                log.error(e, \"Error deleting temporary file: %s\", tmpFilePath);\n            }\n        }\n    }\n\n    private void createFile(HdfsContext hdfsContext, Path path, byte[] content, ConnectorSession session)\n    {\n        try {\n            FileSystem fs = hdfsEnvironment.getFileSystem(hdfsContext, path);\n            try (DataSink dataSink = dataSinkFactory.createDataSink(session, fs, path)) {\n                DataOutput dataOutput = createDataOutput(Slices.wrappedBuffer(content));\n                dataSink.write(ImmutableList.of(dataOutput));\n            }\n        }\n        catch (IOException e) {\n            throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, \"Error write zero-row file to Hive\", e);\n        }\n    }\n}\n","sourceCodeStart":143,"sourceCodeEnd":165,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveZeroRowFileCreator.java#L143-L165","documentation":"HiveZeroRowFileCreator writes special zero-row marker files (empty files used to materialize empty partitions/directories). If the underlying DataSink throws an IOException while writing the wrapped buffer of the marker content, Presto wraps it in HIVE_WRITER_CLOSE_ERROR with this message. It signals the zero-row marker file could not be persisted to storage.","triggerScenarios":"Calling HiveZeroRowFileCreator.createFile when dataSinkFactory.createDataSink succeeds but dataSink.write(...) or the sink close (try-with-resources) throws IOException — e.g. filesystem errors while flushing the small marker payload.","commonSituations":"HDFS/S3 transient write failures, missing write permissions on the target directory, quota exceeded, HDFS safe mode, or S3 throttling when creating empty partition marker files during a commit phase.","solutions":["Check filesystem health and permissions on the target partition directory; retry the failed query once the underlying IOException cause is resolved.","Verify HDFS is out of safe mode / S3 credentials and bucket policies allow writes.","Inspect the wrapped cause (the IOException is attached as the cause) for the root storage error.","If it happens on S3 frequently, tune retry/timeout settings of the S3 filesystem client."],"exampleFix":null,"handlingStrategy":"retry","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    query.execute();\n} catch (PrestoException e) {\n    if (\"HIVE_WRITER_CLOSE_ERROR\".equals(e.getErrorCode().getName()) && isTransient(e.getCause())) {\n        retry(query, maxAttempts = 3, backoff = exponential());\n    } else {\n        throw e;\n    }\n}","preventionTips":["Ensure target partition directories are writable by the Presto service account.","Monitor HDFS safe mode and S3 error rates; avoid commits during storage instability.","Keep HDFS/S3 client retry policies enabled with sane timeouts."],"tags":["hive","io","filesystem","writer"],"backgroundTag":"file-write-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"}