prestodb/presto · error · PrestoException

HIVE_WRITER_CLOSE_ERROR

HIVE_WRITER_CLOSE_ERROR

Error message

Error committing write to Hive

What it means

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.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/SortingFileWriter.java:144

    @Override
    public Optional<Page> commit()
    {
        if (!sortBuffer.isEmpty()) {
            // skip temporary files entirely if the total output size is small
            if (tempFiles.isEmpty()) {
                sortBuffer.flushTo(outputWriter::appendRows);
                return outputWriter.commit();
            }

            flushToTempFile();
        }

        try {
            writeSorted();
            return outputWriter.commit();
        }
        catch (UncheckedIOException e) {
            throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error committing write to Hive", e);
        }
    }

    @Override
    public void rollback()
    {
        if (!sortedWriteToTempPathEnabled) {
            for (TempFile file : tempFiles) {
                cleanupFile(file.getPath());
            }
        }

        outputWriter.rollback();
    }

    @Override
    public long getValidationCpuNanos()
    {

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Check local disk space for spill/temp directories and HDFS write health, then retry.
  2. Reduce per-task sort size: increase writer count, lower per-task data volume, or split the INSERT.
  3. Tune sort/writer memory configuration so writeSorted() does not exhaust buffers.
  4. Inspect the wrapped UncheckedIOException for the precise I/O failure (disk, permissions, HDFS).
Defensive patterns

Strategy: retry

Try / catch

try {
    executeInsert(sql);
} catch (PrestoException e) {
    if (e.getErrorCode() == HiveErrorCode.HIVE_WRITER_CLOSE_ERROR.toErrorCode().getId()) {
        // check local spill disk space and HDFS health, then retry with reduced sort size
    }
}

Prevention

When it happens

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

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

Related errors


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