{"record":{"id":"29a72d27229a722a","repo":"bumptech/glide","slug":"failed-to-delete-entry-key-size-actuall","errorCode":null,"errorMessage":"Failed to delete entry, key: {}, size: {}, actually deleted: {}","messagePattern":"Failed to delete entry, key: (.+?), size: (.+?), actually deleted: (.+?)","errorType":"exception","errorClass":"IllegalStateException","httpStatus":null,"severity":"error","filePath":"integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/Journal.java","lineNumber":307,"sourceCode":"    SizeSQLiteTransactionListener sizeListener = sizeJournal.prepareSizeTransaction();\n    db.beginTransactionWithListenerNonExclusive(sizeListener);\n    try {\n      // We may be asked to abort a put that failed before the entry was updated, so we will\n      // occasionally fail to find the entry here.\n      boolean isKeyPresent = 0 != containsKeyStatement.simpleQueryForLong();\n      if (!isKeyPresent) {\n        return;\n      }\n      long entrySize;\n      try {\n        entrySize = selectNotPendingSizeStatement.simpleQueryForLong();\n      } catch (SQLiteDoneException e) {\n        // No row found for this key that is not pending delete.\n        entrySize = 0;\n      }\n      int deleted = deleteEntryStatement.executeUpdateDelete();\n      if (deleted != 1) {\n        throw new IllegalStateException(\n            \"Failed to delete entry\"\n                + \", key: \"\n                + key\n                + \", size: \"\n                + entrySize\n                + \", actually deleted: \"\n                + deleted);\n      } else {\n        // If the item is pending delete its size is 0 here - skip decrementing.\n        if (entrySize != 0) {\n          sizeJournal.decrementSizeInTransaction(sizeListener, entrySize);\n        }\n      }\n      db.setTransactionSuccessful();\n    } finally {\n      db.endTransaction();\n      statementPool.offer(CONTAINS_KEY_SQL, containsKeyStatement);\n      statementPool.offer(SELECT_ENTRY_SIZE_NOT_PENDING_SQL, selectNotPendingSizeStatement);","sourceCodeStart":289,"sourceCodeEnd":325,"githubUrl":"https://github.com/bumptech/glide/blob/eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a/integration/sqljournaldiskcache/src/main/java/com/bumptech/glide/integration/sqljournaldiskcache/Journal.java#L289-L325","documentation":"Thrown by Journal during a single-key delete when executeUpdateDelete() does not delete exactly one row. The journal expects the targeted key to resolve to exactly one deletable row; a result other than 1 means the row was absent (or duplicated), breaking the size-accounting invariant.","triggerScenarios":"selectNotPendingSizeStatement confirms the key is present (isKeyPresent true), but the subsequent deleteEntryStatement.executeUpdateDelete() returns a count != 1, so the guard at line 307 fires.","commonSituations":"A race where the row was removed between the presence check and the delete; duplicated rows from a prior partial write; concurrent eviction and put operating on the same key; a journal corruption causing the presence query and delete to disagree.","solutions":["Clear the cache to reset the journal and eliminate any duplicated/inconsistent rows.","Confirm only one EvictionManager/disk-cache instance operates on the directory concurrently.","Upgrade the sqljournaldiskcache integration for concurrency fixes around delete.","If reproducible, capture the key, expected size, and actual deleted count from the message and file a bug."],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n  diskCache.delete(key)\n} catch (e: IllegalStateException) {\n  if (e.message?.contains(\"Failed to delete entry\") == true) {\n    // row already gone or duplicated; clear to reset consistent state\n    diskCache.clear()\n  } else throw e\n}","preventionTips":["Ensure only one cache instance operates on a directory.","Clear the cache if delete-count mismatches recur (signals duplicated/inconsistent rows).","Keep the integration updated for concurrency fixes."],"tags":["sqljournaldiskcache","integration","journal","delete","race-condition","corruption","runtime"],"backgroundTag":null,"analyzedSha":"eb14a895d8f866e6a08c3e19d50ea3bd2c12c20a","analyzedAt":"2026-08-14T01:43:54.821Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}