apache/cassandra · warning
Failed to remove hard link files
Error message
Failed to remove hard link files
What it means
ComponentContext manages hard links created for streamed sstable components and deletes them on close. deleteWithConfirm accumulates any failures; if the accumulated exception is non-null, close logs 'Failed to remove hard link files' as a warning. The links are typically already superseded; this signals leftover files consuming disk until manually removed.
Source
Thrown at src/java/org/apache/cassandra/db/streaming/ComponentContext.java:96
@SuppressWarnings("resource") // file channel will be closed by Caller
FileChannel channel = toTransfer.newReadChannel();
assert size == channel.size() : String.format("Entire sstable streaming expects %s file size to be %s but got %s.",
component, size, channel.size());
return channel;
}
@Override
public void close()
{
Throwable accumulate = null;
for (File file : hardLinks.values())
accumulate = FileUtils.deleteWithConfirm(file, accumulate);
hardLinks.clear();
if (accumulate != null)
logger.warn("Failed to remove hard link files", accumulate);
}
}
View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Manually delete leftover hard-link files from the streamed sstable directories after confirming no process uses them
- Check directory permissions for the Cassandra user on the data directories
- Look at the accumulated cause in the log to identify which file failed and why
- If on NFS/EBS-backed storage, verify the filesystem supports unlink semantics Cassandra expects
Defensive patterns
Strategy: try-catch
Validate before calling
// ensure Cassandra user owns data dirs and no stale processes hold files // ls -l on hardlink dirs; lsof +D <data_dir> before manual cleanup
Try / catch
try (ComponentContext ctx = new ComponentContext(...)) {
// use component
} // close() logs warning on delete failure; clean leftover files manually afterward Prevention
- Keep Cassandra data directories on local POSIX filesystems rather than NFS
- Ensure consistent ownership/permissions for the cassandra user
- After aborts, sweep for leftover hard-link files
- Watch disk usage so orphans don't accumulate
When it happens
Trigger: close() is called (stream writer aborted or completed) and one or more hard-linked files cannot be deleted — usually because another process holds them open, or a permission/IO error prevents removal.
Common situations: Files still open by a concurrent reader at close time; filesystem permission problems; NFS/EFS quirkiness where unlink of an open file behaves unexpectedly; disk errors.
Related errors
- Unable to hardlink from %s to %s
- Unable to delete storage-attached index component file {} du
- Exception thrown when cleaning up files to delete on exit, c
- Failed importing SSTables
- Unable to resolve canonical path for
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/5e745100d4f00a0a.
Report an issue: GitHub.