{"record":{"id":"feb0a358e885f0ec","repo":"bumptech/glide","slug":"failed-to-find-entries-to-evict","errorCode":null,"errorMessage":"Failed to find entries to evict.","messagePattern":"Failed to find entries to evict\\.","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/EvictionManager.java","lineNumber":133,"sourceCode":"      Log.d(TAG, \"Starting eviction on work thread\");\n    }\n\n    int successfullyDeletedCount = 0;\n    int triedToDeleteEntries = staleEntriesKeys.size();\n    if (!staleEntriesKeys.isEmpty()) {\n      successfullyDeletedCount += diskCache.delete(staleEntriesKeys).size();\n    }\n\n    long targetSize = maximumSizeBytes - evictionSlopBytes;\n    if (isEvictionRequired(maximumSizeBytes)) {\n      long bytesToEvict = journal.getCurrentSizeBytes() - targetSize;\n      List<String> leastRecentlyUsedKeys = journal.getLeastRecentlyUsed(bytesToEvict);\n      triedToDeleteEntries += leastRecentlyUsedKeys.size();\n      successfullyDeletedCount += diskCache.delete(leastRecentlyUsedKeys).size();\n    }\n\n    if (triedToDeleteEntries == 0) {\n      throw new IllegalStateException(\"Failed to find entries to evict.\");\n    }\n\n    if (LOG_DEBUG) {\n      Log.d(\n          TAG,\n          \"Ran eviction\"\n              + \", tried to delete: \"\n              + triedToDeleteEntries\n              + \" entries\"\n              + \", actually deleted: \"\n              + successfullyDeletedCount\n              + \" entries\"\n              + \", target journal : \"\n              + targetSize\n              + \", journal size: \"\n              + journal.getCurrentSizeBytes()\n              + \", file size: \"\n              + fileSystem.getDirectorySize(cacheDirectory));","sourceCodeStart":115,"sourceCodeEnd":151,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/EvictionManager.java#L115-L151","documentation":"Thrown by EvictionManager.evictOnWorkThread() when eviction was deemed necessary (it passed the early-return) but no entries were found to delete: both stale entries and least-recently-used keys came back empty, leaving triedToDeleteEntries == 0. The cache believes it is over capacity yet the journal offers nothing to remove.","triggerScenarios":"isEvictionRequired(maximumSizeBytes) is true so the method proceeds, but journal.getStaleEntries() returns empty and journal.getLeastRecentlyUsed(bytesToEvict) also returns empty, so nothing was attempted for deletion.","commonSituations":"Journal/file size desynchronization: the recorded current size exceeds the limit but the underlying entries were already removed (partial delete earlier), or a pending-delete state hides entries from the LRU query. Indicates the journal bookkeeping drifted from real on-disk content.","solutions":["Clear the disk cache to reset the journal to a consistent state and let it rebuild.","Check for a prior crash or partial write that left the journal and files out of sync (see recovery manager logs).","Verify the cache directory is not being modified by another process or cleaned externally while Glide runs.","Upgrade the sqljournaldiskcache integration, as size-tracking fixes may address the desync.","If reproducible, capture the journal size vs actual directory size from logs to file a bug."],"exampleFix":"// before: cache left in inconsistent state, eviction throws\n\n// after: clear and reinitialize the cache\ndiskCache.clear() // or: delete the cache directory and let Glide recreate it","handlingStrategy":"fallback","validationCode":"// Before relying on the cache, verify eviction can proceed by checking journal health\n// is non-trivial; the practical guard is to clear the cache on failure.","typeGuard":null,"tryCatchPattern":"try {\n  diskCache.put(key, data)\n} catch (e: IllegalStateException) {\n  if (e.message?.contains(\"Failed to find entries to evict\") == true) {\n    diskCache.clear() // reset journal and retry once\n    diskCache.put(key, data)\n  } else throw e\n}","preventionTips":["Clear the disk cache when eviction errors recur to restore consistency.","Avoid external modification of cache files while Glide runs.","Keep the integration updated for size-accounting fixes."],"tags":["sqljournaldiskcache","integration","eviction","journal","corruption","runtime"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}