{"record":{"id":"aa316490d90d2eb9","repo":"pentaho/pentaho-kettle","slug":"trans-exception-unabletowritemetricsinformationtologtable","errorCode":null,"errorMessage":"Trans.Exception.UnableToWriteMetricsInformationToLogTable","messagePattern":"Trans\\.Exception\\.UnableToWriteMetricsInformationToLogTable","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/Trans.java","lineNumber":2756,"sourceCode":"\n        Map<String, MetricsSnapshotInterface> snapshotMap =\n          MetricsRegistry.getInstance().getSnapshotMaps().get( logChannelId );\n        if ( snapshotMap != null ) {\n          synchronized ( snapshotMap ) {\n            Iterator<MetricsSnapshotInterface> iterator = snapshotMap.values().iterator();\n            while ( iterator.hasNext() ) {\n              MetricsSnapshotInterface snapshot = iterator.next();\n              db.writeLogRecord( metricsLogTable, LogStatus.START, new LoggingMetric( batchId, snapshot ), null );\n            }\n          }\n        }\n      }\n\n      // Also time-out the log records in here...\n      //\n      db.cleanupLogRecords( metricsLogTable, getName() );\n    } catch ( Exception e ) {\n      throw new KettleException( BaseMessages.getString( PKG,\n        \"Trans.Exception.UnableToWriteMetricsInformationToLogTable\" ), e );\n    } finally {\n      disconnectDb( db );\n    }\n  }\n\n  private void disconnectDb( Database db ) throws KettleDatabaseException {\n    if ( db == null ) {\n      return;\n    }\n    if ( !db.isAutoCommit() ) {\n      db.commit( true );\n    }\n    db.close();\n  }\n\n  /**\n   * Gets the result of the transformation. The Result object contains such measures as the number of errors, number of","sourceCodeStart":2738,"sourceCodeEnd":2774,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/Trans.java#L2738-L2774","documentation":"Thrown by Trans.writeMetricsLogInformation() when writing transformation metric records to the configured performance/metrics log table fails, or when its cleanupLogRecords() call fails. Metrics logging records run/status metrics per execution; an error there is wrapped as UnableToWriteMetricsInformationToLogTable.","triggerScenarios":"writeMetricsLogInformation() writes metric rows into the metrics log table (typically at begin/end processing) and then db.cleanupLogRecords(metricsLogTable, getName()); any Exception is wrapped in this message.","commonSituations":"Performance metrics log table configured but never created; schema drift after PDI upgrade; metrics table grew too large causing write timeouts/lock contention; DB connection dropped during the run.","solutions":["Inspect the cause to find the failing statement and fix the underlying database error.","Create or recreate the metrics log table using the DDL generated in the Log tab.","Archive/purge old metrics rows to reduce lock contention and timeouts on very large tables.","Grant the log user INSERT/DELETE privileges on the metrics log table, or disable metrics logging if unused."],"exampleFix":"// before: metrics_log missing\nKettleException: UnableToWriteMetricsInformationToLogTable\n// after: run generated DDL for metrics_log from the Log tab, then re-run","handlingStrategy":"validation","validationCode":"// Confirm the metrics log table exists and is not oversized before the run\nDatabase db = new Database(trans, metricsLogTable.getDatabaseMeta());\ndb.connect();\nif (!db.checkTableExists(\"METRICS_LOG\")) throw new IllegalStateException(\"METRICS_LOG missing\");","typeGuard":null,"tryCatchPattern":"try {\n  trans.waitUntilFinished();\n} catch (KettleException e) {\n  log.error(\"Metrics logging failed; check METRICS_LOG table and connection\", e.getCause());\n}","preventionTips":["Schedule periodic purges/archives of METRICS_LOG to keep writes fast.","Recreate metrics log tables after PDI upgrades to absorb schema changes.","Disable metrics logging in environments where it is not consumed."],"tags":["database","logging","metrics","transformation"],"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"}