{"record":{"id":"230612845aa9ca45","repo":"apache/seatunnel","slug":"unable-to-fail-rollback-current-transaction-xid","errorCode":null,"errorMessage":"unable to fail/rollback current transaction, xid={}","messagePattern":"unable to fail/rollback current transaction, xid=(.+?)","errorType":"console","errorClass":null,"httpStatus":null,"severity":"warning","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcExactlyOnceSinkWriter.java","lineNumber":321,"sourceCode":"        } catch (Exception recoveryException) {\n            LOG.warn(\n                    \"recovery after rollback prepared transaction failure also failed, xid={}\",\n                    failedRollbackXid,\n                    recoveryException);\n            rollbackFailure.addSuppressed(recoveryException);\n        }\n    }\n\n    private void failAndRollbackCurrentXidQuietly() {\n        if (currentXid == null || !xaFacade.isOpen()) {\n            return;\n        }\n        Xid xid = currentXid;\n        try {\n            LOG.debug(\"remove current transaction, xid={}\", xid);\n            xaFacade.failAndRollback(xid);\n        } catch (Exception e) {\n            LOG.warn(\"unable to fail/rollback current transaction, xid={}\", xid, e);\n        } finally {\n            currentXid = null;\n        }\n    }\n\n    private void prepareCurrentTx() throws IOException {\n        checkState(currentXid != null, \"no current xid\");\n        outputFormat.flush();\n\n        Exception endAndPrepareException = null;\n        try {\n            xaFacade.endAndPrepare(currentXid);\n        } catch (Exception e) {\n            endAndPrepareException = e;\n            throw new JdbcConnectorException(\n                    JdbcConnectorErrorCode.XA_OPERATION_FAILED,\n                    \"unable to prepare current xa transaction\",\n                    e);","sourceCodeStart":303,"sourceCodeEnd":339,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/sink/JdbcExactlyOnceSinkWriter.java#L303-L339","documentation":"This is a WARN-level log emitted by JdbcExactlyOnceSinkWriter when it tries to roll back the current in-doubt XA transaction via the XA facade (xaResource.fail + rollback) and the XA operation throws. The writer swallows the exception because it is already in an error/cleanup path (abort or close); the transaction stays heuristically in-doubt in the database and currentXid is cleared regardless.","triggerScenarios":"abortPrepare or close calls failAndRollbackCurrentXidQuietly while the XA resource is disconnected, the XID is already completed/unknown on the DB side, or the DB rejects the fail/rollback command (XAER_RMFAIL, XAER_NOTA, connection lost).","commonSituations":"Job fails mid-transaction and the DB connection is already dead; database restarted between prepare and rollback; driver-level XA errors like 'XAER_RMFAIL: connection closed'; MySQL/Postgres cleaned up the transaction after timeout.","solutions":["Inspect the WARN's cause stack trace to identify the XA error code and fix the root connection/DB issue","Check DB-side in-doubt transactions (e.g. RECOVER PREPARED in Postgres, XA RECOVER in MySQL) and roll them back manually","Verify network stability and DB timeout settings (wait_timeout, transaction timeout) larger than checkpoint interval","Retry the failing job; Zeta recovery plus database-side cleanup restores exactly-once state"],"exampleFix":"// before: silent warn leaves DB transaction in doubt\n} catch (Exception e) {\n    LOG.warn(\"unable to fail/rollback current transaction, xid={}\", xid, e);\n}\n// after: record xid in state so recovery tooling can clean it up\n} catch (Exception e) {\n    LOG.warn(\"unable to fail/rollback current transaction, xid={}\", xid, e);\n    pendingRollbackXids.add(xid); // expose for monitoring/manual XA RECOVER\n}","handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"try {\n    xaFacade.failAndRollback(xid);\n} catch (Exception e) {\n    LOG.warn(\"XA rollback failed, inspect DB in-doubt txns for xid={}\", xid, e);\n    alertOpsForManualRecovery(xid); // XA RECOVER / RECOVER PREPARED\n}","preventionTips":["Set DB connection and transaction timeouts longer than the job's checkpoint interval","Monitor cluster/job failures so rollbacks happen while the DB connection is still healthy","Periodically scan for in-doubt XA transactions (XA RECOVER) and clean them","Keep network between workers and database reliable (health checks, retries)"],"tags":["jdbc","xa-transaction","rollback","exactly-once","database"],"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"}