MySQL as a Source: Data Synchronization Limits

更新时间:
复制 MD 格式

Read this page before you configure a DTS data synchronization task with MySQL as the source. It covers network requirements, source database prerequisites, and destination-specific constraints to help you prevent task failures and data inconsistency.

General limits

These limits apply to all synchronization tasks, regardless of source or destination database type.

Network

Requirement Value
Source database network bandwidth ≥ 100 Mb/s
Network RTT (Round-Trip Time) between source and DTS < 2 ms

Cross-region or cross-country deployments — for example, a source database in Singapore connected to DTS via a VPN in China (Hong Kong) — may cause RTT to exceed this limit, resulting in synchronization latency.

Business load

Scenario Limit
Peak log volume < 1 TB/day
Average hourly log volume < 50 GB
Peak traffic < 15 MB/s
High-frequency DDL operations ≤ 10 per second
Single transaction log volume < 100 GB
DTS pulls logs for the entire source database instance, not just the synchronized objects. Frequent writes to unrelated large tables generate logs that can cause synchronization latency, even when you synchronize only a small subset of tables.

Additional load considerations:

  • Batch updates: Large-scale updates to CLOB, BLOB, or LONG type columns may cause latency. Perform such operations in batches or schedule them during off-peak hours.

  • Tables without primary keys: Frequent DELETE or UPDATE operations on tables without primary keys may cause latency.

  • Large transactions: A single transaction with a log volume exceeding 100 GB may cause the task to fail.

Cross-account and cross-border synchronization

Cross-account synchronization: Support depends on the database type and connection type. See Configure Cross-Alibaba Cloud Account Tasks.

Cross-border data synchronization: Not enabled by default. Submit a request for cross-border data synchronization permission and pass the review before use.

Important

For cross-border and cross-region tasks, keep task bandwidth at or below 100 Mbit/s. If bandwidth exceeds this limit, configure cross-region network bandwidth using Cloud Enterprise Network (CEN) before configuring the DTS task.

Instance recovery

If a DTS instance fails, support will attempt to recover it within 8 hours. During recovery, the instance may be restarted or have its parameters adjusted.

Only DTS instance parameters are modified during recovery — database parameters are not changed. For the parameters that may be modified, see Modify Instance Parameters.

Source database limits

The following requirements apply when your source database is a MySQL-series database.

Account permissions

Self-managed MySQL requires the following permissions:

Permission Required for
SELECT Objects to be synchronized
REPLICATION SLAVE Incremental data synchronization (CDC)
REPLICATION CLIENT Incremental data synchronization (CDC)
SHOW VIEW All tasks
Database and table creation Allows DTS to periodically run CREATE DATABASE IF NOT EXISTS \test\`` to advance the binary logging offset

ApsaraDB RDS for MySQL: Provide an account with read and write permission.

To synchronize database accounts from the source, see Migrate Database Accounts for prerequisites and considerations.

Binary logging configuration

Parameter Required value Applies to
Binary logging Enabled All MySQL sources
binlog_row_image FULL All MySQL sources
binlog_format ROW Self-managed MySQL only
log_slave_updates Enabled Self-managed MySQL with dual-primary or cascading replication architecture

To verify the current values, run the following queries on the source database:

-- Check binary logging status (MySQL 8.x)
SELECT variable_value AS "Binary logging status"
FROM performance_schema.global_variables
WHERE variable_name = 'log_bin';

-- Check binlog_row_image and binlog_format
SHOW GLOBAL VARIABLES WHERE variable_name IN ('binlog_row_image', 'binlog_format');

Binary log retention period

Source type Minimum retention
Self-managed MySQL > 7 days
ApsaraDB RDS for MySQL > 3 days

Retaining binary logs for less than the required period may cause DTS task failures because logs become unavailable. In extreme cases, this can lead to data inconsistency or data loss. Issues caused by insufficient retention periods are not covered by the DTS Service Level Agreement (SLA).

Tables and primary keys

All tables to be synchronized must have a primary key or a UNIQUE constraint with unique field values. Without these, data duplication may occur in the destination.

To find tables without primary keys in the source database, run:

SELECT
  t.TABLE_SCHEMA AS table_schema,
  t.TABLE_NAME AS table_name
