{"record":{"id":"d8fd3b65590d7d3d","repo":"prestodb/presto","slug":"hive-cannot-open-split-d8fd3b","errorCode":"HIVE_CANNOT_OPEN_SPLIT","errorMessage":"Error opening Hive split %s (offset=%s, length=%s): %s","messagePattern":"Error opening Hive split (.+?) \\(offset=(.+?), length=(.+?)\\): (.+?)","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-hive/src/main/java/com/facebook/presto/hive/rcfile/RcFilePageSourceFactory.java","lineNumber":137,"sourceCode":"        else {\n            return Optional.empty();\n        }\n\n        if (fileSplit.getFileSize() == 0) {\n            throw new PrestoException(HIVE_BAD_DATA, \"RCFile is empty: \" + fileSplit.getPath());\n        }\n\n        FSDataInputStream inputStream;\n        Path path = new Path(fileSplit.getPath());\n        try {\n            inputStream = hdfsEnvironment.getFileSystem(session.getUser(), path, configuration).openFile(path, hiveFileContext);\n        }\n        catch (Exception e) {\n            if (nullToEmpty(e.getMessage()).trim().equals(\"Filesystem closed\") ||\n                    e instanceof FileNotFoundException) {\n                throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, e);\n            }\n            throw new PrestoException(HIVE_CANNOT_OPEN_SPLIT, splitError(e, fileSplit), e);\n        }\n\n        try {\n            ImmutableMap.Builder<Integer, Type> readColumns = ImmutableMap.builder();\n            for (HiveColumnHandle column : columns) {\n                readColumns.put(column.getHiveColumnIndex(), column.getHiveType().getType(typeManager));\n            }\n\n            RcFileReader rcFileReader = new RcFileReader(\n                    new HdfsRcFileDataSource(path.toString(), inputStream, fileSplit.getFileSize(), stats),\n                    rcFileEncoding,\n                    readColumns.build(),\n                    new AircompressorCodecFactory(new HadoopCodecFactory(configuration.getClassLoader())),\n                    fileSplit.getStart(),\n                    fileSplit.getLength(),\n                    new DataSize(8, Unit.MEGABYTE));\n\n            return Optional.of(new RcFilePageSource(rcFileReader, columns, typeManager));","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-hive/src/main/java/com/facebook/presto/hive/rcfile/RcFilePageSourceFactory.java#L119-L155","documentation":"Thrown by RcFilePageSourceFactory.createPageSource when the HDFS/Hive connector cannot open an RCFile split. Any exception raised while calling hdfsEnvironment.getFileSystem(...).openFile(path, ...) is wrapped in a PrestoException with error code HIVE_CANNOT_OPEN_SPLIT; FileNotFoundException and 'Filesystem closed' are wrapped without the split message, everything else gets the formatted splitError message. It signals the split could not be read at all — an infrastructure/availability problem rather than corrupt data.","triggerScenarios":"Presto worker executes createPageSource for an RCFile (RCFileColumnarSerDe or LazyBinaryColumnarSerDe table) and openFile throws: NameNode unreachable, permission denied on the HDFS path, FileNotFoundException because the file was deleted between split scheduling and read, a cached Hadoop FileSystem instance already closed, or any other IOException from the Hadoop FS layer.","commonSituations":"HDFS NameNode in safe mode or down; underlying table/partition files dropped by a compaction or retention job while a query was running; wrong dfs permissions or missing Kerberos tokens for the presto user; Hive metastore pointing at stale locations; 'Filesystem closed' after a FileSystem cache invalidation in long-lived workers.","solutions":["Verify the HDFS file exists and is readable: run `hdfs dfs -ls <path>` and `hdfs dfs -cat <file> | head` as the presto user.","Check NameNode health and that the worker's core-site/hdfs-site config points at the right cluster.","Confirm the presto user has read permission (or appropriate Kerberos/HDFS ACLs) on the file and its parents.","If 'Filesystem closed', restart the affected workers / upgrade — the cached FileSystem instance was closed underneath the connector.","Re-run the query; if the file was deleted mid-query, regenerate the data or rerun against an intact snapshot."],"exampleFix":"// before: querying a path that no longer exists\nSELECT * FROM hive.default.rc_table; -- fails HIVE_CANNOT_OPEN_SPLIT, file deleted\n// after: verify location, or exclude the bad partition\nALTER TABLE hive.default.rc_table DROP IF EXISTS PARTITION (ds='2026-01-01');\nSELECT * FROM hive.default.rc_table WHERE ds <> '2026-01-01';","handlingStrategy":"try-catch","validationCode":"// before running the query, from a node with the same Hadoop config/user:\n// hdfs dfs -test -e <split-path> && hdfs dfs -cat <split-path>/part | head -c 1\nProcess p = new ProcessBuilder(\"hdfs\", \"dfs\", \"test\", \"-e\", splitPath).start();\nif (p.waitFor() != 0) throw new IllegalStateException(\"HDFS path not readable: \" + splitPath);","typeGuard":"boolean isCannotOpenSplit(Throwable t) {\n    return t instanceof PrestoException && ((PrestoException) t).getErrorCode().getName().equals(\"HIVE_CANNOT_OPEN_SPLIT\");\n}","tryCatchPattern":"try {\n    return query(sql);\n} catch (PrestoException e) {\n    if (e.getErrorCode().getCode() == StandardErrorCode.EXTERNAL.getCode() && e.getMessage() != null && e.getMessage().contains(\"HIVE_CANNOT_OPEN_SPLIT\")) {\n        // check HDFS health / file existence, then retry once or fail fast\n        throw new TransientQueryException(\"Split unreadable, check HDFS/file: \" + e.getMessage(), e);\n    }\n    throw e;\n}","preventionTips":["Pre-check file existence/permissions on the table location before launching scans.","Keep HDFS client configs (core-site, hdfs-site) consistent across coordinators and workers.","Monitor NameNode health and safe-mode status; gate scheduled queries on cluster health.","Avoid deleting/rewriting table files while queries may be scanning them (use atomic rename patterns).","Maintain valid Kerberos/delegation tokens for the presto user on long-running clusters."],"tags":["hive","hdfs","rcfile","io","split"],"backgroundTag":"hive-cannot-open-split","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}