{"record":{"id":"ec47dc5ad649def3","repo":"apache/cassandra","slug":"io-exception-while-reading-file","errorCode":null,"errorMessage":"IO exception while reading file {}.","messagePattern":"IO exception while reading file (.+?)\\.","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/service/StartupChecks.java","lineNumber":726,"sourceCode":"        private Map<String, String> getBlockDevices(String[] dataDirectories) {\n            Map<String, String> blockDevices = new HashMap<String, String>();\n\n            for (String dataDirectory : dataDirectories)\n            {\n                try\n                {\n                    Path p = File.getPath(dataDirectory);\n                    FileStore fs = Files.getFileStore(p);\n\n                    String blockDirectory = fs.name();\n                    if(StringUtils.isNotEmpty(blockDirectory))\n                    {\n                        blockDevices.put(blockDirectory, dataDirectory);\n                    }\n                }\n                catch (IOException e)\n                {\n                    logger.warn(\"IO exception while reading file {}.\", dataDirectory, e);\n                }\n            }\n            return blockDevices;\n        }\n\n        @Override\n        public void execute(StartupChecksConfiguration configuration)\n        {\n            if (configuration.isDisabled(name()) || !FBUtilities.isLinux)\n                return;\n\n            String[] dataDirectories = DatabaseDescriptor.getRawConfig().data_file_directories;\n            Map<String, String> blockDevices = getBlockDevices(dataDirectories);\n\n            for (Map.Entry<String, String> entry: blockDevices.entrySet())\n            {\n                String blockDeviceDirectory = entry.getKey();\n                String dataDirectory = entry.getValue();","sourceCodeStart":708,"sourceCodeEnd":744,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StartupChecks.java#L708-L744","documentation":"In DiskCheck/CheckReadAhead machinery, getBlockDevices walks each configured data directory to resolve its backing block device by reading sysfs paths. If an IOException occurs while reading the directory/files, it logs 'IO exception while reading file {dataDirectory}.' with the exception, skips that directory, and continues. The startup check degrades gracefully rather than failing startup.","triggerScenarios":"IOException while listing/reading the sysfs block-device path or data directory during getBlockDevices (e.g. /sys entries missing, unreadable /proc/self/mountinfo, I/O error on the data directory).","commonSituations":"Containers without /sys/block mounted, unusual storage layouts (LVM/loop devices), permission-restricted data directories, NFS or ephemeral mounts where sysfs resolution fails.","solutions":["Inspect the logged exception for the actual failing path and fix permissions (chown cassandra:cassandra on the data directory).","Mount /sys read-write or at least readable into containers running Cassandra.","Verify data_file_directories in cassandra.yaml point to existing, readable paths.","If the warning is expected for your storage topology, treat it as informational; read-ahead checks are skipped for that device."],"exampleFix":"// before\ndata_file_directories: [/mnt/missing-disk/data]\n// after\ndata_file_directories: [/var/lib/cassandra/data]  # existing, readable path","handlingStrategy":"try-catch","validationCode":"for (String dir : dataDirs) {\n    File f = new File(dir);\n    if (!f.canRead()) System.out.println(\"Unreadable data directory: \" + dir);\n}\nif (!new File(\"/sys/block\").canRead()) System.out.println(\"/sys/block not accessible; device checks will be skipped\");","typeGuard":null,"tryCatchPattern":"try {\n    // device/directory probing\n} catch (IOException e) {\n    logger.warn(\"IO exception while reading file {}.\", dataDirectory, e);\n    // fall back: skip read-ahead check for this directory\n}","preventionTips":["Mount /sys read-only into Cassandra containers.","Ensure cassandra user owns data_file_directories.","Avoid NFS for data directories; use local block devices.","Fix the underlying IOException by reading the logged stack trace."],"tags":["io","filesystem","startup-check"],"backgroundTag":"file-read-failed","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}