{"record":{"id":"b48e25be7aa941f4","repo":"apache/seatunnel","slug":"xa-operation-failed-b48e25","errorCode":"XA_OPERATION_FAILED","errorMessage":"reached max number of commit attempts (%d) for transactions: %s","messagePattern":"reached max number of commit attempts \\((.+?)\\) for transactions: (.+?)","errorType":"error_code","errorClass":"JdbcConnectorException","httpStatus":null,"severity":"critical","filePath":"seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/xa/XaGroupOpsImpl.java","lineNumber":162,"sourceCode":"                    LOG.info(\"unable to rollback recovered transaction, xid={}\", xid, e);\n                }\n            }\n        }\n    }\n\n    private static void throwIfAnyReachedMaxAttempts(\n            GroupXaOperationResult<XidInfo> result, int maxAttempts) {\n        List<XidInfo> reached = null;\n        for (XidInfo x : result.getForRetry()) {\n            if (x.getAttempts() >= maxAttempts) {\n                if (reached == null) {\n                    reached = new ArrayList<>();\n                }\n                reached.add(x);\n            }\n        }\n        if (reached != null) {\n            throw new JdbcConnectorException(\n                    JdbcConnectorErrorCode.XA_OPERATION_FAILED,\n                    String.format(\n                            \"reached max number of commit attempts (%d) for transactions: %s\",\n                            maxAttempts, reached));\n        }\n    }\n}\n","sourceCodeStart":144,"sourceCodeEnd":170,"githubUrl":"https://github.com/apache/seatunnel/blob/cf67b549a7a6c35fa0beb12d83c62892427ea919/seatunnel-connectors-v2/connector-jdbc/src/main/java/org/apache/seatunnel/connectors/seatunnel/jdbc/internal/xa/XaGroupOpsImpl.java#L144-L170","documentation":"XaGroupOpsImpl tracks how many times each pending XA transaction's commit has been retried. throwIfAnyReachedMaxAttempts is called from commit and, when one or more transactions have been attempted maxAttempts times without success, throws XA_OPERATION_FAILED listing the transactions. This prevents infinite commit retry loops on transactions that can never commit.","triggerScenarios":"Repeated checkpoint/commit cycles where the database persistently rejects XA commit (e.g. the transaction is in a heuristic or abandoned state, or connection failures recur) until maxCommitAttempts is reached.","commonSituations":"Database outage during multiple checkpoints; a stuck 'in-doubt' transaction that needs manual XA recovery; too-low configured max attempts combined with flaky network.","solutions":["Inspect the listed transactions on the database side (XA recovery / in-doubt transactions) and manually commit or rollback them.","Increase the configured max commit attempts to tolerate transient outages.","Fix the root connectivity/authorization failure causing commits to keep failing.","After manual recovery, restart the job; pending transactions should be recoverable via XA recovery."],"exampleFix":"// before\nmax_commit_attempts = 3\n// after\nmax_commit_attempts = 10","handlingStrategy":"retry","validationCode":"// monitor pending XA transactions before they exhaust attempts\n// SELECT * FROM pg_prepared_xacts;  -- PostgreSQL in-doubt transactions","typeGuard":null,"tryCatchPattern":"try {\n  xaGroupOps.commit(xids);\n} catch (JdbcConnectorException e) {\n  if (e.getMessage() != null && e.getMessage().contains(\"reached max number of commit attempts\")) {\n    // resolve in-doubt XAs manually on the DB, then restart job for XA recovery\n  }\n  throw e;\n}","preventionTips":["Set max commit attempts generously enough to survive transient outages.","Regularly inspect and clean in-doubt transactions on the database.","Fix connectivity/auth problems that make commits fail repeatedly.","Alert on persistent XA commit failures before the attempt cap is reached."],"tags":["jdbc","xa","commit","retry-limit"],"backgroundTag":"rate-limit-exceeded","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"}