FROM information_schema.TABLES t
LEFT JOIN information_schema.TABLE_CONSTRAINTS tc
  ON t.TABLE_SCHEMA = tc.TABLE_SCHEMA
  AND t.TABLE_NAME = tc.TABLE_NAME
  AND tc.CONSTRAINT_TYPE = 'PRIMARY KEY'
WHERE t.TABLE_TYPE = 'BASE TABLE'
  AND tc.CONSTRAINT_NAME IS NULL
  AND t.TABLE_SCHEMA NOT IN ('information_schema', 'performance_schema', 'mysql', 'sys')
ORDER BY t.TABLE_SCHEMA, t.TABLE_NAME;
For Two-way Synchronization links (such as MySQL to MySQL), enable the Exactly-Once write feature in the task to accurately synchronize data from tables without primary keys or UNIQUE constraints. See Synchronize Tables Without Primary Keys and UNIQUE Constraints.

Table quantity limit: If the synchronization scope is table-level and requires column mapping, a single task supports a maximum of 1,000 tables. If this limit is exceeded, split the tables across multiple tasks or configure a full database synchronization task.

Invisible columns (MySQL 8.0.23 and later)

If the source database is MySQL 8.0.23 or later, check for invisible columns in the objects to be synchronized. Make them visible before starting the task:

ALTER TABLE <table_name> ALTER COLUMN <column_name> SET VISIBLE;

Also set automatically generated invisible primary keys (for tables without primary keys) to visible. Failing to do so may cause data loss because DTS cannot retrieve data for invisible columns.

Version compatibility

Synchronize from a lower version to a higher version, or keep source and destination versions consistent. Synchronizing from a higher version to a lower version may cause compatibility issues.

MySQL compatibility

When DTS synchronizes data from a MySQL-family source database, it relies on the standard MySQL protocol and Binlog format, and behaviors incompatible with standard MySQL are not supported. If your source database claims MySQL compatibility but behaves differently from MySQL (for example, when OceanBase is connected as a source in MySQL mode, the timestamp of the trailing rotate event in the Binlog is 0, which differs from MySQL), the DTS synchronization task may fail.

Unsupported source databases

  • ApsaraDB RDS for MySQL 5.6 read-only instances (which do not record transaction logs)

  • ApsaraDB RDS for MySQL instances with the always-confidential feature enabled (Full Data Synchronization is not supported; Transparent Data Encryption (TDE) is not affected)

Cluster read/write node requirement

If the source is Amazon Aurora MySQL or another cluster-mode MySQL instance, connect DTS to a read/write (RW) node that is always available. Connecting to a read-only node may cause the synchronization task to run incorrectly.

During synchronization

Performance impact

Full Data Synchronization initialization consumes read and write resources from both the source and destination databases. Perform data synchronization during off-peak hours to minimize impact.

DDL restrictions

Do not perform DDL during schema or full data synchronization: DDL operations that change the database or table schema during Schema Synchronization or Full Data Synchronization will cause the task to fail.

During full synchronization, DTS queries the source database, which creates metadata locks. These locks may block DDL operations on the source database.

Unsupported DDL types: The following DDL operations are not supported and may cause data loss or task failure:

  • DDL parsers defined using comment syntax

  • Online DDL in temporary table mode (including multi-table merge scenarios)

  • Adding function-based indexes to unique key columns

Online DDL tool restriction: If the synchronization scope is a single table or multiple tables (not the entire database), do not use tools such as pt-online-schema-change on the synchronized objects during the task. This causes synchronization failure.

Operations not captured by binary logs

DTS cannot detect or synchronize data changes from operations that are not written to binary logs, including:

  • Foreign key cascade updates and deletes

  • Data recovery through physical backup

If this affects your data, and if your business allows, remove the affected tables from the synchronization scope using the modify synchronization object feature, then add them back. See Modify Synchronization Objects.

Primary/secondary switchover

If a self-managed MySQL source instance undergoes a primary/secondary switchover, the synchronization task will fail.

Synchronization latency

DTS calculates latency by comparing the timestamp of the last synchronized record with the current time. If no DML operations occur for an extended period, the latency reading may be inaccurate.

To get an accurate latency reading, run a DML operation on the source database.

If the entire database is the synchronization scope, create a heartbeat table that writes data every second.

Two-way synchronization limits

