pentaho/pentaho-kettle · warning · KettleDatabaseException
Error cancelling statement
Error message
Error cancelling statement
What it means
KettleDatabaseException thrown by Database.cancelQuery() when Statement.cancel() throws a SQLException. Cancel is usually called to abort a running query from another thread; failure means the driver could not cancel (statement already finished/closed, driver lacks async cancel support, or connection is broken).
Solutions
- Check the wrapped SQLException for feature-not-supported — the driver may not support cancel; use DB-specific KILL QUERY/session commands instead
- Verify the connection is still alive; a dead connection cannot cancel anything
- Ignore/tolerate this error when it races with statement completion (cancel after finish is harmless)
- Upgrade the driver to one supporting statement cancellation
Example fix
// before
try { database.cancelQuery(); } catch (Exception e) { throw e; }
// after
try {
database.cancelQuery();
} catch (KettleDatabaseException e) {
log.debug("Cancel failed (query may already have finished): " + e.getMessage());
} Defensive patterns
Strategy: try-catch
Validate before calling
if ( database.getConnection() == null || database.getConnection().isClosed() ) {
return; // nothing to cancel
} Try / catch
try {
database.cancelQuery();
} catch ( KettleDatabaseException e ) {
log.debug( "Cancel raced with completion or unsupported: " + e.getMessage() );
} Prevention
- Treat cancel failures during shutdown as benign
- Use a driver that supports Statement.cancel (or DB-level KILL QUERY)
- Avoid cancelling after the statement future already completed
- Keep the cancelling reference on the same thread-safe Database object
When it happens
Trigger: Calling Database.cancelQuery() while statement.cancel() throws — statement already completed, connection dead, or driver does not support cancellation (e.g. some drivers throw SQLFeatureNotSupported).
Common situations: Cancelling a long-running transformation step whose query already returned, cancelling after the connection timed out, drivers without true async cancel (MySQL needs a separate connection to kill the query).
Understand the failure class
Background: Database query failed: Internal Server Error 500s wrapping SQL, Prisma, and connection failures — what to check first — this error's family across 16 libraries.
Related errors
- Error closing prepared statement
- Unable to close prepared statement sel_stmt
- An error occurred executing SQL:
- 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/6cd403455fb824d4.
Report an issue: GitHub.
Appendix: source
Thrown at core/src/main/java/org/pentaho/di/core/database/Database.java:1044
cancelStatement( selStmt );
}
/**
* Cancel an open/running SQL statement
*
* @param statement the statement to cancel
* @throws KettleDatabaseException
*/
public void cancelStatement( Statement statement ) throws KettleDatabaseException {
try {
if ( statement != null ) {
statement.cancel();
}
if ( log.isDebug() ) {
log.logDebug( "Statement canceled!" );
}
} catch ( SQLException ex ) {
throw new KettleDatabaseException( "Error cancelling statement", ex );
}
}
/**
* Specify after how many rows a commit needs to occur when inserting or updating values.
*
* @param commitSize The number of rows to wait before doing a commit on the connection.
*/
public void setCommit( int commitSize ) {
setCommitSize( commitSize );
setAutoCommit();
}
public void setAutoCommit() {
String onOff = ( commitsize <= 0 ? "on" : "off" );
try {
connection.setAutoCommit( commitsize <= 0 );
if ( log.isDetailed() ) {View on GitHub (pinned to f3058517a1)