{"record":{"id":"ac379d5fb5160193","repo":"prestodb/presto","slug":"iceberg-transaction-conflict-error","errorCode":"ICEBERG_TRANSACTION_CONFLICT_ERROR","errorMessage":" cannot be called within a transaction (use autocommit mode) in Iceberg connector.","messagePattern":" cannot be called within a transaction \\(use autocommit mode\\) in Iceberg connector\\.","errorType":"error_code","errorClass":"PrestoException","httpStatus":null,"severity":"error","filePath":"presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java","lineNumber":2893,"sourceCode":"                    .commit();\n        }\n        catch (RuntimeException e) {\n            throw new PrestoException(ICEBERG_INCOMPATIBLE_COLUMN_TYPE, \"Failed to set column type: \" + firstNonNull(e.getMessage(), e), e);\n        }\n    }\n\n    protected void openCreateTableTransaction(SchemaTableName tableName, Transaction transaction)\n    {\n        transactionContext.registerTransaction(tableName, transaction);\n    }\n\n    /**\n     * Check and ensure that the specified statement can only run in a transaction with autocommit context set to true.\n     * */\n    protected void shouldRunInAutoCommitTransaction(String statement)\n    {\n        if (!transactionContext.isAutoCommitContext()) {\n            throw new PrestoException(ICEBERG_TRANSACTION_CONFLICT_ERROR, statement + \" cannot be called within a transaction (use autocommit mode) in Iceberg connector.\");\n        }\n    }\n}\n","sourceCodeStart":2875,"sourceCodeEnd":2897,"githubUrl":"https://github.com/prestodb/presto/blob/55bb57d202de3b926896fa966c2c4a44c779634e/presto-iceberg/src/main/java/com/facebook/presto/iceberg/IcebergAbstractMetadata.java#L2875-L2897","documentation":"Thrown by IcebergAbstractMetadata.shouldRunInAutoCommitTransaction when a statement that only supports autocommit execution (e.g. certain materialized view or table-maintenance operations) is issued inside an explicit multi-statement transaction. The Iceberg connector cannot run these operations within a user transaction.","triggerScenarios":"Executing a restricted statement (the operation name is prepended to the message) while inside START TRANSACTION ... without autocommit, i.e. transactionContext.isAutoCommitContext() is false.","commonSituations":"Wrapping CREATE/DROP MATERIALIZED VIEW or similar Iceberg DDL in an explicit transaction in a session or tool that keeps a transaction open; ORM/framework-managed sessions with autocommit disabled.","solutions":["Run the statement outside any explicit transaction: COMMIT/ROLLBACK the current transaction first, then execute in autocommit mode","Ensure the client/session has autocommit enabled (e.g. remove START TRANSACTION around the DDL)","Restructure application logic so this Iceberg operation is executed as a standalone statement"],"exampleFix":"// before\nSTART TRANSACTION;\nCREATE MATERIALIZED VIEW mv AS SELECT ...;\nCOMMIT;\n// after\n-- execute directly, autocommit on\nCREATE MATERIALIZED VIEW mv AS SELECT ...;","handlingStrategy":"validation","validationCode":"// in client code, ensure autocommit before running Iceberg DDL\nif (connection.getTransactionIsolation() != TRANSACTION_NONE && !connection.getAutoCommit()) {\n    throw new IllegalStateException(\"Commit/rollback the transaction before running this Iceberg statement\");\n}","typeGuard":null,"tryCatchPattern":"try { stmt.execute(ddl); } catch (PrestoException e) { if (\"ICEBERG_TRANSACTION_CONFLICT_ERROR\".equals(e.getErrorCode().getName())) { connection.setAutoCommit(true); /* re-run */ } else throw e; }","preventionTips":["Never wrap Iceberg-restricted DDL (e.g. materialized view ops) in START TRANSACTION blocks","Keep autocommit enabled in ORM/framework-managed sessions for these statements","Document which connector operations require autocommit in team runbooks"],"tags":["iceberg","transaction","autocommit","ddl"],"backgroundTag":"operation-not-allowed-in-transaction","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"}