{"record":{"id":"737bb5ad7b89ffb8","repo":"prestodb/presto","slug":"hive-file-not-found","errorCode":"HIVE_FILE_NOT_FOUND","errorMessage":"HIVE_FILE_NOT_FOUND (message from cause throwable)","messagePattern":"HIVE_FILE_NOT_FOUND \\(message from cause throwable\\)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/HiveSplitSource.java","lineNumber":831,"sourceCode":"    {\n        while (true) {\n            T current = atomicReference.get();\n            if (!predicate.test(current)) {\n                return false;\n            }\n            if (atomicReference.compareAndSet(current, newValue)) {\n                return true;\n            }\n        }\n    }\n\n    private static RuntimeException propagatePrestoException(Throwable throwable)\n    {\n        if (throwable instanceof PrestoException) {\n            throw (PrestoException) throwable;\n        }\n        if (throwable instanceof FileNotFoundException) {\n            throw new PrestoException(HIVE_FILE_NOT_FOUND, throwable);\n        }\n        throw new PrestoException(HIVE_UNKNOWN_ERROR, throwable);\n    }\n\n    interface PerBucket\n    {\n        ListenableFuture<?> offer(OptionalInt bucketNumber, InternalHiveSplit split);\n\n        ListenableFuture<List<ConnectorSplit>> borrowBatchAsync(OptionalInt bucketNumber, int maxSize, Function<List<InternalHiveSplit>, BorrowResult<InternalHiveSplit, List<ConnectorSplit>>> function);\n\n        default ListenableFuture<List<ConnectorSplit>> borrowBatchAsync(OptionalInt bucketNumber, Map<String, String> partitionValues, int maxSize, Function<List<InternalHiveSplit>, BorrowResult<InternalHiveSplit, List<ConnectorSplit>>> function)\n        {\n            throw new UnsupportedOperationException(\"partition-aware borrowBatchAsync requires a PerBucket implementation that supports partition values\");\n        }\n\n        void noMoreSplits();\n\n        boolean isFinished(OptionalInt bucketNumber);","sourceCodeStart":813,"sourceCodeEnd":849,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/HiveSplitSource.java#L813-L849","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Re-run the query after the concurrent modification finishes.","Disable/coordinate S3 lifecycle rules or HDFS retention that delete files during queries; align compaction windows with query schedule.","Repair the table: run MSCK REPAIR or drop stale partition locations that no longer exist.","Catch HIVE_FILE_NOT_FOUND in your query runner and retry with fresh metadata."],"exampleFix":"// before\n// query fails: java.io.FileNotFoundException: File s3://bucket/table/part-0000 does not exist\n// after: retry after ensuring files exist; or configure lifecycle rules to not expire in-use prefixes\n{\"Rules\":[{\"Filter\":{\"Prefix\":\"table/\"},\"Status\":\"Disabled\"}]}","handlingStrategy":"retry","validationCode":"// verify expected files still exist before querying\nFileSystem fs = path.getFileSystem(conf);\nif (!fs.exists(new Path(partitionLocation))) { /* refresh partitions or reschedule */ }","typeGuard":"boolean isFileNotFound(PrestoException e) {\n    return HIVE_FILE_NOT_FOUND.toErrorCode().getCode() == e.getErrorCode().getCode();\n}","tryCatchPattern":"try { runQuery(sql); } catch (PrestoException e) {\n    if (isFileNotFound(e)) { refreshPartitionMetadata(); retryQuery(sql); }\n    else { throw e; }\n}","preventionTips":["Avoid S3 lifecycle/HDFS retention rules that delete files under live query paths","Coordinate compaction and file deletion with query schedules","Use ACID/Iceberg tables for concurrent mutation safety","Run MSCK REPAIR / metastore checks after data moves"],"tags":["file-not-found","hdfs","s3","concurrency"],"backgroundTag":"file-not-found","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-12T02:17:10.037Z"}