pentaho/pentaho-kettle · error · KettleException

Errors encountered (first 10): ...

Error message

Errors encountered (first 10): ...

What it means

When error handling is enabled and a batch insert fails, the step collects up to the first 10 individual exceptions from the KettleDatabaseBatchException and rethrows them as a single KettleException summarizing the batch failure. This is the aggregated report of which rows/statements in the batch failed.

Solutions

  1. Parse the listed messages to identify and fix the offending rows in the source data.
  2. Reduce commit size so fewer rows fail per batch and error rows are more precisely identified.
  3. Disable batch mode to get exact per-row error handling and use the error hop to route bad rows.
  4. Add data-cleansing steps (dedupe, type validation) upstream.

Example fix

// before: batch mode + error handling, 10 rows with duplicate PKs fail together
// after: uncheck 'Use batch update' so failing rows go individually to the error hop
Defensive patterns

Strategy: try-catch

Validate before calling

// Validate rows before batch insert to avoid multi-row batch failures
for ( Object[] row : rows ) { validateRowAgainstSchema( row, tableSchema ); }

Try / catch

try {
  writeToTable( row );
} catch ( KettleException e ) {
  if ( e.getMessage().startsWith( "Errors encountered (first 10)" ) ) {
    for ( String line : e.getMessage().split( Const.CR ) ) logFailedRow( line );
    // replay failing rows individually for precise error handling
  }
}

Prevention

When it happens

Trigger: A KettleDatabaseBatchException is caught, getStepMeta().isDoingErrorHandling() is true, batchProblem is set, and the step builds a message with the first 10 exceptions from be.getExceptionsList() before rethrowing.

Common situations: Batch insert with multiple bad rows (duplicate keys, constraint violations, truncations); error handling configured but data quality issues present; commit size large so many rows fail per batch.

Related errors


AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13). Data as JSON: /api/errors/e9611b0bf0516238. Report an issue: GitHub.

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/tableoutput/TableOutput.java:346

      updateCounts = be.getUpdateCounts();
      exceptionsList = be.getExceptionsList();

      if ( getStepMeta().isDoingErrorHandling() ) {
        data.db.clearBatch( insertStatement );
        data.db.commit( true );
      } else {
        data.db.clearBatch( insertStatement );
        data.db.rollback();
        StringBuilder msg = new StringBuilder( "Error batch inserting rows into table [" + tableName + "]." );
        msg.append( Const.CR );
        msg.append( "Errors encountered (first 10):" ).append( Const.CR );
        for ( int x = 0; x < be.getExceptionsList().size() && x < 10; x++ ) {
          Exception exception = be.getExceptionsList().get( x );
          if ( exception.getMessage() != null ) {
            msg.append( exception.getMessage() ).append( Const.CR );
          }
        }
        throw new KettleException( msg.toString(), be );
      }
    } catch ( KettleDatabaseException dbe ) {
      if ( getStepMeta().isDoingErrorHandling() ) {
        if ( isRowLevel() ) {
          logRowlevel( "Written row to error handling : " + getInputRowMeta().getString( r ) );
        }

        if ( data.useSafePoints ) {
          data.db.rollback( data.savepoint );
          if ( data.releaseSavepoint ) {
            data.db.releaseSavepoint( data.savepoint );
          }
          // data.db.commit(true); // force a commit on the connection too.
        }

        sendToErrorRow = true;
        errorMessage = dbe.toString();
      } else {

View on GitHub (pinned to f3058517a1)