apache/cassandra · error · RuntimeException

Tried to hard link to file that does not exist

Error message

Tried to hard link to file that does not exist %s

What it means

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.

Solutions

  1. Verify the source path exists (from.exists()) before linking and correct the configured directory.
  2. Check whether another process/compaction deleted the source and rerun the operation.
  3. If the source is expected but absent, recreate the file (e.g. re-flush) before linking.

Example fix

// before
FileUtils.createHardLink(segmentPath, archivePath);

// after
File src = new File(segmentPath);
if (!src.exists())
    throw new IllegalStateException("Commitlog segment missing: " + segmentPath);
FileUtils.createHardLink(src, new File(archivePath));
Defensive patterns

Strategy: validation

Validate before calling

if (!new File(from).exists()) throw new IllegalStateException("source missing: " + from);

Type guard

boolean hardlinkSourceReady(File from) { return from != null && from.exists(); }

Try / catch

try { FileUtils.createHardLink(from, to); } catch (RuntimeException e) { if (e.getMessage().contains("does not exist")) { /* recreate or reconfigure */ } }

Prevention

When it happens

Trigger: 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).

Common situations: 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.

Understand the failure class

Background: "File not found" and ENOENT errors: why libraries can't find a file that should exist — this error's family across 50 libraries.

Related errors


AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10). Data as JSON: /api/errors/4b09455ea8d062dc. Report an issue: GitHub.

Appendix: source

Thrown at src/java/org/apache/cassandra/io/util/FileUtils.java:137

    public static File createDeletableTempFile(String prefix, String suffix)
    {
        File f = createTempFile(prefix, suffix, getTempDir());
        f.deleteOnExit();
        return f;
    }

    public static void createHardLink(String from, String to)
    {
        createHardLink(new File(from), new File(to));
    }

    public static void createHardLink(File from, File to)
    {
        if (to.exists())
            throw new DuplicateHardlinkException("Tried to create duplicate hard link from " + from + " to " + to);
        if (!from.exists())
            throw new RuntimeException("Tried to hard link to file that does not exist " + from);

        try
        {
            Files.createLink(to.toPath(), from.toPath());
        }
        catch (IOException e)
        {
            throw new FSWriteError(e, to);
        }
    }

    public static void createHardLinkWithConfirm(String from, String to)
    {
        createHardLinkWithConfirm(new File(from), new File(to));
    }

    public static void createHardLinkWithConfirm(File from, File to)
    {

View on GitHub (pinned to 88fd0f6a0e)