The following additional limits apply to two-way synchronization tasks.

  • Automatic full verification: When a bidirectional synchronization task is in a specific region (China (Hangzhou), China (Shenzhen), or China (Guangzhou)) and includes Full Data Synchronization, DTS automatically creates a full verification task for that full synchronization task. This task uses the Full Data Verification of Verify based on the number of table rows. If you have already configured a full verification task, your configured task takes precedence.

Anti-looping database

DTS automatically creates a dts database in the destination databases of both the forward and reverse tasks to prevent data looping. While the task runs:

  • Do not modify the dts database.

  • The task account must have read and write permission on the dts database.

The dts database may affect normal MySQL primary/secondary synchronization. Check whether the dts database and its tables exist in the secondary database. If not, manually create them based on the schema in the primary database.

Unidirectional full initialization

When configuring a two-way synchronization task, if the destination of one task overlaps with the source of another:

  • Only one direction can perform Full Data Synchronization and Incremental Data Synchronization.

  • The other direction supports only Incremental Data Synchronization to ensure correct data initialization.

  • Synchronized data does not cascade: data written to the destination of one task is not picked up as source data by the other task.

log_slave_updates for shared source databases

If a self-managed MySQL instance serves as the source for both a two-way synchronization task and other DTS tasks, set log_slave_updates=1 in its configuration file and restart the database. This ensures that data changes synchronized from the other direction are recorded in binary logs and captured by other tasks.

Destination database limits

ApsaraDB RDS for MySQL

Before synchronization

Requirement Details
Storage space Available space in the destination must exceed the space used by the source tables
Character set If data contains four-byte characters (rare characters or emojis), set character_set_server to utf8mb4
Always-confidential (EncDB) Full Data Synchronization is not supported; TDE is not affected
Account permissions Read and write permission required
Field compatibility If Schema Synchronization is not selected, verify field type compatibility between source and destination. For example, synchronizing a TEXT field to a VARCHAR(255) field may truncate data

During synchronization

Prohibit external writes: During synchronization, no program or user other than DTS should write to the destination database. External writes cause data conflicts and inconsistency.

Primary key and unique key conflict handling:

Schema consistency Phase Behavior
Consistent Full Data Synchronization DTS retains the destination record and skips the conflicting source record
Consistent Incremental Data Synchronization DTS overwrites the destination record with the source record
Inconsistent Any Data initialization may fail, only partial columns may synchronize, or synchronization may fail

DDL failure handling: If a synchronized DDL fails in the destination database, DTS logs the failure and continues synchronizing DML. View failed DDL operations in the task logs. See Query Task Logs.

Case sensitivity: MySQL uses a case-insensitive policy by default. Writing column names that differ only in case to the same table may produce unexpected results.

Foreign keys and constraints:

  • During Schema Synchronization, DTS synchronizes foreign keys from the source to the destination.

  • During Full Data Synchronization and Incremental Data Synchronization, DTS temporarily disables constraint checks and foreign key cascade operations at the session level. If the source has cascade update or delete operations during this time, data inconsistency may occur.

Tablespace growth: During Full Data Synchronization, DTS uses high-concurrency INSERT operations, which may cause internal fragmentation. The destination table's space usage may be larger than the source table's after synchronization. This is expected behavior.

Data integrity verification: After the task Status shows Completed, run the following command in the destination database to confirm all data has been written:

ANALYZE TABLE <table_name>;

This step is especially important after a high-availability (HA) switchover in the destination database, where data may reside only in memory.

Supported SQL operations

DML: INSERT, UPDATE, DELETE

DDL:

  • CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE TABLE, RENAME TABLE

  • CREATE VIEW, ALTER VIEW

  • CREATE INDEX, DROP INDEX

  • CREATE PROCEDURE, CREATE FUNCTION

Executing RENAME TABLE on a table that is a partial synchronization object may cause that table's data to stop synchronizing after the rename. To avoid this, use the entire database as the synchronization scope, and make sure both the source and destination database names are included in the synchronization objects.
For Two-way Synchronization links, only forward tasks (source to destination) support DDL synchronization. Reverse tasks (destination to source) automatically filter out DDL operations.

Message Queue for Apache Kafka

Before synchronization

  • Create a topic: Create a topic in the destination Kafka instance before starting the task to receive data. See Step 1: Create a Topic.

  • Storage space: Available storage in the destination Kafka instance must exceed the space used by the source database.

  • Avoid large object columns: Do not synchronize unnecessary TEXT or BLOB columns to prevent message body overflow or performance issues.

