prestodb/presto · error · PrestoException

HIVE_FILE_NOT_FOUND

HIVE_FILE_NOT_FOUND

Error message

HIVE_FILE_NOT_FOUND (message from cause throwable)

What it means

propagatePrestoException wraps a java.io.FileNotFoundException thrown during background split loading into a PrestoException with HIVE_FILE_NOT_FOUND. Because the failure surfaces from an async task, the original FileNotFoundException message becomes the exception detail.

Source

Thrown at presto-hive/src/main/java/com/facebook/presto/hive/HiveSplitSource.java:831

    {
        while (true) {
            T current = atomicReference.get();
            if (!predicate.test(current)) {
                return false;
            }
            if (atomicReference.compareAndSet(current, newValue)) {
                return true;
            }
        }
    }

    private static RuntimeException propagatePrestoException(Throwable throwable)
    {
        if (throwable instanceof PrestoException) {
            throw (PrestoException) throwable;
        }
        if (throwable instanceof FileNotFoundException) {
            throw new PrestoException(HIVE_FILE_NOT_FOUND, throwable);
        }
        throw new PrestoException(HIVE_UNKNOWN_ERROR, throwable);
    }

    interface PerBucket
    {
        ListenableFuture<?> offer(OptionalInt bucketNumber, InternalHiveSplit split);

        ListenableFuture<List<ConnectorSplit>> borrowBatchAsync(OptionalInt bucketNumber, int maxSize, Function<List<InternalHiveSplit>, BorrowResult<InternalHiveSplit, List<ConnectorSplit>>> function);

        default ListenableFuture<List<ConnectorSplit>> borrowBatchAsync(OptionalInt bucketNumber, Map<String, String> partitionValues, int maxSize, Function<List<InternalHiveSplit>, BorrowResult<InternalHiveSplit, List<ConnectorSplit>>> function)
        {
            throw new UnsupportedOperationException("partition-aware borrowBatchAsync requires a PerBucket implementation that supports partition values");
        }

        void noMoreSplits();

        boolean isFinished(OptionalInt bucketNumber);

View on GitHub (pinned to 55bb57d202)

Solutions

  1. Re-run the query after the concurrent modification finishes.
  2. Disable/coordinate S3 lifecycle rules or HDFS retention that delete files during queries; align compaction windows with query schedule.
  3. Repair the table: run MSCK REPAIR or drop stale partition locations that no longer exist.
  4. Catch HIVE_FILE_NOT_FOUND in your query runner and retry with fresh metadata.

Example fix

// before
// query fails: java.io.FileNotFoundException: File s3://bucket/table/part-0000 does not exist
// after: retry after ensuring files exist; or configure lifecycle rules to not expire in-use prefixes
{"Rules":[{"Filter":{"Prefix":"table/"},"Status":"Disabled"}]}
Defensive patterns

Strategy: retry

Validate before calling

// verify expected files still exist before querying
FileSystem fs = path.getFileSystem(conf);
if (!fs.exists(new Path(partitionLocation))) { /* refresh partitions or reschedule */ }

Type guard

boolean isFileNotFound(PrestoException e) {
    return HIVE_FILE_NOT_FOUND.toErrorCode().getCode() == e.getErrorCode().getCode();
}

Try / catch

try { runQuery(sql); } catch (PrestoException e) {
    if (isFileNotFound(e)) { refreshPartitionMetadata(); retryQuery(sql); }
    else { throw e; }
}

Prevention

When it happens

Trigger: During asynchronous split verification/loading, opening a data file that no longer exists on HDFS/S3 — file deleted or renamed between listing and read, or listing produced stale paths.

Common situations: Concurrent jobs deleting/compacting files mid-query (files noticably missing after HDFS retention or S3 lifecycle rules); hive.cp.remove-when-missing style moves; bucket file missing after failed compaction; schema/permission changes making paths inaccessible.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


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