apache/cassandra · warning
Failed to delete {}
Error message
Failed to delete {} What it means
When saving a cache (key cache / row cache), AutoSavingCache.deleteOldCacheFiles cleans up stale files in the saved_caches directory that match this cache's name or type. If File.tryDelete() fails to unlink such a file, this warning is logged and the cleaner continues. Stale file remains on disk but cache save/load still proceeds.
Source
Thrown at src/java/org/apache/cassandra/cache/AutoSavingCache.java:453
private void deleteOldCacheFiles()
{
File savedCachesDir = new File(DatabaseDescriptor.getSavedCachesLocation());
assert savedCachesDir.exists() && savedCachesDir.isDirectory();
File[] files = savedCachesDir.tryList();
if (files != null)
{
String cacheNameFormat = String.format("%s-%s.db", cacheType.toString(), CURRENT_VERSION);
for (File file : files)
{
if (!file.isFile())
continue; // someone's been messing with our directory. naughty!
if (file.name().endsWith(cacheNameFormat)
|| file.name().endsWith(cacheType.toString()))
{
if (!file.tryDelete())
logger.warn("Failed to delete {}", file.absolutePath());
}
}
}
else
{
logger.warn("Could not list files in {}", savedCachesDir);
}
}
public boolean isGlobal()
{
return false;
}
}
/**
* A base cache serializer that is used to serialize/deserialize a cache to/from disk.
* <p>View on GitHub (pinned to 88fd0f6a0e)
Solutions
- Stop Cassandra and manually delete stale files in the saved_caches directory (they are disposable caches, safe to remove while the node is down).
- Fix ownership/permissions: chown -R cassandra:cassandra /var/lib/cassandra/saved_caches.
- Check disk space and mount status (df -h, mount) — a full or read-only filesystem makes unlink fail.
- Ensure no external processes (backups, antivirus) hold those files open when Cassandra runs.
Example fix
// before (bash): fix leftover root-owned cache files sudo rm -f /var/lib/cassandra/saved_caches/* sudo chown -R cassandra:cassandra /var/lib/cassandra/saved_caches
Defensive patterns
Strategy: fallback
Validate before calling
// Pre-flight check on deployment (bash) test -w /var/lib/cassandra/saved_caches || echo "saved_caches not writable by $(id -un)" find /var/lib/cassandra/saved_caches ! -user cassandra -ls # detect foreign-owned files
Prevention
- Always start Cassandra under the same service user; clean up after manual/root runs.
- Exclude saved_caches from backup tools that hold files open.
- Keep the cache directory on a local, writable volume (not NFS).
- Manually clear saved_caches during planned restarts if warnings accumulate.
When it happens
Trigger: A file in saved_caches whose name ends with the cache's name format or cache type cannot be deleted — typically because the file is open by another process, or the Cassandra process lacks write/remove permission on the directory/file.
Common situations: Running Cassandra as a different user after a manual start (root-created files left behind); backup agents or file watchers holding files open; read-only or full filesystem; NFS-mounted saved_caches directories.
Related errors
- Could not list files in {}
- Unable check disk space in '%s'. Perhaps the Cassandra user
- ; unable to start server
- Unable to create directory " + dir
- Dictionary file %s is not readable.
AI-assisted analysis of apache/cassandra@88fd0f6a0e (2026-09-10).
Data as JSON: /api/errors/b2dadb27fc21db56.
Report an issue: GitHub.