pentaho/pentaho-kettle · error · KettleObjectExistsException
Failed to create object in repository. Object
Error message
Failed to create object in repository. Object [{0}] already exists. What it means
insertPartitionSchema throws KettleObjectExistsException before generating an ID if a partition schema with the same name already exists in R_PARTITION_SCHEMA. This is the low-level guard preventing duplicate-named partition schemas in the repository.
Solutions
- Check existence first (getPartitionSchemaID) and update the existing object instead of inserting
- Rename the schema to something unique before inserting
- Catch KettleObjectExistsException and fall back to updatePartitionSchema on the existing ID
- Serialize inserts (the method is synchronized) through a single writer process to avoid races
Example fix
// before ObjectId id = delegate.insertPartitionSchema(schema); // after ObjectId existingId = delegate.getPartitionSchemaID(schema.getName()); ObjectId id = (existingId != null) ? existingId // reuse existing schema : delegate.insertPartitionSchema(schema);
Defensive patterns
Strategy: validation
Validate before calling
ObjectId existingId = delegate.getPartitionSchemaID(schema.getName());
if (existingId != null) { /* update existing instead of inserting */ } Prevention
- Always upsert by name: check existence first, then insert or update
- Avoid parallel inserts of identically named schemas across clients
- Make import scripts idempotent
- Catch KettleObjectExistsException and fall back to update
When it happens
Trigger: Calling insertPartitionSchema(partitionSchema) when getPartitionSchemaID(name) returns a non-null ID, i.e. the name is already taken. Reached via savePartitionSchema flows that decide to insert rather than update.
Common situations: Race between two clients inserting the same schema name concurrently; programmatic import loops that insert schemas without checking existence first; re-running migration scripts.
Understand the failure class
Background: "already exists" / EEXIST / FileAlreadyExistsException: what the 'file already exists' error means and how to fix it — this error's family across 37 libraries.
Related errors
- Failed to save object to repository. Object [name] already…
- Failed to create object in repository. Object
- Failed to save object to repository. Object
- Can not create element type with id…
- Namespace with name ''+namespace+'' already exists
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/afa4cd3f0c201c03.
Report an issue: GitHub.
Appendix: source
Thrown at engine/src/main/java/org/pentaho/di/repository/kdr/delegates/KettleDatabaseRepositoryPartitionSchemaDelegate.java:140
RowMetaAndData row = getPartitionSchema( id_partition_schema );
partitionSchema.setName( row.getString( "NAME", null ) );
ObjectId[] pids = repository.getPartitionIDs( id_partition_schema );
for ( int i = 0; i < pids.length; i++ ) {
partitionSchema.getPartitionIDs().add( getPartition( pids[i] ).getString( "PARTITION_ID", null ) );
}
partitionSchema.setDynamicallyDefined( row.getBoolean( "DYNAMIC_DEFINITION", false ) );
partitionSchema.setNumberOfPartitionsPerSlave( row.getString( "PARTITIONS_PER_SLAVE", null ) );
return partitionSchema;
}
public synchronized ObjectId insertPartitionSchema( PartitionSchema partitionSchema ) throws KettleException {
if ( getPartitionSchemaID( partitionSchema.getName() ) != null ) {
// This partition schema name is already in use. Throw an exception.
throw new KettleObjectExistsException( "Failed to create object in repository. Object ["
+ partitionSchema.getName() + "] already exists." );
}
ObjectId id = repository.connectionDelegate.getNextPartitionSchemaID();
RowMetaAndData table = new RowMetaAndData();
table.addValue( new ValueMetaInteger( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_ID_PARTITION_SCHEMA ), id );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_NAME ),
partitionSchema.getName() );
table.addValue( new ValueMetaBoolean( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_DYNAMIC_DEFINITION ),
partitionSchema.isDynamicallyDefined() );
table.addValue( new ValueMetaString( KettleDatabaseRepository.FIELD_PARTITION_SCHEMA_PARTITIONS_PER_SLAVE ),
partitionSchema.getNumberOfPartitionsPerSlave() );
repository.connectionDelegate.getDatabase().prepareInsert(
table.getRowMeta(), KettleDatabaseRepository.TABLE_R_PARTITION_SCHEMA );
repository.connectionDelegate.getDatabase().setValuesInsert( table );View on GitHub (pinned to f3058517a1)