{"record":{"id":"0da201593d490c4d","repo":"pentaho/pentaho-kettle","slug":"error-updating-batch-first-10-errors-errors-encountered","errorCode":null,"errorMessage":"Error updating batch, first 10 errors: Errors encountered (first 10):","messagePattern":"Error updating batch, first 10 errors: Errors encountered \\(first 10\\):","errorType":"exception","errorClass":"KettleException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/synchronizeaftermerge/SynchronizeAfterMerge.java","lineNumber":424,"sourceCode":"      }\n      if ( data.deleteStatement != null ) {\n        data.db.clearBatch( data.deleteStatement );\n      }\n\n      if ( getStepMeta().isDoingErrorHandling() ) {\n        data.db.commit( true );\n      } else {\n        data.db.rollback();\n        StringBuilder msg = new StringBuilder( \"Error batch inserting rows into table [\" + data.realTableName + \"].\" );\n        msg.append( Const.CR );\n        msg.append( \"Errors encountered (first 10):\" ).append( Const.CR );\n        for (int x = 0; x < be.getExceptionsList().size() && x < 10; x++) {\n          Exception exception = be.getExceptionsList().get( x );\n          if ( exception.getMessage() != null ) {\n            msg.append( exception.getMessage() ).append( Const.CR );\n          }\n        }\n        throw new KettleException( msg.toString(), be );\n      }\n    } catch ( KettleDatabaseException dbe ) {\n      if ( getStepMeta().isDoingErrorHandling() ) {\n        if ( log.isRowLevel() ) {\n          logRowlevel( \"Written row to error handling : \" + getInputRowMeta().getString( row ) );\n        }\n\n        if ( data.specialErrorHandling && data.supportsSavepoints ) {\n          if ( data.savepoint != null || !data.lookupFailure ) {\n            // do this when savepoint was set, and this is not lookup failure PDI-10878\n            data.db.rollback( data.savepoint );\n            if ( data.releaseSavepoint ) {\n              data.db.releaseSavepoint( data.savepoint );\n            }\n          }\n        }\n        sendToErrorRow = true;\n        errorMessage = dbe.toString();","sourceCodeStart":406,"sourceCodeEnd":442,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/synchronizeaftermerge/SynchronizeAfterMerge.java#L406-L442","documentation":"Thrown after a KettleDatabaseBatchException escapes lookupValues(): when the step is NOT doing row-level error handling, it catches the batch exception, collects messages from the first 10 wrapped exceptions, and rethrows a KettleException titled 'Error updating batch, first 10 errors: Errors encountered (first 10):' so the user can see the individual batch failures.","triggerScenarios":"lookupValues() threw KettleDatabaseBatchException from executeBatch(); in the outer catch, getStepMeta().isDoingErrorHandling() is false, so the code builds msg from be.getExceptionsList() and throws KettleException(msg, be).","commonSituations":"Multiple rows in one batch violate constraints or types; user has no error-handling hops configured so the whole transformation fails instead of routing bad rows; inspecting which rows failed.","solutions":["Read the 10 appended messages to identify the common failing cause (constraint, datatype, size).","Configure error handling on the step (define an error hop) so bad rows are captured instead of aborting the transformation.","Fix the data or target schema issues named in the individual batch error messages.","Reduce batch size so fewer rows fail together and errors are easier to isolate."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"catch (KettleException e) {\n  if (e.getMessage().startsWith(\"Error updating batch\")) {\n    Throwable cause = e.getCause();\n    if (cause instanceof KettleDatabaseBatchException) {\n      ((KettleDatabaseBatchException) cause).getExceptionsList()\n        .forEach(ex -> logError(\"Batch row error: \" + ex.getMessage()));\n    }\n  }\n}","preventionTips":["Configure error handling hops so bad rows are captured instead of failing the run.","Validate data against target constraints before writing.","Keep batch sizes small so failures are easy to triage."],"tags":["database","jdbc-batch","error-handling","pentaho-kettle"],"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"}