{"record":{"id":"b515a02b06c5e969","repo":"prestodb/presto","slug":"not-supported-b515a0","errorCode":"NOT_SUPPORTED","errorMessage":"Nested transactions not supported","messagePattern":"Nested transactions not supported","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-main-base/src/main/java/com/facebook/presto/execution/StartTransactionTask.java","lineNumber":54,"sourceCode":"\npublic class StartTransactionTask\n        implements SessionTransactionControlTask<StartTransaction>\n{\n    @Override\n    public String getName()\n    {\n        return \"START TRANSACTION\";\n    }\n\n    @Override\n    public ListenableFuture<?> execute(StartTransaction statement, TransactionManager transactionManager, Metadata metadata, AccessControl accessControl, QueryStateMachine stateMachine, List<Expression> parameters, String query)\n    {\n        Session session = stateMachine.getSession();\n        if (!session.isClientTransactionSupport()) {\n            throw new PrestoException(StandardErrorCode.INCOMPATIBLE_CLIENT, \"Client does not support transactions\");\n        }\n        if (session.getTransactionId().isPresent()) {\n            throw new PrestoException(StandardErrorCode.NOT_SUPPORTED, \"Nested transactions not supported\");\n        }\n\n        Optional<IsolationLevel> isolationLevel = extractIsolationLevel(statement);\n        Optional<Boolean> readOnly = extractReadOnly(statement);\n\n        TransactionId transactionId = transactionManager.beginTransaction(\n                isolationLevel.orElse(TransactionManager.DEFAULT_ISOLATION),\n                readOnly.orElse(TransactionManager.DEFAULT_READ_ONLY),\n                false);\n\n        stateMachine.setStartedTransactionId(transactionId);\n\n        // Since the current session does not contain this new transaction ID, we need to manually mark it as inactive\n        // when this statement completes.\n        transactionManager.trySetInactive(transactionId);\n\n        return immediateFuture(null);\n    }","sourceCodeStart":36,"sourceCodeEnd":72,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-main-base/src/main/java/com/facebook/presto/execution/StartTransactionTask.java#L36-L72","documentation":"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).","triggerScenarios":"StartTransactionTask.execute() finds session.getTransactionId().isPresent() — i.e. START TRANSACTION issued while a previous transaction is still open on the same session.","commonSituations":"Scripts issuing START TRANSACTION twice without COMMIT/ROLLBACK in between, connection pools leaking open transactions, or application frameworks that auto-begin transactions.","solutions":["COMMIT or ROLLBACK the current transaction before starting a new one.","Check transaction state client-side before issuing START TRANSACTION (inspect the returned transaction ID header).","Fix connection-pool or framework code that leaves transactions open.","Ensure error paths always roll back open transactions."],"exampleFix":"-- before\nSTART TRANSACTION;\nSTART TRANSACTION;\n-- after\nSTART TRANSACTION;\nCOMMIT;\nSTART TRANSACTION;","handlingStrategy":"validation","validationCode":"// track open transaction state client-side\nif (inTransaction) commitOrRollbackFirst();","typeGuard":null,"tryCatchPattern":"// catch PrestoException with errorCode NOT_SUPPORTED and message 'Nested transactions not supported'; commit/rollback then retry once","preventionTips":["Always pair BEGIN with COMMIT/ROLLBACK in error paths","Verify connection pool resets transaction state on return","Avoid framework auto-begin duplicating explicit BEGINs"],"tags":["transactions","nested-transactions","sql"],"backgroundTag":"nested-transaction-not-supported","analyzedSha":"55bb57d202de3b926896fa966c2c4a44c779634e","analyzedAt":"2026-09-04T12:50:26.162Z","contentChangedAt":"2026-09-04T12:50:26.162Z","schemaVersion":2},"datasetVersion":"2026-09-11T21:17:09.523Z"}