{"record":{"id":"9f53a12b05c049d4","repo":"t8y2/dbx","slug":"no-manual-transaction-is-active","errorCode":null,"errorMessage":"No manual transaction is active","messagePattern":"No manual transaction is active","errorType":"exception","errorClass":"SQLException","httpStatus":null,"severity":"error","filePath":"plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java","lineNumber":1090,"sourceCode":"    private static ObjectNode commitManualTransaction() throws SQLException {\n        Connection conn = activeManualTransactionConnection(null);\n        conn.commit();\n        conn.setAutoCommit(true);\n        manualTransactionActive = false;\n        return okResult();\n    }\n\n    private static ObjectNode rollbackManualTransaction() throws SQLException {\n        Connection conn = activeManualTransactionConnection(null);\n        conn.rollback();\n        conn.setAutoCommit(true);\n        manualTransactionActive = false;\n        return okResult();\n    }\n\n    private static Connection activeManualTransactionConnection(JsonNode connection) throws SQLException {\n        if (!manualTransactionActive || sharedConnection == null || sharedConnection.isClosed()) {\n            throw new SQLException(\"No manual transaction is active\");\n        }\n        if (connection != null && !connectionKey(connection).equals(sharedConnectionKey)) {\n            throw new SQLException(\"The manual transaction belongs to a different JDBC connection\");\n        }\n        return sharedConnection;\n    }\n\n    private static ObjectNode okResult() {\n        ObjectNode result = MAPPER.createObjectNode();\n        result.put(\"ok\", true);\n        return result;\n    }\n\n    private record ExecutedStatement(ResultSet resultSet, int updateCount) {\n    }\n\n    private static final class QuerySession {\n        private final String id;","sourceCodeStart":1072,"sourceCodeEnd":1108,"githubUrl":"https://github.com/t8y2/dbx/blob/c0390bff16418b651f4728520d99adf8ce48829a/plugins/jdbc/src/main/java/app/dbx/jdbc/DbxJdbcPlugin.java#L1072-L1108","documentation":"activeManualTransactionConnection validates the preconditions for any manual-transaction operation (commit, rollback, statement execution): manualTransactionActive must be true and sharedConnection must exist and be open. If any of these fails, it throws this SQLException — the caller is attempting transaction work with no live transaction.","triggerScenarios":"Calling commit/rollback or running a statement inside a manual transaction when begin was never called, the transaction was already committed/rolled back, the shared connection was closed (timeout, server kill, plugin restart clearing static state), or after a plugin reload resetting manualTransactionActive.","commonSituations":"Connection dropped by the server between begin and commit (idle timeout, network blip), the process restarted losing static state, or script logic calling commit twice.","solutions":["Begin a manual transaction before attempting commit/rollback; ensure the begin call succeeded.","Detect closed connections (SQLException on isClosed/use) and restart the transaction from begin rather than committing a dead one.","Make commit/rollback idempotent in your orchestration: track your own in-transaction flag and skip duplicate finalization.","If the plugin process restarted mid-transaction, treat the transaction as lost and rerun the whole unit of work."],"exampleFix":"// before\nbeginTx(conn);\n// connection drops; process restarts\ncommitTx(conn);          // -> \"No manual transaction is active\"\n// after\nbeginTx(conn);\ntry {\n    if (hasActiveTx()) commitTx(conn);\n} catch (SQLException e) {\n    beginTx(conn); commitTx(conn); // restart unit of work\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    plugin.commitManualTransaction(connCfg);\n} catch (java.sql.SQLException e) {\n    if (e.getMessage().contains(\"No manual transaction is active\")) {\n        // transaction lost (restart/close); redo the unit of work\n        redoUnitOfWork(connCfg);\n    } else {\n        throw e;\n    }\n}","preventionTips":["Keep transactions short to avoid idle-timeout connection drops mid-transaction","Track your own in-transaction flag so commit is only called once","Re-begin the transaction after any reconnect instead of committing stale state","Remember static transaction state is lost on process restart — re-run the unit of work"],"tags":["jdbc","transactions","connection-state"],"backgroundTag":"no-active-transaction","analyzedSha":"c0390bff16418b651f4728520d99adf8ce48829a","analyzedAt":"2026-09-05T23:05:10.900Z","contentChangedAt":"2026-09-05T23:05:10.900Z","schemaVersion":2},"datasetVersion":"2026-09-14T05:17:10.506Z"}