{"record":{"id":"bd21b16ef54c1f0a","repo":"apache/seatunnel","slug":"transaction-operation-failed","errorCode":"TRANSACTION_OPERATION_FAILED","errorMessage":"commit failed,","messagePattern":"commit failed,","errorType":"error_code","errorClass":"JdbcConnectorException","httpStatus":null,"severity":"error","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcSinkWriter.java","lineNumber":322,"sourceCode":"                    reportWriteSuccess(batchRows);\n                } catch (Throwable e) {\n                    if (!isRowLevelDataError(e)) {\n                        throwAsIoException(e);\n                    }\n                    handleRowLevelBatchFailure(\n                            RowErrorPhase.PREPARE_COMMIT, checkpointId, batchRows, e);\n                }\n            }\n            return Optional.empty();\n        }\n\n        tryOpen();\n        outputFormat.checkFlushException();\n        outputFormat.flush();\n        try {\n            commitIfNeeded();\n        } catch (SQLException e) {\n            throw new JdbcConnectorException(\n                    JdbcConnectorErrorCode.TRANSACTION_OPERATION_FAILED,\n                    \"commit failed,\" + e.getMessage(),\n                    e);\n        }\n        return Optional.empty();\n    }\n\n    @Override\n    public void abortPrepare() {}\n\n    @Override\n    public void close() throws IOException {\n        if (rowErrorCollector.isPresent()) {\n            synchronized (batchLock) {\n                tryOpen();\n                List<SeaTunnelRow> batchRows = swapPendingRowsLocked();\n                try {\n                    outputFormat.flush();","sourceCodeStart":304,"sourceCodeEnd":340,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcSinkWriter.java#L304-L340","documentation":"JdbcSinkWriter.prepareCommitInternal flushes buffered rows and commits the current transaction (when auto-commit is off / XA is in use). If Connection.commit() (or the internal commitIfNeeded path) throws a SQLException, the writer wraps it in JdbcConnectorException with code TRANSACTION_OPERATION_FAILED. The job's checkpoint fails and the writer will be recovered/restored by the engine.","triggerScenarios":"Calling prepareCommit during checkpoint; commitIfNeeded issues a JDBC commit and the underlying driver rejects it — connection lost, transaction aborted by the server, lock timeout, XA protocol error, or network interruption.","commonSituations":"Database connection dropped mid-checkpoint (wait_timeout, firewall idle kill); deadlocks or lock-wait timeouts on the target table; server-side max_prepared_transaction limits on PostgreSQL; network partition between SeaTunnel worker and the DB.","solutions":["Inspect the wrapped SQLException (cause chain) to identify the root cause (timeout, deadlock, connection reset).","Enable connection validation/keepalive and adjust database-side timeouts (wait_timeout, lock_wait_timeout).","Retry the job/checkpoint; the engine restores the writer from the last successful checkpoint so committed data is not duplicated.","Verify XA configuration on the database (e.g. PostgreSQL max_prepared_transactions > 0)."],"exampleFix":null,"handlingStrategy":"retry","validationCode":"// before prepareCommit: verify connection liveness\nif (!connection.isValid(5)) { reconnect(); }","typeGuard":null,"tryCatchPattern":"try {\n  writer.prepareCommit();\n} catch (JdbcConnectorException e) {\n  if (e.getSeatunnelCode() == JdbcConnectorErrorCode.TRANSACTION_OPERATION_FAILED) {\n    // inspect SQLException cause; rely on checkpoint restart\n  }\n}","preventionTips":["Tune DB wait_timeout and firewall idle timeouts above checkpoint interval","Enable connection validation on borrow","Monitor for deadlocks and lock-wait timeouts on target tables","Ensure XA is properly configured (max_prepared_transactions on PostgreSQL)"],"tags":["jdbc","transaction","commit","checkpoint"],"backgroundTag":"database-write-failed","analyzedSha":"cf67b549a7a6c35fa0beb12d83c62892427ea919","analyzedAt":"2026-09-10T21:44:55.265Z","contentChangedAt":"2026-09-10T21:44:55.265Z","schemaVersion":2},"datasetVersion":"2026-09-23T08:17:48.524Z"}