{"record":{"id":"983e5cf73a7cef6a","repo":"pentaho/pentaho-kettle","slug":"unable-to-create-the-database-cache","errorCode":null,"errorMessage":"Unable to create the database cache: ","messagePattern":"Unable to create the database cache: ","errorType":"exception","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/DBCache.java","lineNumber":218,"sourceCode":"    } catch ( Exception e ) {\n      throw new KettleFileException( \"Couldn't write to the database cache\", e );\n    }\n  }\n\n  /**\n   * Create the database cache instance by loading it from disk\n   *\n   * @return the database cache instance.\n   */\n  @SuppressWarnings( \"squid:S00112\" )\n  public static DBCache getInstance() {\n    if ( dbCache != null ) {\n      return dbCache;\n    }\n    try {\n      dbCache = new DBCache();\n    } catch ( KettleFileException kfe ) {\n      throw new RuntimeException( \"Unable to create the database cache: \" + kfe.getMessage() );\n    }\n    return dbCache;\n  }\n\n}\n","sourceCodeStart":200,"sourceCodeEnd":224,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/DBCache.java#L200-L224","documentation":"DBCache.getInstance() lazily creates the singleton DBCache; the constructor may throw KettleFileException (e.g. corrupt cache file). getInstance converts this into a RuntimeException 'Unable to create the database cache: <message>' because a static factory cannot declare checked exceptions. Callers see an unchecked failure whenever the cache cannot be initialized from disk.","triggerScenarios":"First call to DBCache.getInstance() in a JVM where the persisted db.cache file is unreadable/corrupt (see error 85), causing the constructor's KettleFileException to be re-thrown as RuntimeException.","commonSituations":"Upgraded Kettle reading an old-format db.cache; corrupted cache file after a crash; read-permission issues on the cache file at first use of the database cache.","solutions":["Delete the corrupt db.cache file so a fresh one is created on next startup","Wrap the first getInstance() call in try-catch and degrade gracefully (run without the DB cache)","Check that the Kettle system/user directory is readable by the process user"],"exampleFix":"// before\nDBCache dbCache = DBCache.getInstance(); // RuntimeException if cache corrupt\n// after\nDBCache dbCache;\ntry { dbCache = DBCache.getInstance(); }\ncatch (RuntimeException e) { log.logError(\"DB cache unavailable, continuing without it: \" + e.getMessage()); dbCache = null; }","handlingStrategy":"try-catch","validationCode":"File cacheFile = new File(cachePath);\nif (cacheFile.exists() && !cacheFile.canRead()) { cacheFile.delete(); } // rebuild on first use","typeGuard":null,"tryCatchPattern":"try { DBCache dbCache = DBCache.getInstance(); } catch (RuntimeException e) { log.error(\"DB cache init failed: \" + e.getMessage()); /* proceed without cache or rethrow */ }","preventionTips":["Clear db.cache after upgrades or crashes","Ensure the user directory is readable before starting Kettle","Wrap early getInstance() calls so a corrupt cache degrades instead of crashing startup"],"tags":["cache","singleton","file-read","pentaho-kettle"],"backgroundTag":"module-init-failed","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}