<p>ER_XA_RBROLLBACK signals that the resource manager asked MySQL to roll back a prepared XA transaction branch instead of committing it.</p>
<p>MySQL Error 1402: ER_XA_RBROLLBACK means the resource manager rolled back an XA transaction branch, often due to timeouts or deadlocks. Clear the XA record with XA ROLLBACK and replay the logical work to resolve the issue.</p>
XA_RBROLLBACK: Transaction branch was rolled back
Error 1402 occurs during distributed XA transactions when a resource manager (RM) tells MySQL that a prepared branch must be rolled back. MySQL records this outcome with the ER_XA_RBROLLBACK condition and SQLSTATE XA100.
The message appears after XA PREPARE but before XA COMMIT, indicating that a two-phase commit could not finish successfully. Only the affected branch is reversed; other branches may still commit or roll back separately.
The RM may detect a deadlock, timeout, or integrity violation and decide the safest action is to undo the branch. Network issues, crashed nodes, or manual administrator intervention can also trigger the rollback reply.
Because XA uses a global transaction ID (XID), any participant that votes to roll back forces the coordinator to roll back the entire global transaction.
First, clear lingering XA records with XA RECOVER and XA ROLLBACK. Then replay the lost logical work in a new, healthy XA transaction. Verify that all RMs are reachable before issuing XA PREPARE again.
If the error repeats, investigate the RM logs for deeper issues such as missing indexes, lock scarcity, or configuration mismatches.
Timeout during long-running batch: shorten batch size or raise innodb_lock_wait_timeout. Deadlock between branches: revise access order or use READ COMMITTED isolation. Resource exhaustion: tune buffer pool and log file sizes.
Manual rollback from another system: coordinate commits with a global transaction manager or middleware that supports two-phase commit.
Keep XA branches short and idempotent. Monitor XA RECOVER output for stray XIDs. Configure uniform isolation levels across participants. Use a proven transaction coordinator when multiple databases are involved.
Galaxy users can script health checks and share endorsed recovery queries, ensuring team-wide consistency and faster incident response.
Error 1397 ER_XAER_RMFAIL happens when the RM is unavailable. Error 1398 ER_XAER_NOTA shows when an XID does not exist. Both require XA ROLLBACK or coordinator cleanup.
When an RM exceeds its configured timeout, it aborts the branch to free locks, leading to ER_XA_RBROLLBACK.
If the RM detects a cyclic wait, it resolves the deadlock by rolling back one branch and signalling the error.
Unique key or foreign key violations during prepare force the RM to vote rollback.
A lost connection during prepare may cause the RM to roll back automatically when it comes back online.
Admins can cancel a prepared branch, which surfaces as ER_XA_RBROLLBACK on the coordinator.
The resource manager is unavailable or shut down. Restart the RM and rollback or replay the XA branch.
The provided XID is unknown. Ensure you pass the exact identifier returned by XA START.
Invalid arguments in an XA statement. Check XID format and statement order.
Temporary failure. Retry the XA statement after resolving the underlying issue.
Yes. In two-phase commit, a single rollback vote forces the coordinator to undo the global transaction.
No. Once a participant votes rollback, the global transaction must be rolled back. Replay the business logic in a new XA cycle.
Run XA RECOVER to list prepared branches. Clean them up with XA COMMIT or XA ROLLBACK as appropriate.
Galaxy lets teams store and share vetted XA recovery scripts, reducing response time and preventing manual mistakes.