{"record":{"id":"6387d0626fbf47ad","repo":"apache/cassandra","slug":"directory-doesn-t-exist","errorCode":null,"errorMessage":"Directory {} doesn't exist","messagePattern":"Directory (.+?) doesn't exist","errorType":"console","errorClass":null,"httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/StartupChecks.java","lineNumber":857,"sourceCode":"        @Override\n        public void execute(StartupChecksConfiguration configuration) throws StartupException\n        {\n            if (configuration.isDisabled(name()))\n                return;\n            // check all directories(data, commitlog, saved cache) for existence and permission\n            Iterable<String> dirs = Iterables.concat(Arrays.asList(DatabaseDescriptor.getAllDataFileLocations()),\n                                                     Arrays.asList(DatabaseDescriptor.getCommitLogLocation(),\n                                                                   DatabaseDescriptor.getSavedCachesLocation(),\n                                                                   DatabaseDescriptor.getHintsDirectory().absolutePath()));\n            for (String dataDir : dirs)\n            {\n                logger.debug(\"Checking directory {}\", dataDir);\n                File dir = new File(dataDir);\n\n                // check that directories exist.\n                if (!dir.exists())\n                {\n                    logger.warn(\"Directory {} doesn't exist\", dataDir);\n                    // if they don't, failing their creation, stop cassandra.\n                    if (!dir.tryCreateDirectories())\n                        throw new StartupException(StartupException.ERR_WRONG_DISK_STATE,\n                                                   \"Has no permission to create directory \"+ dataDir);\n                }\n\n                // if directories exist verify their permissions\n                if (!Directories.verifyFullPermissions(dir, dataDir))\n                    throw new StartupException(StartupException.ERR_WRONG_DISK_STATE,\n                                               \"Insufficient permissions on directory \" + dataDir);\n            }\n        }\n    };\n\n    public static final StartupCheck checkDirectIOSupport = new StartupCheck()\n    {\n        @Override\n        public String name()","sourceCodeStart":839,"sourceCodeEnd":875,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/StartupChecks.java#L839-L875","documentation":"checkDataDirs verifies at startup that every data file directory from cassandra.yaml exists. If a directory is missing it is logged as a warning and auto-created; if creation fails (typically due to filesystem permissions), a StartupException with ERR_WRONG_DISK_STATE is thrown and the node refuses to start.","triggerScenarios":"A data_file_directories entry in cassandra.yaml points to a path that does not exist and the process user lacks write permission on the parent (dir.tryCreateDirectories() returns false), throwing StartupException(ERR_WRONG_DISK_STATE).","commonSituations":"Typo in data_file_directories path; volume not mounted before Cassandra starts (Kubernetes StatefulSet ordering); changed ownership of /var/lib/cassandra; running as non-cassandra user for testing.","solutions":["Create the missing directory and chown it to the Cassandra user: mkdir -p <dir> && chown -R cassandra:cassandra <dir>","Verify the path in cassandra.yaml data_file_directories is correct and the volume is mounted before startup","Check filesystem permissions/mount options (read-only mounts, SELinux) preventing creation","If the directory is intentionally gone, remove the stale entry from cassandra.yaml"],"exampleFix":"// before (cassandra.yaml)\ndata_file_directories:\n  - /var/lib/cassandra/data   # volume not mounted\n\n// after (shell pre-check before starting Cassandra)\n$ mkdir -p /var/lib/cassandra/data\n$ chown -R cassandra:cassandra /var/lib/cassandra\n$ df -h /var/lib/cassandra  # confirm mount exists","handlingStrategy":"validation","validationCode":"for (String dir : dataFileDirectories) {\n    File d = new File(dir);\n    if (!d.exists() && !d.getParentFile().canWrite())\n        throw new IllegalStateException(\"Cannot create data dir \" + dir + \": no write permission on parent\");\n}","typeGuard":null,"tryCatchPattern":"try {\n    startCassandra();\n} catch (StartupException e) {\n    if (e.errorCode == StartupException.ERR_WRONG_DISK_STATE)\n        // fix directory/permission and retry bootstrap\n        provisionDataDirs();\n}","preventionTips":["Create and chown data dirs in provisioning/entrypoint scripts before launching Cassandra","Use init containers or StatefulSet volumeClaimTemplates so mounts exist before start","Lint cassandra.yaml paths against actual mount points at deploy time"],"tags":["startup","filesystem","directories","permissions"],"backgroundTag":"directory-not-found","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"}