pentaho/pentaho-kettle · error · KettleException

Unable to close insert after populating table

Error message

Unable to close insert after populating table {schemaTable}

What it means

After batch-inserting seed rows into a repository table, the helper calls database.closeInsert(); a KettleException while closing/flushing the prepared insert is wrapped as 'Unable to close insert after populating table <schemaTable>'. The rows themselves may be in limbo, so the table could be partially populated.

Solutions

  1. Inspect the cause for the flush/batch error; fix duplicates or constraints.
  2. Recreate the repository schema cleanly so seeding starts from empty tables.
  3. Verify connection stability between client and database during creation.
  4. Re-run creation after correcting; the insert closure happens only on failures in the batch pipeline.

Example fix

// before
repo.createRepositorySchema(monitor, false); // fails on existing seeded rows
// after
if (database.getRowCount(TABLE_DATABASE_TYPE) == 0) {
  repo.createRepositorySchema(monitor, false);
}
Defensive patterns

Strategy: validation

Validate before calling

// only seed into empty tables
if (database.getRowCount(schemaTable) == 0) {
  performSeedInserts();
}

Try / catch

try {
  repo.createRepositorySchema(monitor, false);
} catch (KettleException e) {
  log.error("seed insert close failed for " + schemaTable + ": " + e.getCause(), e);
}

Prevention

When it happens

Trigger: createRepositorySchema() populates a lookup table (e.g. R_DATABASE_TYPE) with batch inserts, then closeInsert() throws — usually an unflushed batch error, constraint violation at flush, or connection drop.

Common situations: Network drop mid-batch during first-time repository creation; duplicate seed rows against an already-populated table; JDBC driver rejecting the batch on close.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/repository/kdr/KettleDatabaseRepositoryCreationHelper.java:379

          if ( dryrun ) {
            sql = database.getSQLOutput( null, tablename, table, tableData, null );
            statements.add( sql );
          } else {
            database.setValuesInsert( table, tableData );
            database.insertRow();
          }
        }
      }

      try {
        if ( !dryrun ) {
          database.closeInsert();
        }
        if ( log.isDetailed() ) {
          log.logDetailed( "Populated table " + schemaTable );
        }
      } catch ( KettleException dbe ) {
        throw new KettleException( "Unable to close insert after populating table " + schemaTable, dbe );
      }
    }
    if ( monitor != null ) {
      monitor.worked( 1 );
    }

    // ////////////////////////////////////////////////////////////////////////////////
    //
    // R_NOTE
    //
    // Create table...
    table = new RowMeta();
    tablename = KettleDatabaseRepository.TABLE_R_NOTE;
    schemaTable = databaseMeta.getQuotedSchemaTableCombination( null, tablename );
    if ( monitor != null ) {
      monitor.subTask( "Checking table " + schemaTable );
    }
    table.addValueMeta( new ValueMetaInteger(

View on GitHub (pinned to f3058517a1)