apache/cassandra · warning

Could not list files in {}

Error message

Could not list files in {}

What it means

deleteOldCacheFiles tries to list the saved_caches directory to purge stale cache files. If the directory listing itself fails (File[] listing returns null or throws), Cassandra logs this warning with the directory path and skips cleanup entirely. Cache save/load elsewhere may still work, but old files will accumulate.

Source

Thrown at src/java/org/apache/cassandra/cache/AutoSavingCache.java:459

            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>
     * It expects the following lifecycle:
     * Serializations:
     * 1. {@link #serialize(CacheKey, DataOutputPlus, ColumnFamilyStore)} is called for each key in the cache.
     * 2. {@link #serializeMetadata(DataOutputPlus)} is called to serialize any metadata.
     * 3. {@link #cleanupAfterSerialize()} is called to clean up any resources allocated for serialization.
     * <p>

View on GitHub (pinned to 88fd0f6a0e)

Solutions

  1. Create the directory with correct ownership: mkdir -p <saved_caches_dir> && chown cassandra:cassandra <saved_caches_dir> && chmod 755 <saved_caches_dir>.
  2. Verify cassandra.yaml's saved_caches location matches an existing, writable path.
  3. Check filesystem mount/health (df -h, mount, dmesg) and fix a full or read-only volume.
  4. Restart Cassandra after fixing; stale cache files are safe to delete while the node is down.

Example fix

// before (cassandra.yaml) pointing to a missing dir
saved_caches_directory: /var/lib/cassandra/saved_caches  # directory deleted
// after (bash)
mkdir -p /var/lib/cassandra/saved_caches && chown cassandra:cassandra /var/lib/cassandra/saved_caches
Defensive patterns

Strategy: validation

Validate before calling

// Pre-flight (bash)
DIR=$(grep saved_caches_directory /etc/cassandra/cassandra.yaml | awk '{print $2}')
test -d "$DIR" && test -w "$DIR" || { mkdir -p "$DIR"; chown cassandra:cassandra "$DIR"; }

Prevention

When it happens

Trigger: The saved_caches directory does not exist, is unreadable by the Cassandra process, or an I/O error occurs while listing it during a cache save triggered by periodic auto-save or shutdown.

Common situations: saved_caches path deleted or misconfigured in cassandra.yaml; wrong ownership after changing the service user; read-only or unmounted filesystem; directory on a failed/unavailable volume.

Related errors


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