prestodb/presto · error · PrestoException
NOT_IN_TRANSACTION
NOT_IN_TRANSACTION
Error message
No transaction in progress
What it means
COMMIT was executed but the session has no open transaction. CommitTask.execute checks session.getTransactionId().isPresent() and throws NOT_IN_TRANSACTION if absent, because there is no transaction to commit.
Source
Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/CommitTask.java:44
import java.util.List;
import static com.facebook.presto.spi.StandardErrorCode.NOT_IN_TRANSACTION;
public class CommitTask
implements SessionTransactionControlTask<Commit>
{
@Override
public String getName()
{
return "COMMIT";
}
@Override
public ListenableFuture<?> execute(Commit statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, String query)
{
Session session = stateMachine.getSession();
if (!session.getTransactionId().isPresent()) {
throw new PrestoException(NOT_IN_TRANSACTION, "No transaction in progress");
}
TransactionId transactionId = session.getTransactionId().get();
stateMachine.clearTransactionId();
return transactionManager.asyncCommit(transactionId);
}
}
View on GitHub (pinned to 55bb57d202)
Solutions
- Start a transaction first: START TRANSACTION; ... ; COMMIT
- Remove the stray COMMIT if autocommit is desired — each statement commits on its own
- Check driver/session autocommit settings so COMMIT is only sent when a transaction was explicitly started
- Guard application logic with a transaction-active flag before sending COMMIT
Example fix
// before
Connection c = driver.connect(...); // autocommit on
stmt.execute("COMMIT");
// after
stmt.execute("START TRANSACTION");
stmt.execute("INSERT ...");
stmt.execute("COMMIT"); Defensive patterns
Strategy: try-catch
Validate before calling
// track transaction state client-side
if (!sessionState.isInTransaction()) {
throw new IllegalStateException("COMMIT skipped: no transaction in progress");
} Try / catch
try {
stmt.execute("COMMIT");
} catch (PrestoSQLException e) {
if ("NOT_IN_TRANSACTION".equals(e.getErrorCodeName())) {
// no-op or log: transaction already closed
} else throw e;
} Prevention
- Always pair START TRANSACTION / COMMIT in the same session and code path
- Avoid mixing autocommit and manual transaction control
- Track transaction state in your connection wrapper before issuing COMMIT
- Handle reconnects by re-checking transaction state rather than blindly resending COMMIT
When it happens
Trigger: Running COMMIT without a preceding START TRANSACTION in the same session; running COMMIT after an implicit auto-commit of the previous statement; issuing COMMIT twice (the first COMMIT clears the session transaction id via stateMachine.clearTransactionId()); session transaction id was cleared by a prior commit or rollback.
Common situations: Client drivers with autocommit enabled issuing manual COMMIT; scripts that unconditionally COMMIT; retry logic resending COMMIT after a connection drop mid-transaction; mixing session-scoped transaction state across pooled connections.
Related errors
- ICEBERG_TRANSACTION_CONFLICT_ERROR
- AUTOCOMMIT_WRITE_CONFLICT
- INVALID_TABLE_PROPERTY
- MISSING_ATTRIBUTE
- AMBIGUOUS_ATTRIBUTE
AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04).
Data as JSON: /api/errors/4efc56365b8a1347.
Report an issue: GitHub.