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

  1. Verify the sequence name and schema in the step dialog exist on the target DB (SELECT from user_sequences / pg_sequences).
  2. Grant SELECT on the sequence to the connection's DB user.
  3. Check the wrapped KettleDatabaseException for SQL errors (ORA-02289 sequence does not exist is the usual one).
  4. 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

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


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)