{"record":{"id":"4b09455ea8d062dc","repo":"apache/cassandra","slug":"tried-to-hard-link-to-file-that-does-not-exist-s","errorCode":null,"errorMessage":"Tried to hard link to file that does not exist %s","messagePattern":"Tried to hard link to file that does not exist (.+?)","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"src/java/org/apache/cassandra/io/util/FileUtils.java","lineNumber":137,"sourceCode":"\n    public static File createDeletableTempFile(String prefix, String suffix)\n    {\n        File f = createTempFile(prefix, suffix, getTempDir());\n        f.deleteOnExit();\n        return f;\n    }\n\n    public static void createHardLink(String from, String to)\n    {\n        createHardLink(new File(from), new File(to));\n    }\n\n    public static void createHardLink(File from, File to)\n    {\n        if (to.exists())\n            throw new DuplicateHardlinkException(\"Tried to create duplicate hard link from \" + from + \" to \" + to);\n        if (!from.exists())\n            throw new RuntimeException(\"Tried to hard link to file that does not exist \" + from);\n\n        try\n        {\n            Files.createLink(to.toPath(), from.toPath());\n        }\n        catch (IOException e)\n        {\n            throw new FSWriteError(e, to);\n        }\n    }\n\n    public static void createHardLinkWithConfirm(String from, String to)\n    {\n        createHardLinkWithConfirm(new File(from), new File(to));\n    }\n\n    public static void createHardLinkWithConfirm(File from, File to)\n    {","sourceCodeStart":119,"sourceCodeEnd":155,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/io/util/FileUtils.java#L119-L155","documentation":"createHardLink(File, File) throws RuntimeException when the source file `from` does not exist. A hard link cannot be created to a missing file, so the method fails fast with a descriptive message naming the missing source. It signals that earlier pipeline steps (writing/flushing the file) did not complete or the file was deleted.","triggerScenarios":"Calling FileUtils.createHardLink(from, to) with a non-existent `from` path — e.g. hardlinking a flushed memtable sstable or commitlog segment that was already removed, or a wrong path (typo, wrong data directory).","commonSituations":"Commitlog archiver pointing at a directory other than the live commitlog directory; race with cleanup/background deletion of source files; misconfigured data_file_directories or snapshot path.","solutions":["Verify the source path exists (from.exists()) before linking and correct the configured directory.","Check whether another process/compaction deleted the source and rerun the operation.","If the source is expected but absent, recreate the file (e.g. re-flush) before linking."],"exampleFix":"// before\nFileUtils.createHardLink(segmentPath, archivePath);\n\n// after\nFile src = new File(segmentPath);\nif (!src.exists())\n    throw new IllegalStateException(\"Commitlog segment missing: \" + segmentPath);\nFileUtils.createHardLink(src, new File(archivePath));","handlingStrategy":"validation","validationCode":"if (!new File(from).exists()) throw new IllegalStateException(\"source missing: \" + from);","typeGuard":"boolean hardlinkSourceReady(File from) { return from != null && from.exists(); }","tryCatchPattern":"try { FileUtils.createHardLink(from, to); } catch (RuntimeException e) { if (e.getMessage().contains(\"does not exist\")) { /* recreate or reconfigure */ } }","preventionTips":["Confirm source files are fully written/flushed before linking.","Verify commitlog/data directory configuration matches actual locations.","Handle concurrent cleanup that may delete sources mid-pipeline."],"tags":["io","hardlink","file-not-found"],"backgroundTag":"file-not-found","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"}