pentaho/pentaho-kettle · critical · KettleStepException
AddSequence.Exception.ErrorReadingSequence
Error message
AddSequence.Exception.ErrorReadingSequence
What it means
AddSequence.addSequence throws KettleStepException with this message when getNextSequenceValue on the configured database fails while fetching the next value of a DB sequence. The sequence name is embedded in the message; the KettleDatabaseException is the cause.
Solutions
- Verify the sequence name and schema in the step dialog exist on the target DB (SELECT from user_sequences / pg_sequences).
- Grant SELECT on the sequence to the connection's DB user.
- Check the wrapped KettleDatabaseException for SQL errors (ORA-02289 sequence does not exist is the usual one).
- Confirm the step's connection points at the intended environment's database.
Example fix
// before next = data.getDb().getNextSequenceValue( data.realSchemaName, data.realSequenceName, meta.getValuename() ); // after (environment variable substitution keeps env-specific sequence names) String seq = environmentSubstitute( meta.getSequenceName() ); next = data.getDb().getNextSequenceValue( environmentSubstitute( meta.getSchemaName() ), seq, meta.getValuename() );
Defensive patterns
Strategy: try-catch
Validate before calling
// verify the sequence exists and is readable before running the transformation SELECT sequence_name FROM all_sequences WHERE sequence_owner = ? AND sequence_name = UPPER(?); -- Oracle -- or Postgres: SELECT 1 FROM pg_sequences WHERE schemaname = ? AND sequencename = ?;
Try / catch
try { /* run transformation with AddSequence */ } catch ( KettleStepException e ) { if ( e.getMessage().contains( "AddSequence.Exception.ErrorReadingSequence" ) ) { logError( "Sequence " + seqName + " missing or inaccessible: " + e.getCause(), e ); } } Prevention
- Create sequences in all environments via migration scripts (Flyway/Liquibase).
- Use exact-case sequence names on Oracle/Postgres and qualify with schema.
- Grant SELECT on sequences to the PDI connection user.
- Point the step's connection at the correct environment database.
When it happens
Trigger: Executing the AddSequence step with isDatabaseUsed() true and data.getDb().getNextSequenceValue(realSchemaName, realSequenceName, valuename) throwing — wrong schema/sequence name, sequence dropped, or insufficient SELECT privilege on the sequence.
Common situations: Sequence name typo or case-sensitivity on Oracle/Postgres, missing schema qualifier, sequence exists in dev but not prod, DB user lacking sequence SELECT grant, connection dropped mid-run.
Understand the failure class
Background: "query failed", "%w: SQL error" — wrapped database query errors in Go libraries explained — this error's family across 3 libraries.
Related errors
- Unable to get next value for slave sequence '" + name + "'…
- AddSequence.Exception.CouldNotFindNextValueForSequence
- AddSequence.Exception.NoSpecifiedMethod
- An error occurred executing SQL:
- Couldn't execute SQL:
AI-assisted analysis of pentaho/pentaho-kettle@f3058517a1 (2026-09-13).
Data as JSON: /api/errors/66f5f0c8574d0dad.
Report an issue: GitHub.
Appendix: source
Thrown at plugins/core/impl/src/main/java/org/pentaho/di/trans/steps/addsequence/AddSequence.java:74
synchronized ( data.counter ) {
long prev = data.counter.getCounter();
long nval = prev + data.increment;
if ( data.increment > 0 && data.maximum > data.start && nval > data.maximum ) {
nval = data.start;
}
if ( data.increment < 0 && data.maximum < data.start && nval < data.maximum ) {
nval = data.start;
}
data.counter.setCounter( nval );
next = prev;
}
} else if ( meta.isDatabaseUsed() ) {
try {
next = data.getDb().getNextSequenceValue( data.realSchemaName, data.realSequenceName, meta.getValuename() );
} catch ( KettleDatabaseException dbe ) {
throw new KettleStepException( BaseMessages.getString(
PKG, "AddSequence.Exception.ErrorReadingSequence", data.realSequenceName ), dbe );
}
} else {
// This should never happen, but if it does, don't continue!!!
throw new KettleStepException( BaseMessages.getString( PKG, "AddSequence.Exception.NoSpecifiedMethod" ) );
}
if ( next != null ) {
Object[] outputRowData = inputRowData;
if ( inputRowData.length < inputRowMeta.size() + 1 ) {
outputRowData = RowDataUtil.resizeArray( inputRowData, inputRowMeta.size() + 1 );
}
outputRowData[inputRowMeta.size()] = next;
return outputRowData;
} else {
throw new KettleStepException( BaseMessages.getString(
PKG, "AddSequence.Exception.CouldNotFindNextValueForSequence" )
+ meta.getValuename() );View on GitHub (pinned to f3058517a1)