{"record":{"id":"3d702f2f22953d83","repo":"apache/cassandra","slug":"err-wrong-disk-state-3d702f","errorCode":"ERR_WRONG_DISK_STATE","errorMessage":"FS ownership check failed; error when checking for fs ownership file","messagePattern":"FS ownership check failed; error when checking for fs ownership file","errorType":"exception","errorClass":"StartupException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/service/FileSystemOwnershipCheck.java","lineNumber":171,"sourceCode":"            Path dir = File.getPath(dataDir).normalize();\n            do\n            {\n                File tokenFile = resolve(dir, tokenFilename);\n                if (tokenFile.exists())\n                {\n                    foundFiles++;\n                    if (!foundProperties.containsKey(tokenFile.toPath().toAbsolutePath()))\n                    {\n                        try (BufferedReader reader = Files.newBufferedReader(tokenFile.toPath()))\n                        {\n                            Properties props = new Properties();\n                            props.load(reader);\n                            foundProperties.put(tokenFile.toPath().toAbsolutePath(), props);\n                        }\n                        catch (Exception e)\n                        {\n                            logger.error(\"Error reading fs ownership file from disk\", e);\n                            throw exception(READ_EXCEPTION);\n                        }\n                    }\n                }\n                dir = dir.getParent();\n            } while (dir != null);\n\n            foundPerTargetDir.put(dataDir, foundFiles);\n        }\n\n        // If a marker file couldn't be found for every target directory, error.\n        if (foundPerTargetDir.containsValue(0))\n        {\n            throw exception(String.format(NO_OWNERSHIP_FILE, foundPerTargetDir.entrySet()\n                                                                              .stream()\n                                                                              .filter(e -> e.getValue() == 0)\n                                                                              .map(Map.Entry::getKey)\n                                                                              .collect(Collectors.joining(\"', '\", \"'\", \"'\"))));\n        }","sourceCodeStart":153,"sourceCodeEnd":189,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/service/FileSystemOwnershipCheck.java#L153-L189","documentation":"Part of Cassandra's filesystem ownership verification: while walking up the data directory tree looking for the .cassandra/ownership (fs ownership) properties file, an exception occurred reading a file that was found. The check cannot complete, so startup/attach fails with ERR_WRONG_DISK_STATE.","triggerScenarios":"Calling executeAndFail/execute during startup with fs ownership checking enabled, when an ownership marker file exists under a data directory but opening/loading its Properties throws an I/O error (permissions, corrupt file, unreadable path).","commonSituations":"Ownership file has wrong file permissions (not readable by the cassandra user); the file is corrupt or truncated after a crash or bad sync; the file is on a mount that became unavailable; file copied with incorrect ownership.","solutions":["Fix permissions/ownership of the .cassandra/ownership file so the Cassandra process can read it (`chown cassandra:cassandra …; chmod 644 …)","Regenerate the ownership file (re-run the ownership initialization tooling / remove the corrupt file and recreate it) and restart","Verify the data directories and any network mounts are mounted and readable before starting Cassandra"],"exampleFix":"// before\ncassandra@cassandra /mnt/data/.cassandra/ownership  (owned by root, mode 600)\n// after\nsudo chown cassandra:cassandra /mnt/data/.cassandra/ownership && sudo chmod 644 /mnt/data/.cassandra/ownership","handlingStrategy":"try-catch","validationCode":"File f = new File(dataDir, \".cassandra/ownership\");\nif (f.exists()) {\n    try (FileReader r = new FileReader(f)) { new Properties().load(r); }\n    catch (IOException e) { throw new IllegalStateException(\"Ownership file unreadable: \" + f, e); }\n}","typeGuard":"static boolean ownershipFileReadable(Path p) {\n    try (var in = Files.newInputStream(p)) { in.read(); return true; }\n    catch (IOException e) { return false; }\n}","tryCatchPattern":"try {\n    FileSystemOwnershipCheck.executeAndFail(...);\n} catch (FileSystemOwnershipcheck.FileSystemOwnershipException e) {\n    if (e.getCode() == FileSystemOwnershipcheck.ErrorCode.READ_EXCEPTION) {\n        // fix permissions / regenerate ownership file, then restart\n    } else throw e;\n}","preventionTips":["Ensure the cassandra OS user can read every .cassandra/ownership file on all volumes","Include ownership files in consistent backup/restore procedures to avoid corruption","Check mounts (and network filesystem availability) in startup scripts before launching Cassandra","Avoid hand-editing the ownership properties file"],"tags":["filesystem","ownership","startup","io"],"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-17T15:17:12.973Z"}