Common SQL Errors

MySQL Error 1614: ER_XA_RBDEADLOCK - Fix Deadlock in XA Transaction

Galaxy Team
August 7, 2025

<p>The server rolled back an XA transaction branch because a lock deadlock was detected.</p>

Sign up for the latest in common SQL errors from the Galaxy Team!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

What is MySQL Error 1614 ER_XA_RBDEADLOCK?

<p>MySQL Error 1614: ER_XA_RBDEADLOCK signals that an XA transaction branch was rolled back after the server detected a deadlock. Release conflicting locks or redesign the two-phase commit flow to eliminate circular waits, then retry the transaction.</p>

Error Highlights

Typical Error Message

XA_RBDEADLOCK: Transaction branch was rolled back:

Error Type

Transaction Error

Language

MySQL

Symbol

ER_XA_RBDEADLOCK

Error Code

1614

SQL State

XA102

Explanation

Table of Contents

What is MySQL Error 1614 ER_XA_RBDEADLOCK?

The error appears when MySQL aborts a branch of a distributed XA transaction during the prepare or commit phase because a deadlock was discovered. The server rolls back the branch and returns SQLSTATE XA102.

Why does MySQL choose rollback?

In two-phase commit, consistency outranks liveness. When InnoDB detects that locks held by one XA branch block another in a circular wait, it rolls back the youngest victim to break the deadlock and preserve atomicity across resources.

When does this error surface?

The message surfaces during XA START, XA END, XA PREPARE, or XA COMMIT statements if the branch still holds row or metadata locks that conflict with another session running inside the same global transaction or a separate workload.

Is data lost after the rollback?

The rolled-back branch loses its uncommitted changes, but other branches of the XA transaction remain intact until a decision is taken. Coordinators should detect the RB reply and decide whether to issue XA ROLLBACK to all participants or retry.

How is this different from classic deadlocks?

Classic InnoDB deadlocks involve local transactions. ER_XA_RBDEADLOCK is specific to distributed transactions and guarantees that the participant unilaterally rolled back, requiring the coordinator to react.

Common Causes

Conflicting row updates

Two XA branches update the same rows in reverse order, creating a circular wait on row locks.

Gap locks during range scans

Range queries with LOCK IN SHARE MODE under REPEATABLE READ hold gap locks that block inserts from another branch.

Long-running XA branch

A branch keeps locks open between XA END and XA PREPARE, increasing the window for deadlocks.

Mixed autocommit traffic

Autocommit statements executed in the same session as an XA branch introduce extra locks and contention.

Related Errors

MySQL Error 1213: ER_LOCK_DEADLOCK

Standard InnoDB deadlock during local transactions; no XA involvement.

MySQL Error 1397: XAER_RMERR

Participant reports a resource manager error during XA operation.

MySQL Error 1400: XAER_NOTA

The XA transaction identifier is unknown or already completed.

MySQL Error 1613: ER_XA_RBROLLBACK

Generic rollback of an XA branch for reasons other than deadlock.

FAQs

Does ER_XA_RBDEADLOCK always require a full rollback?

Yes. The branch reporting the error is already rolled back. The coordinator should decide whether to roll back the entire global transaction or retry the failed branch.

Can I disable gap locks to avoid this error?

You can lower the isolation level to READ COMMITTED or enable innodb_locks_unsafe_for_binlog, but you risk phantom reads and data inconsistency. Prefer proper lock ordering.

How do I monitor XA deadlocks proactively?

Enable performance_schema tables like events_transactions_summary_by_thread. Poll them or use Galaxy alerts to flag repeat deadlocks.

Is this error unique to InnoDB?

The code is emitted by MySQL, but any storage engine that supports XA and deadlock detection could trigger it. In practice, InnoDB is the common source.

Start Querying with the Modern SQL Editor Today!
Welcome to the Galaxy, Guardian!
You'll be receiving a confirmation email

Follow us on twitter :)
Oops! Something went wrong while submitting the form.

Check out some other errors

Trusted by top engineers on high-velocity teams
Aryeo Logo
Assort Health
Curri
Rubie Logo
Bauhealth Logo
Truvideo Logo