prestodb/presto · error · PrestoException
HIVE_CURSOR_ERROR
HIVE_CURSOR_ERROR
Error message
Failed to read ORC file: %s
What it means
OrcBatchPageSource.getNextPage converts OrcCorruptionException to HIVE_BAD_DATA, but any other IOException or RuntimeException during record-set advancement closes the source and is wrapped as PrestoException(HIVE_CURSOR_ERROR) with the ORC data source id. This is the connector's generic 'the cursor hit a failure while reading this file' signal.
Source
Thrown at presto-hive/src/main/java/com/facebook/presto/hive/orc/OrcBatchPageSource.java:214
blocks[fieldId] = constantBlocks[fieldId].getRegion(0, batchSize);
}
else {
blocks[fieldId] = new LazyBlock(batchSize, new OrcBlockLoader(hiveColumnIndexes[fieldId]));
}
}
return new Page(batchSize, blocks);
}
catch (PrestoException e) {
closeWithSuppression(e);
throw e;
}
catch (OrcCorruptionException e) {
closeWithSuppression(e);
throw new PrestoException(HIVE_BAD_DATA, e);
}
catch (IOException | RuntimeException e) {
closeWithSuppression(e);
throw new PrestoException(HIVE_CURSOR_ERROR, format("Failed to read ORC file: %s", orcDataSource.getId()), e);
}
}
@Override
public void close()
{
// some hive input formats are broken and bad things can happen if you close them multiple times
if (closed) {
return;
}
closed = true;
try {
stats.addMaxCombinedBytesPerRow(recordReader.getMaxCombinedBytesPerRow());
recordReader.close();
}
catch (IOException e) {
throw new UncheckedIOException(e);View on GitHub (pinned to 55bb57d202)
Solutions
- Read the `cause` of the HIVE_CURSOR_ERROR to get the real underlying problem
- Validate file integrity: hdfs fsck and try reading the file with a Hive/ORC tooling (orc-tools dump)
- Re-run the query if the cause was transient HDFS I/O (coexists with HIVE_FILESYSTEM_ERROR causes)
- Replace/regenerate corrupt or truncated files; rewrite with orc-tools if the writer produced bad metadata
Example fix
// before SELECT * FROM t; -- HIVE_CURSOR_ERROR: Failed to read ORC file: hdfs://.../part-0 (cause: EOFException) // after -- java -jar orc-tools-*.jar dump /warehouse/t/part-0 # verify readability -- regenerate part-0 from the upstream job SELECT * FROM t;
Defensive patterns
Strategy: try-catch
Validate before calling
# verify file readability outside Presto first hadoop jar orc-tools-*.jar meta /warehouse/t/part-0 hdfs fsck /warehouse/t/part-0 -blocks
Try / catch
try {
return query(sql);
} catch (PrestoException e) {
if (e.getErrorCode().getName().equals("HIVE_CURSOR_ERROR")) {
// inspect e.getCause() for the real IOException/RuntimeException
logRootCause(e.getCause());
return query(sql); // retry only if cause was transient IO
}
throw e;
} Prevention
- Always check e.getCause() — HIVE_CURSOR_ERROR is a wrapper, not a diagnosis
- Validate newly written ORC files with orc-tools before publishing partitions
- Monitor for truncated files (writes interrupted) in table locations
- Ensure worker memory is sufficient for the column widths being read
When it happens
Trigger: getNextPage -> recordSet.advanceNextPosition() throws IOException or RuntimeException that is not OrcCorruptionException (e.g., EOF from truncated file, HdfsOrcDataSource PrestoExceptions bubbling, NPEs, OOM).
Common situations: Truncated files whose postscript/stripes cut off; transient HDFS read failures during long scans; faulty writer output causing unexpected runtime errors; worker memory exhaustion reading wide rows.
Related errors
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/44151b764564ec6c.
Report an issue: GitHub.