pentaho/pentaho-kettle · error · KettleDatabaseBatchException

SynchronizeAfterMerge.Error.UpdatingBatch

Error message

SynchronizeAfterMerge.Error.UpdatingBatch

What it means

Thrown in lookupValues() when the step is in batch mode and executing the JDBC batch (insert/update/delete Statement.executeBatch()) fails with a SQLException. Database.createKettleDatabaseBatchException wraps the SQL error in a KettleDatabaseBatchException using this message so all batch errors are reported together.

Solutions

  1. Read the wrapped exceptionsList in the KettleDatabaseBatchException to find the real SQLException cause (constraint, syntax, connection).
  2. Disable batch mode in the step ('Use batch update' off) to get per-row errors that identify the offending row.
  3. Fix the underlying data/constraint problem revealed by the cause (duplicate keys, oversized values).
  4. Check DB connectivity/network stability and reduce commit/batch size to limit rework on failure.
Defensive patterns

Strategy: try-catch

Validate before calling

// Pre-check for constraint-prone data before the step
if (duplicateKeysExist(rows)) { throw new ValidationException("Duplicate keys would violate PK in batch"); }

Try / catch

catch (KettleDatabaseBatchException be) {
  for (Exception ex : be.getExceptionsList()) {
    logError("Batch item failed: " + ex.getMessage());
  }
}

Prevention

When it happens

Trigger: data.batchMode is true, batch counter reaches the commit size, executeBatch()/commit() on the insert, update, or delete statement throws SQLException (constraint violation, syntax error, connection loss, etc.).

Common situations: Unique/PK constraint violated inside a batch; target column too small for data; database connection dropped mid-batch; SQL dialect issue with generated INSERT/UPDATE/DELETE; deadlock with another session.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/trans/steps/synchronizeaftermerge/SynchronizeAfterMerge.java:377

        //
        if ( commitCounter > 0 && ( commitCounter % data.commitSize ) == 0 ) {
          if ( data.batchMode ) {
            try {
              if ( performInsert ) {
                data.insertStatement.executeBatch();
                data.db.commit();
                data.insertStatement.clearBatch();
              } else if ( performUpdate ) {
                data.updateStatement.executeBatch();
                data.db.commit();
                data.updateStatement.clearBatch();
              } else if ( performDelete ) {
                data.deleteStatement.executeBatch();
                data.db.commit();
                data.deleteStatement.clearBatch();
              }
            } catch ( SQLException ex ) {
              throw Database.createKettleDatabaseBatchException( BaseMessages.getString( PKG,
                "SynchronizeAfterMerge.Error.UpdatingBatch" ), ex );
            } catch ( Exception ex ) {
              throw new KettleDatabaseException( "Unexpected error inserting row", ex );
            }
          } else {
            // insertRow normal commit
            data.db.commit();
          }
          // Clear the batch/commit counter...
          //
          data.commitCounterMap.put( tableName, Integer.valueOf( 0 ) );
          rowIsSafe = true;
        } else {
          rowIsSafe = false;
        }
      }
    } catch ( KettleDatabaseBatchException be ) {
      errorMessage = be.toString();

View on GitHub (pinned to f3058517a1)