During synchronization

Single record size limit: If a serialized row exceeds the Kafka maximum message size (max.message.bytes for self-managed Kafka; check the console for cloud instances), the task is interrupted. To resolve this:

  • Filter out columns with large objects when configuring the task.

  • If the task is already running, remove the affected table from the synchronization scope, then add it back with the large object columns filtered out.

Prohibit external writes: No program other than DTS should write to the destination topic. External writes cause data inconsistency.

Kafka cluster scaling: If the destination Kafka cluster scales out or in during synchronization, restart the DTS synchronization task.

Tablespace growth: During Full Data Synchronization, DTS uses high-concurrency INSERT operations, which may cause internal fragmentation. The destination space usage may be larger than the source. This is expected behavior.

Supported SQL operations

DML: INSERT, UPDATE, DELETE

DDL:

  • CREATE TABLE, ALTER TABLE, DROP TABLE, TRUNCATE TABLE, RENAME TABLE

  • CREATE VIEW, ALTER VIEW, DROP VIEW

  • CREATE PROCEDURE, ALTER PROCEDURE, DROP PROCEDURE

  • CREATE FUNCTION, DROP FUNCTION

  • CREATE TRIGGER, DROP TRIGGER

  • CREATE INDEX, DROP INDEX

DDL synchronized to Kafka is delivered as a message type. For the message format, see Data Storage Format in Message Queue.

AnalyticDB for MySQL 3.0

Before synchronization

Requirement Details
Primary key The destination table must have a custom primary key, or configure a Primary Key Column during the Configurations for Databases, Tables, and Columns phase
Disk usage If disk usage exceeds 80%, the task fails due to write errors. Estimate required space and make sure the cluster has sufficient storage before starting
Cluster status If the destination cluster is in a backup state, the task will fail
Prefix indexes The source database cannot have prefix indexes; synchronization may fail if they exist

During synchronization

Prohibit external writes: No program or user other than DTS should write to the destination database. External writes cause data conflicts and inconsistency.

Primary key and unique key conflict handling:

Schema consistency Phase Behavior
Consistent Full Data Synchronization DTS retains the destination record and skips the conflicting source record
Consistent Incremental Data Synchronization DTS overwrites the destination record with the source record
Inconsistent Any Data initialization may fail, only partial columns may synchronize, or synchronization may fail

DDL failure handling: If a synchronized DDL fails in the destination, DTS logs the failure and continues synchronizing DML. See Query Task Logs.

DDL restrictions during synchronization:

  • Do not perform DDL operations on the source database that modify primary keys or add table comments (for example, ALTER TABLE table_name COMMENT='Table comment';). These operations fail during synchronization.

  • For table-level synchronization where no data other than DTS writes to the destination, use Data Management Service (DMS) for online DDL. See Schema Changes Without Locking Tables.

Tablespace growth: During Full Data Synchronization, DTS uses high-concurrency INSERT operations, which may cause internal fragmentation. The destination space usage may be larger than the source. This is expected behavior.

Supported SQL operations

DML: INSERT, UPDATE, DELETE

UPDATE statements are automatically converted to REPLACE INTO. If a primary key is updated, the operation converts to DELETE + INSERT.

DDL:

  • CREATE TABLE, DROP TABLE, RENAME TABLE, TRUNCATE TABLE

  • ADD COLUMN, MODIFY COLUMN, DROP COLUMN

Not supported: INDEX, PARTITION, VIEW, PROCEDURE, FUNCTION, TRIGGER, foreign keys (FK)

Executing RENAME TABLE on a table that is a partial synchronization object may cause that table's data to stop synchronizing after the rename. To avoid this, use the entire database as the synchronization scope and make sure both the source and destination database names are included in the synchronization objects.

Recovering from a field type change

If you change the field type of a source table during synchronization, the task fails and stops. Resolve this manually:

  1. The source table (for example, customer) fails synchronization due to the field type change.

  2. Create a new table (customer_new) in AnalyticDB for MySQL 3.0. Match its schema exactly to the updated customer table.

  3. Copy data from customer to customer_new:

    INSERT INTO customer_new SELECT * FROM customer;

    Verify data consistency between the two tables.

  4. Rename or delete the failed customer table, then rename customer_new to customer.

  5. On the DTS console, restart the data synchronization task.