{"record":{"id":"630fdf06c0bc25c3","repo":"pentaho/pentaho-kettle","slug":"unable-to-end-processing-by-writing-log-record-to-table","errorCode":null,"errorMessage":"Unable to end processing by writing log record to table {tableName}","messagePattern":"Unable to end processing by writing log record to table (.+?)","errorType":"exception","errorClass":"KettleJobException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/job/Job.java","lineNumber":1219,"sourceCode":"    KettleDatabaseException {\n    boolean cleanLogRecords = status.equals( LogStatus.END );\n    String tableName = jobLogTable.getActualTableName();\n    DatabaseMeta logcon = jobLogTable.getDatabaseMeta();\n\n    Database ldb = createDataBase( logcon );\n    ldb.shareVariablesWith( this );\n    try {\n      ldb.connect();\n      ldb.setCommit( logCommitSize );\n      ldb.writeLogRecord( jobLogTable, status, this, null );\n\n      if ( cleanLogRecords ) {\n        ldb.cleanupLogRecords( jobLogTable, getJobname() );\n      }\n\n    } catch ( KettleDatabaseException dbe ) {\n      addErrors( 1 );\n      throw new KettleJobException( \"Unable to end processing by writing log record to table \" + tableName, dbe );\n    } finally {\n      if ( !ldb.isAutoCommit() ) {\n        ldb.commitLog( true, jobLogTable );\n      }\n      ldb.close();\n    }\n  }\n\n  /**\n   * Write log channel information.\n   *\n   * @throws KettleException\n   *           the kettle exception\n   */\n  protected void writeLogChannelInformation() throws KettleException {\n    Database db = null;\n    ChannelLogTable channelLogTable = jobMeta.getChannelLogTable();\n","sourceCodeStart":1201,"sourceCodeEnd":1237,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/job/Job.java#L1201-L1237","documentation":"Thrown at the end of job processing when updating the log table with the final (END) record raises a KettleDatabaseException. An error is added to the result and the exception is chained; commitLog and close still run in the finally block.","triggerScenarios":"The final log-record write (or cleanupLogRecords) against the job log table fails: connection lost, table missing/locked, schema drift, or constraint failure during the END-status update.","commonSituations":"Long-running jobs outliving DB connection idle timeouts; DB maintenance/locks during job execution; log table altered externally; network partition at job completion.","solutions":["Read the chained KettleDatabaseException for the exact SQL error","Increase connection idle/keepalive timeouts for long jobs","Verify job log table schema and privileges","Check for DB locks or maintenance windows coinciding with job end"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// guard against long-job connection drops\nif (expectedJobDurationMinutes > 30) {\n  configureConnectionKeepalive(logDbConnection, 60); // seconds\n}","typeGuard":null,"tryCatchPattern":"try {\n  job.run();\n} catch (KettleJobException e) {\n  if (e.getMessage().contains(\"Unable to end processing by writing log record\")) {\n    Throwable dbe = e.getCause();\n    if (dbe != null && dbe.getMessage().contains(\"connection\")) {\n      // reconnect and finalize log manually or retry the job\n    }\n    log.error(\"Job END log write failed\", dbe);\n  }\n}","preventionTips":["Enable keepalive/idle-timeout tuning for long jobs","Avoid DB maintenance windows overlapping job schedules","Keep log tables small via periodic cleanupLogRecords"],"tags":["database","logging","connection-timeout"],"backgroundTag":"database-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"}