The distributed transactions that are described in this topic are intended for users who use MySQL 5.7 and PolarDB-X 1.0 V5.3.4 and later.

Overview

If the version of the MySQL engine in your custom ApsaraDB RDS for MySQL instance is 5.7 or later, PolarDB-X 1.0 processes distributed transactions based on the XA protocol by default.

For more information about how to use distributed transactions on other versions of custom ApsaraDB RDS for MySQL instances in PolarDB-X 1.0, see Distributed transactions based on MySQL 5.6.

Usage

The user experience of distributed transactions on PolarDB-X 1.0 is the same as that on standalone databases that run the MySQL engine. Examples:

  • You can run SET AUTOCOMMIT=0 to start a transaction.
  • You can run COMMIT to commit a transaction.
  • You can run ROLLBACK to roll back a transaction.

If SQL statements in a transaction involve only a single shard, PolarDB-X 1.0 treats the transaction as a non-distributed transaction. In this case, the system directly routes the transaction to a custom ApsaraDB RDS for MySQL instance. If SQL statements in a transaction are used to modify data in multiple shards, PolarDB-X 1.0 automatically upgrades the transaction to a distributed transaction.

FAQ

Q: Do I need to enable distributed transactions in the console?

A: No. You can use distributed transactions in the same way as you use them on standalone MySQL databases as long as your MySQL version and PolarDB-X 1.0 version meet the requirements.

Q: Which versions of MySQL and PolarDB-X 1.0 are required to use distributed transactions?

A: To use the latest distributed transactions, MySQL 5.7 and later and PolarDB-X 1.0 V5.3.4 and later are required.PolarDB-X 1.0 If the MySQL version and PolarDB-X 1.0 version does not meet this requirement, we recommend you to upgrade your PolarDB-X 1.0 instances and custom ApsaraDB RDS for MySQL instances to the latest versions. For more information about how to use distributed transactions on other versions of custom ApsaraDB RDS for MySQL instances and PolarDB-X 1.0 instances, see Distributed transactions based on MySQL 5.6.