pentaho/pentaho-kettle · warning · SshConnectionException

Command execution was interrupted

Error message

Command execution was interrupted

What it means

exec catches InterruptedException while sleeping/polling the channel exit status and rethrows it as SshConnectionException('Command execution was interrupted'), after restoring the thread's interrupt flag. It means the executing thread was interrupted (e.g. transformation cancelled/stopped) rather than any SSH-level problem.

Solutions

  1. Treat it as a cancellation signal: stop the workflow rather than retrying automatically
  2. Check who interrupted the thread (transformation stop, executor shutdown)
  3. If you must kill the remote process, close the SSH connection so the channel is torn down
  4. Avoid swallowing InterruptedException in caller code; propagate or re-interrupt
  5. Design long remote jobs to be resumable so cancellation is safe

Example fix

// before
try { result = conn.exec(cmd, timeout); } catch ( Exception e ) { e.printStackTrace(); } // ignores interruption
// after
try { result = conn.exec(cmd, timeout); }
catch ( SshConnectionException e ) {
  if ( Thread.currentThread().isInterrupted() ) { cleanupRemote( conn ); return null; } // cancelled
  throw e;
}
Defensive patterns

Strategy: try-catch

Validate before calling

// check before starting long work
if ( Thread.currentThread().isInterrupted() ) { throw new CancellationException( "Already interrupted; skip SSH exec" ); }

Try / catch

try { result = conn.exec( cmd, timeoutMs ); }
catch ( SshConnectionException e ) {
  if ( "Command execution was interrupted".equals( e.getMessage() ) ) {
    return; // treat as cancellation, do not retry
  }
  throw e;
} finally {
  if ( Thread.currentThread().isInterrupted() ) { /* propagate cancellation upstream */ }
}

Prevention

When it happens

Trigger: A calling thread is interrupted during exec's wait loop (Thread.sleep polling) — typically when a Pentaho transformation/job is stopped, or an executor shutdown cancels the task.

Common situations: User hits Stop in Spoon while a remote command runs; thread pool shutdown during app redeploy; timeouts in the orchestration layer cancelling workers.

Related errors


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

Appendix: source

Thrown at engine/src/main/java/org/pentaho/di/core/ssh/mina/MinaSshConnection.java:470

          if ( ex == null ) {
            // Wait a bit more for exit status to be set
            Thread.sleep( 100 );
            ex = ch.getExitStatus();
          }
          exit = ex == null ? -1 : ex;
        } else {
          // Timeout occurred
          throw new SshTimeoutException( "Command execution timed out after " + timeoutMs + "ms" );
        }
      }
      String outStr = stdout.toString( StandardCharsets.UTF_8 );
      String errStr = stderr.toString( StandardCharsets.UTF_8 );
      return new ExecResult( outStr, errStr, outStr + errStr, exit, exit != 0 );
    } catch ( SshTimeoutException e ) {
      throw e; // Re-throw timeout exceptions as-is
    } catch ( InterruptedException e ) {
      Thread.currentThread().interrupt(); // Restore interrupted status
      throw new SshConnectionException( "Command execution was interrupted", e );
    } catch ( Exception e ) {
      throw new SshConnectionException( "Failed to execute command: " + command, e );
    }
  }

  @Override
  public ExecResult exec( String command ) throws SshConnectionException {
    return exec( command, config.getCommandTimeoutMillis() );
  }

  @Override
  public SftpSession openSftp() throws SshConnectionException {
    try {
      var factory = SftpClientFactory.instance();
      var sftp = factory.createSftpClient( session );
      return new MinaSftpSession( sftp );
    } catch ( Exception e ) {
      throw new SftpException( "Failed to open SFTP session", e );

View on GitHub (pinned to f3058517a1)