prestodb/presto · error · PrestoException

HIVE_WRITER_CLOSE_ERROR

HIVE_WRITER_CLOSE_ERROR

Error message

Error committing write to Hive. %s

What it means

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.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/OrcFileWriter.java:257

            throw new PrestoException(HIVE_WRITER_DATA_ERROR, e);
        }
    }

    @Override
    public Optional<Page> commit()
    {
        try {
            orcWriter.close();
        }
        catch (IOException | UncheckedIOException | PrestoException e) {
            try {
                rollbackAction.call();
            }
            catch (Exception ignored) {
                // ignore
            }
            throwIfInstanceOf(e, PrestoException.class);
            throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error committing write to Hive. " + e.getMessage(), e);
        }

        if (validationInputFactory.isPresent()) {
            try {
                try (OrcDataSource input = validationInputFactory.get().get()) {
                    long startThreadCpuTime = THREAD_MX_BEAN.getCurrentThreadCpuTime();
                    orcWriter.validate(input);
                    validationCpuNanos += THREAD_MX_BEAN.getCurrentThreadCpuTime() - startThreadCpuTime;
                }
            }
            catch (IOException | UncheckedIOException e) {
                throw new PrestoException(HIVE_WRITE_VALIDATION_FAILED, e);
            }
        }

        return Optional.of(createFileStatisticsPage(getFileSizeInBytes(), rowCount));
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Inspect the cause attached to the exception for the root storage failure and fix it (permissions, quota, connectivity).
  2. Retry the query/transaction; commit-time IO failures are often transient (S3 timeouts, HDFS retries).
  3. Ensure sufficient space/quota on the destination filesystem before large writes.
  4. Tune S3/HDFS client timeouts and retry counts for large ORC files with big footers.
Defensive patterns

Strategy: retry

Try / catch

try {
    insertInto(orcTable, data);
} catch (PrestoException e) {
    if ("HIVE_WRITER_CLOSE_ERROR".equals(e.getErrorCode().getName())
            && e.getCause() instanceof IOException && isTransient(e.getCause())) {
        retry(insertInto, attempts = 3, backoff = exponential());
    } else {
        throw e;
    }
}

Prevention

When it happens

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

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

Related errors


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