{"record":{"id":"5c0e9f7ac60cdbdc","repo":"pentaho/pentaho-kettle","slug":"synchronizeaftermerge-error-updatingbatch","errorCode":null,"errorMessage":"SynchronizeAfterMerge.Error.UpdatingBatch","messagePattern":"SynchronizeAfterMerge\\.Error\\.UpdatingBatch","errorType":"exception","errorClass":"KettleDatabaseBatchException","httpStatus":null,"severity":"error","filePath":"engine/src/main/java/org/pentaho/di/trans/steps/synchronizeaftermerge/SynchronizeAfterMerge.java","lineNumber":377,"sourceCode":"        //\n        if ( commitCounter > 0 && ( commitCounter % data.commitSize ) == 0 ) {\n          if ( data.batchMode ) {\n            try {\n              if ( performInsert ) {\n                data.insertStatement.executeBatch();\n                data.db.commit();\n                data.insertStatement.clearBatch();\n              } else if ( performUpdate ) {\n                data.updateStatement.executeBatch();\n                data.db.commit();\n                data.updateStatement.clearBatch();\n              } else if ( performDelete ) {\n                data.deleteStatement.executeBatch();\n                data.db.commit();\n                data.deleteStatement.clearBatch();\n              }\n            } catch ( SQLException ex ) {\n              throw Database.createKettleDatabaseBatchException( BaseMessages.getString( PKG,\n                \"SynchronizeAfterMerge.Error.UpdatingBatch\" ), ex );\n            } catch ( Exception ex ) {\n              throw new KettleDatabaseException( \"Unexpected error inserting row\", ex );\n            }\n          } else {\n            // insertRow normal commit\n            data.db.commit();\n          }\n          // Clear the batch/commit counter...\n          //\n          data.commitCounterMap.put( tableName, Integer.valueOf( 0 ) );\n          rowIsSafe = true;\n        } else {\n          rowIsSafe = false;\n        }\n      }\n    } catch ( KettleDatabaseBatchException be ) {\n      errorMessage = be.toString();","sourceCodeStart":359,"sourceCodeEnd":395,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/engine/src/main/java/org/pentaho/di/trans/steps/synchronizeaftermerge/SynchronizeAfterMerge.java#L359-L395","documentation":"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.","triggerScenarios":"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.).","commonSituations":"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.","solutions":["Read the wrapped exceptionsList in the KettleDatabaseBatchException to find the real SQLException cause (constraint, syntax, connection).","Disable batch mode in the step ('Use batch update' off) to get per-row errors that identify the offending row.","Fix the underlying data/constraint problem revealed by the cause (duplicate keys, oversized values).","Check DB connectivity/network stability and reduce commit/batch size to limit rework on failure."],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":"// Pre-check for constraint-prone data before the step\nif (duplicateKeysExist(rows)) { throw new ValidationException(\"Duplicate keys would violate PK in batch\"); }","typeGuard":null,"tryCatchPattern":"catch (KettleDatabaseBatchException be) {\n  for (Exception ex : be.getExceptionsList()) {\n    logError(\"Batch item failed: \" + ex.getMessage());\n  }\n}","preventionTips":["De-duplicate keys and validate column sizes/types upstream.","Keep JDBC drivers current and test connection stability.","Use smaller commit/batch sizes to limit blast radius; enable error handling hops."],"tags":["database","jdbc-batch","sql","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"}