- What's New
- Service Overview
- Getting Started
-
User Guide
- Function Overview
- Permissions Management
-
Instance Management
- Buying a DDM Instance
- Splitting Read-only and Read-Write Services
- Changing Class of a DDM Node
- Scaling Out a DDM Instance
- Scaling In a DDM Instance
- Changing Billing Mode of a DDM Instance
- Renewing a DDM Instance
- Restarting a DDM Instance
- Unsubscribing from a DDM Instance
- Deleting a DDM Instance
- Modifying Parameters of a DDM Instance
- Splitting Read and Write Requests
- Configuring a Parameter Template
- Connection Management
-
Parameter Template Management
- Creating a Parameter Template
- Editing a Parameter Template
- Comparing Two Parameter Templates
- Viewing Parameter Change History
- Replicating a Parameter Template
- Applying a Parameter Template
- Viewing Application Records of a Parameter Template
- Modifying the Description of a Parameter Template
- Deleting a Parameter Template
- Task Center
- Schema Management
- Shard Configuration
- Data Node Management
- Account Management
- Backups and Restorations
-
Data Migration
- Overview
- Migration Evaluation
- Scenario 1: Migrating Data from Huawei Cloud RDS to DDM
- Scenario 2: Migrating Data from an On-Premises RDS Instance for MySQL to DDM
- Scenario 3: Migrating Data from a Third-Party RDS for MySQL Instance to DDM
- Scenario 4: Migrating Data from a Self-Built MySQL Instance to DDM
- Scenario 5: Migrating Data from Heterogeneous Databases to DDM
- Scenario 6: Exporting Data from a DDM Instance
- Slow Queries
- Monitoring Management
- Auditing
-
SQL Syntax
- Introduction
- DDL
- DML
- Functions
- Use Constraints
- Supported SQL Statements
- Global Sequence
- Database Management Syntax
- Advanced SQL Functions
- Quotas
- Change History
-
API Reference
- Before You Start
- API Overview
- Calling APIs
-
APIs (Recommended)
-
DDM Instances
- Buying a DDM instance
- Querying DDM Instances
- Querying Details of a DDM Instance
- Modifying the Name of a DDM Instance
- Modifying the Security Group of a DDM Instance
- Deleting a DDM Instance
- Restarting a DDM Instance
- Reloading Table Data
- Scaling out a DDM instance
- Scaling in a DDM instance
- Modifying the Read Policy of the Associated DB Instance
- Synchronizing Data Node Information
- Querying Nodes of a DDM Instance
- Querying Details of a DDM Instance Node
- Querying Parameters of a Specified DDM Instance
- Modifying Parameters of a DDM Instance
- Querying DDM Engine Information
- Querying DDM Node Classes Available in an AZ
- Changing the Node Class of a DDM Instance
- Schemas
- DDM Accounts
- Monitoring
-
DDM Instances
- APIs (Unavailable Soon)
- Appendix
- Change History
- SDK Reference
-
Best Practices
- Overview
- Formulating Sharding Rules
- Determining the Number of Shards in a Schema
- Using Broadcast and Unsharded Tables
- Transaction Models
- SQL Standards
- Migrating an Entire RDS Database to DDM
- Migrating an Entire MyCat Database to DDM
- Accessing DDM Using a JDBC Connection Pool
- Logging In to a DDM Instance Using Navicat
- Migrating Data from RDS for MySQL to DDM Using DRS
- Performance White Paper
-
FAQs
- General Questions
-
DDM Usage
- How Does DDM Perform Sharding?
- What Do I Do If I Fail to Connect to a DDM Instance Using the JDBC Driver?
- What Version and Parameters Should I Select?
- Why It Takes So Long Time to Export Data from MySQL Using mysqldump?
- What Do I Do If a Duplicate Primary Key Error Occurs When Data Is Imported into DDM?
- What Should I Do If an Error Message Is Returned When I Specify an Auto-Increment Primary Key During Migration?
- What Do I Do If an Error Is Reported When Parameter Configuration Does Not Time Out?
- Which Should I Delete First, a Schema or its Associated RDS Instances?
- Can I Manually Delete Databases and Accounts Remained in Data Nodes After a Schema Is Deleted?
- SQL Syntax
- RDS-related Questions
- Connection Management
- Resource Freezing, Release, Deletion, and Unsubscription
- Change History
- Videos
Transaction Models
Tables in each DDM instance are usually sharded, so data in the tables may be distributed across different database shards in multiple RDS instances. In DDM, one transaction to add, delete, update, or query a logical table is possibly executed on different database shards in multiple RDS instances, so a series of operations on data tables in one shard of an RDS instance can be deemed as a local transaction. Therefore, one DDM transaction is actually a distributed transaction that consists of local transactions on multiple RDS instances. These local transactions either all succeed, or all fail.
Implementation of Distributed Transactions in DDM
DDM executes 2PC distributed transactions using the MySQL XA protocol.
In a distributed system, each participant knows whether their operation succeeds or fails, but cannot know the status of the operation on other nodes. If a transaction encompasses multiple nodes, to guarantee atomicity and consistency of a transaction, a coordinator is introduced to control operation results of all participants so that all of the transaction's changes either take effect or do not. The DDM node acts as a coordinator in the distributed transaction, and RDS instances are participants.
The two-phase commit protocol breaks a database commit into two phases:
- Prepare phase: Participants notify the coordinator of the operation result. If the participants give a response that they are prepared, they must reserve resources required before the coordinator makes a decision.
- Commit phase: After receiving a notification from the participants, the coordinator sends a notification to the participants again and determines whether the participant needs to commit or roll back the operation based on their response.
For example:
Four people A, B, C, and D want to have a dinner party, so they need to determine the time. Now assume that A is the coordinator and B, C, and D are participants.
Prepare phase:
- A sends a text message to B, C, and D, asking them whether they are available on Tuesday noon.
- D replies yes.
- B replies yes.
- C does not reply for a long time. The time is not determined, so A, B, C, and D cannot continue their dinner party.
- C replies yes or no.
Commit phase:
- Coordinator A sends the collected results (Tuesday dinner party) to B, C, and D. What the result is and when does A feed it back to the other three depends on the time when C replies.
- B received.
- C received.
- D received.
- If any of them does not receive the result, A continues to send it until all of them receive the result.
2-Phase Commit
When DDM processes a transaction, applications run BEGIN/COMMIT as they do on a common transaction, without worrying about whether there are distributed transactions at the underlying layer. DDM automatically processes distributed transactions using the two-phase commit (2PC) protocol. If a transaction involves only one data shard, DDM will process it using the one-phase commit protocol. The one-phase commit protocol will not be described in details here.

XID is the global unique serial number of each distributed transaction. It consists of the transaction serial number, node ID, and timestamp. The XID and the corresponding shard name together constitute the XA_ID that initiates a distributed transaction on a physical database.
Suggestions for Using Transactions
- DDM supports distributed transactions. If all SQL statements in a transaction use the same sharding key, DDM can process the transaction as a single-shard transaction to achieve optimal performance.
- DDM uses the 2PC protocol to process distributed transactions. RDS deadlock detection does not take effect for distributed transactions across RDS instances. If a lock wait times out, there may be a cross-shard deadlock. In this case, check your business model.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.