prestodb/presto · error · PrestoException

HIVE_WRITER_CLOSE_ERROR

HIVE_WRITER_CLOSE_ERROR

Error message

Error write zero-row file to Hive

What it means

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.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveZeroRowFileCreator.java:161

                deleteIfExists(tmpFilePath);
            }
            catch (IOException e) {
                log.error(e, "Error deleting temporary file: %s", tmpFilePath);
            }
        }
    }

    private void createFile(HdfsContext hdfsContext, Path path, byte[] content, ConnectorSession session)
    {
        try {
            FileSystem fs = hdfsEnvironment.getFileSystem(hdfsContext, path);
            try (DataSink dataSink = dataSinkFactory.createDataSink(session, fs, path)) {
                DataOutput dataOutput = createDataOutput(Slices.wrappedBuffer(content));
                dataSink.write(ImmutableList.of(dataOutput));
            }
        }
        catch (IOException e) {
            throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error write zero-row file to Hive", e);
        }
    }
}

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check filesystem health and permissions on the target partition directory; retry the failed query once the underlying IOException cause is resolved.
  2. Verify HDFS is out of safe mode / S3 credentials and bucket policies allow writes.
  3. Inspect the wrapped cause (the IOException is attached as the cause) for the root storage error.
  4. If it happens on S3 frequently, tune retry/timeout settings of the S3 filesystem client.
Defensive patterns

Strategy: retry

Try / catch

try {
    query.execute();
} catch (PrestoException e) {
    if ("HIVE_WRITER_CLOSE_ERROR".equals(e.getErrorCode().getName()) && isTransient(e.getCause())) {
        retry(query, maxAttempts = 3, backoff = exponential());
    } else {
        throw e;
    }
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Understand the failure class

Background: "failed to write file", "Could not save figure", "Error saving remote file" — file write failed: causes and fixes across languages and libraries — this error's family across 38 libraries.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/c79578814d63a63a. Report an issue: GitHub.