{"record":{"id":"fea0757bdf416d78","repo":"pentaho/pentaho-kettle","slug":"couldn-t-write-to-the-database-cache","errorCode":null,"errorMessage":"Couldn't write to the database cache","messagePattern":"Couldn't write to the database cache","errorType":"exception","errorClass":"KettleFileException","httpStatus":null,"severity":"error","filePath":"core/src/main/java/org/pentaho/di/core/DBCache.java","lineNumber":201,"sourceCode":"          for ( DBCacheEntry entry : cache.keySet() ) {\n            entry.write( dos );\n\n            // Save the corresponding row as well.\n            RowMetaInterface rowMeta = get( entry );\n            if ( rowMeta != null ) {\n              rowMeta.writeMeta( dos );\n              counter++;\n            } else {\n              throw new KettleFileException( \"The database cache contains an empty row. We can't save this!\" );\n            }\n          }\n          log.logDetailed( \"We wrote \" + counter + \" cached rows to the database cache!\" );\n        }\n      } else {\n        throw new KettleFileException( \"We can't write to the cache file: \" + filename );\n      }\n    } 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    }","sourceCodeStart":183,"sourceCodeEnd":219,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/core/src/main/java/org/pentaho/di/core/DBCache.java#L183-L219","documentation":"saveCache() wraps its entire write in a catch-all: after opening the file, writing entries, or throwing the earlier specific errors, any resulting Exception is re-thrown as KettleFileException 'Couldn't write to the database cache' with the original as cause. It is the generic failure path for persisting the DB cache to disk.","triggerScenarios":"IOException while writing cache entries to the open DataOutputStream (disk full, stream closed, file handle lost), or any of the inner specific KettleFileExceptions (empty row / non-writable file) being caught and re-wrapped by the outer catch.","commonSituations":"Disk full on the drive holding the cache file; file deleted/unlocked mid-write by another process; antivirus or backup software interfering with the cache file.","solutions":["Check the wrapped cause (getCause()) — usually an IOException; verify disk space and file availability","Make the cache write non-fatal for your use case (log and continue; the cache is an optimization)","Delete the cache file and let it rebuild; ensure only one Kettle process writes it"],"exampleFix":"// before\nDBCache.getInstance().savesCacheToDisk(); // RuntimeException on IO failure\n// after\ntry {\n  DBCache.getInstance().savesCacheToDisk();\n} catch (KettleFileException e) {\n  log.logMinimal(\"DB cache write skipped: \" + e.getMessage()); // cache is optional\n}","handlingStrategy":"try-catch","validationCode":"// Pre-check disk space and writability before saving\nFile f = new File(cacheFile); if (f.getParentFile().getUsableSpace() < MIN_FREE) { skipSave(); }","typeGuard":null,"tryCatchPattern":"try { cache.savesCacheToDisk(); } catch (KettleFileException e) { Throwable cause = e.getCause(); log.warn(\"DB cache write failed: \" + (cause != null ? cause.getMessage() : e.getMessage())); }","preventionTips":["Monitor free disk space on the cache directory","Exclude the cache file from concurrent antivirus/backup scans","Cache writes are best-effort — log and continue rather than failing the run"],"tags":["file-write","cache","io","pentaho-kettle"],"backgroundTag":"file-write-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"}