prestodb/presto · error · PrestoException

NOT_SUPPORTED

NOT_SUPPORTED

Error message

Nested transactions not supported

What it means

PrestoException from StartTransactionTask.execute when a START TRANSACTION statement arrives while the session already holds an active transaction. Presto does not support nested or concurrent transactions per session, and the client has transaction support enabled (otherwise a different error is thrown).

Source

Thrown at presto-main-base/src/main/java/com/facebook/presto/execution/StartTransactionTask.java:54

public class StartTransactionTask
        implements SessionTransactionControlTask<StartTransaction>
{
    @Override
    public String getName()
    {
        return "START TRANSACTION";
    }

    @Override
    public ListenableFuture<?> execute(StartTransaction statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, String query)
    {
        Session session = stateMachine.getSession();
        if (!session.isClientTransactionSupport()) {
            throw new PrestoException(StandardErrorCode.INCOMPATIBLE_CLIENT, "Client does not support transactions");
        }
        if (session.getTransactionId().isPresent()) {
            throw new PrestoException(StandardErrorCode.NOT_SUPPORTED, "Nested transactions not supported");
        }

        Optional<IsolationLevel> isolationLevel = extractIsolationLevel(statement);
        Optional<Boolean> readOnly = extractReadOnly(statement);

        TransactionId transactionId = transactionManager.beginTransaction(
                isolationLevel.orElse(TransactionManager.DEFAULT_ISOLATION),
                readOnly.orElse(TransactionManager.DEFAULT_READ_ONLY),
                false);

        stateMachine.setStartedTransactionId(transactionId);

        // Since the current session does not contain this new transaction ID, we need to manually mark it as inactive
        // when this statement completes.
        transactionManager.trySetInactive(transactionId);

        return immediateFuture(null);
    }

View on GitHub (pinned to 55bb57d202)

Solutions

  1. COMMIT or ROLLBACK the current transaction before starting a new one.
  2. Check transaction state client-side before issuing START TRANSACTION (inspect the returned transaction ID header).
  3. Fix connection-pool or framework code that leaves transactions open.
  4. Ensure error paths always roll back open transactions.

Example fix

-- before
START TRANSACTION;
START TRANSACTION;
-- after
START TRANSACTION;
COMMIT;
START TRANSACTION;
Defensive patterns

Strategy: validation

Validate before calling

// track open transaction state client-side
if (inTransaction) commitOrRollbackFirst();

Try / catch

// catch PrestoException with errorCode NOT_SUPPORTED and message 'Nested transactions not supported'; commit/rollback then retry once

Prevention

When it happens

Trigger: StartTransactionTask.execute() finds session.getTransactionId().isPresent() — i.e. START TRANSACTION issued while a previous transaction is still open on the same session.

Common situations: Scripts issuing START TRANSACTION twice without COMMIT/ROLLBACK in between, connection pools leaking open transactions, or application frameworks that auto-begin transactions.

Understand the failure class

Background: Presto NOT_SUPPORTED error: what "not supported" means and how to fix it — this error's family across 3 libraries.

Related errors


AI-assisted analysis of prestodb/presto@55bb57d202 (2026-09-04). Data as JSON: /api/errors/b515a02b06c5e969. Report an issue: GitHub.