{"record":{"id":"c189e7423523d3a9","repo":"apache/cassandra","slug":"could-not-list-files-in","errorCode":null,"errorMessage":"Could not list files in {}","messagePattern":"Could not list files in (.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"src/java/org/apache/cassandra/cache/AutoSavingCache.java","lineNumber":459,"sourceCode":"            if (files != null)\n            {\n                String cacheNameFormat = String.format(\"%s-%s.db\", cacheType.toString(), CURRENT_VERSION);\n                for (File file : files)\n                {\n                    if (!file.isFile())\n                        continue; // someone's been messing with our directory.  naughty!\n\n                    if (file.name().endsWith(cacheNameFormat)\n                     || file.name().endsWith(cacheType.toString()))\n                    {\n                        if (!file.tryDelete())\n                            logger.warn(\"Failed to delete {}\", file.absolutePath());\n                    }\n                }\n            }\n            else\n            {\n                logger.warn(\"Could not list files in {}\", savedCachesDir);\n            }\n        }\n\n        public boolean isGlobal()\n        {\n            return false;\n        }\n    }\n\n    /**\n     * A base cache serializer that is used to serialize/deserialize a cache to/from disk.\n     * <p>\n     * It expects the following lifecycle:\n     * Serializations:\n     * 1. {@link #serialize(CacheKey, DataOutputPlus, ColumnFamilyStore)} is called for each key in the cache.\n     * 2. {@link #serializeMetadata(DataOutputPlus)} is called to serialize any metadata.\n     * 3. {@link #cleanupAfterSerialize()} is called to clean up any resources allocated for serialization.\n     * <p>","sourceCodeStart":441,"sourceCodeEnd":477,"githubUrl":"https://github.com/apache/cassandra/blob/88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1/src/java/org/apache/cassandra/cache/AutoSavingCache.java#L441-L477","documentation":"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.","triggerScenarios":"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.","commonSituations":"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.","solutions":["Create the directory with correct ownership: mkdir -p <saved_caches_dir> && chown cassandra:cassandra <saved_caches_dir> && chmod 755 <saved_caches_dir>.","Verify cassandra.yaml's saved_caches location matches an existing, writable path.","Check filesystem mount/health (df -h, mount, dmesg) and fix a full or read-only volume.","Restart Cassandra after fixing; stale cache files are safe to delete while the node is down."],"exampleFix":"// before (cassandra.yaml) pointing to a missing dir\nsaved_caches_directory: /var/lib/cassandra/saved_caches  # directory deleted\n// after (bash)\nmkdir -p /var/lib/cassandra/saved_caches && chown cassandra:cassandra /var/lib/cassandra/saved_caches","handlingStrategy":"validation","validationCode":"// Pre-flight (bash)\nDIR=$(grep saved_caches_directory /etc/cassandra/cassandra.yaml | awk '{print $2}')\ntest -d \"$DIR\" && test -w \"$DIR\" || { mkdir -p \"$DIR\"; chown cassandra:cassandra \"$DIR\"; }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Verify saved_caches_directory exists and is writable after any path/cassandra.yaml change.","Include directory creation and ownership in node provisioning/automation.","Check mount health when the data volume is shared or remoted.","After changing the service user, chown the whole Cassandra data tree."],"tags":["cache","filesystem","directory","permissions"],"backgroundTag":"directory-not-found","analyzedSha":"88fd0f6a0eaed8943f05ac9e8f947882b8ddc8f1","analyzedAt":"2026-09-10T07:29:22.284Z","contentChangedAt":"2026-09-10T07:29:22.284Z","schemaVersion":2},"datasetVersion":"2026-09-14T16:17:12.679Z"}