prestodb/presto · error · PrestoException
HIVE_WRITER_CLOSE_ERROR
HIVE_WRITER_CLOSE_ERROR
Error message
Error rolling back write to Hive
What it means
HivePageSink.doAbort attempts to roll back every open writer when a write is aborted. If any writer's rollback itself throws, the sink wraps that exception in HIVE_WRITER_CLOSE_ERROR with this message, preserving the original as cause. It signals failure during cleanup of a failed write, not the original write failure.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HivePageSink.java:311
}
private void doAbort()
{
Optional<Exception> rollbackException = Optional.empty();
for (HiveWriter writer : writers) {
// writers can contain nulls if an exception is thrown when doAppend expends the writer list
if (writer != null) {
try {
writer.rollback();
}
catch (Exception e) {
log.warn("exception '%s' while rollback on %s", e, writer);
rollbackException = Optional.of(e);
}
}
}
if (rollbackException.isPresent()) {
throw new PrestoException(HIVE_WRITER_CLOSE_ERROR, "Error rolling back write to Hive", rollbackException.get());
}
}
@Override
public CompletableFuture<?> appendPage(Page page)
{
if (page.getPositionCount() > 0) {
// Must be wrapped in doAs entirely
// Implicit FileSystem initializations are possible in HiveRecordWriter#addRow or #createWriter
hdfsEnvironment.doAs(session.getUser(), () -> doAppend(page));
}
return NOT_BLOCKED;
}
private void doAppend(Page page)
{
while (page.getPositionCount() > MAX_PAGE_POSITIONS) {View on GitHub (pinned to 55bb57d202)
Solutions
- Inspect the cause exception attached to this PrestoException; it contains the real rollback failure.
- Check storage connectivity/permissions and free space on staging directories.
- Retry the query; abort-time rollback failures usually leave no committed data since the write was already aborted.
- If reproducible on a specific format/compression, upgrade the Hive connector or disable that writer type.
Example fix
// The thrown exception carries the root cause; surface it
try { ... } catch (PrestoException e) {
log.error("rollback failed: %s", e.getCause()); // cause is the writer's rollback exception
} Defensive patterns
Strategy: try-catch
Try / catch
try {
// sink operation / query
} catch (PrestoException e) {
if ("HIVE_WRITER_CLOSE_ERROR".equals(e.getErrorCode().getName())) {
Throwable root = e.getCause(); // real rollback failure
log.error("Writer rollback failed: %s", root);
}
throw e;
} Prevention
- Ensure staging directories have adequate disk space and correct permissions.
- Monitor storage backend connectivity; transient I/O failures during abort cause this.
- Always read getCause() — the message alone hides the real failure.
- Keep the Hive connector up to date to pick up writer abort-path fixes.
When it happens
Trigger: Query failure or cancellation triggers doAbort(); a writer's rollback() call throws (e.g. underlying writer.close/abort raised an IOException, or the original write error left the writer in a broken state).
Common situations: Node losing connection to storage mid-write, ORC/Parquet writer throwing while aborting an in-progress file, disk full on local spill/staging paths during abort.
Related errors
- HIVE_TOO_MANY_OPEN_PARTITIONS
- GENERIC_INTERNAL_ERROR
- HIVE_INVALID_ENCRYPTION_METADATA
- HIVE_INVALID_ENCRYPTION_METADATA
- HIVE_INVALID_ENCRYPTION_METADATA
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/dbef35b86bc7ff70.
Report an issue: GitHub.