The XA transaction branch could not commit and must be retried later.
ER_XA_RETRY (MySQL error 3197) means the server could not commit the XA transaction branch due to temporary contention; wait briefly and issue XA COMMIT again to resolve it.
ER_XA_RETRY
MySQL error 3197, condition name ER_XA_RETRY, appears when the server cannot commit an XA transaction branch at the requested moment. It signals a transient state rather than a fatal failure and instructs the client or transaction manager to retry the commit.
First added in MySQL 5.7.19, the error commonly surfaces in distributed systems that coordinate transactions across multiple databases, message queues, or microservices using two-phase commit.
High lock contention blocks the branch from acquiring the resources needed to complete the commit, forcing MySQL to return ER_XA_RETRY instead of holding locks indefinitely.
Network latency or a short outage between the global transaction coordinator and the MySQL resource manager can leave the branch in a prepared state that is not yet safe to commit.
Long-running DDL, bulk updates, or slow autocommit statements on the same tables can delay the commit phase and trigger the retry response.
The primary fix is to wait briefly and re-issue XA COMMIT
. Well-written transaction managers implement automatic retries with exponential back-off.
If you commit branches manually, wrap the XA COMMIT
in a loop that retries a limited number of times and logs persistent failures for investigation.
Reduce lock contention by shortening transactions, adding supporting indexes, and splitting hot rows across shards or partitions.
Scenario: Two services update the same customer row in different XA branches. Solution: retry commits and redesign workload to avoid hotspot rows.
Scenario: XA prepare succeeded but a network flap delayed commit. Solution: commit after connectivity is restored or rely on automatic recovery at startup.
Keep XA branches small and short-lived so they hold locks for the minimum time required.
Monitor lock waits with performance_schema
and alert when waits exceed your SLA to catch issues before retries accumulate.
Use Galaxy’s lightning-fast SQL editor to inspect pending XA transactions, share retry scripts with the team, and endorse best-practice queries to prevent long-running locks.
ER_XA_RBROLLBACK indicates the branch rolled back instead of committing. Investigate why the coordinator issued a rollback and restart the transaction if needed.
ER_XAER_NOTA signals that the supplied XID is unknown. Verify the XID lifecycle and ensure the branch was prepared on this connection.
Row or table locks held by concurrent transactions.
Temporary network issues between XA coordinator and MySQL.
Uncommitted DDL or bulk operations on affected tables.
Long-running transactions exhausting InnoDB lock wait timeout.
The branch was rolled back by the resource manager; investigate the root cause before retrying.
The supplied XID does not correspond to any open XA transaction on the server.
Invalid arguments were passed to an XA command; check syntax and XID composition.
No data is lost. The branch is in a prepared state and simply needs to be committed once the blocking condition clears.
Most coordinators use 3 to 5 retries with exponential back-off, but tune based on your latency and lock wait requirements.
Yes, but only if your workload does not require atomicity across resources. Replace XA with local transactions or eventual consistency patterns.
Galaxy surfaces open transactions, lets teams share vetted retry scripts, and highlights long-running locks, helping you resolve ER_XA_RETRY faster.