Data Transmission Service (DTS) supports two-way data synchronization between two PostgreSQL databases, such as databases on an ApsaraDB RDS for PostgreSQL instance and self-managed PostgreSQL databases. This feature is applicable to scenarios such as active geo-redundancy (unit-based) and geo-disaster recovery. This topic describes how to configure two-way data synchronization between ApsaraDB RDS for PostgreSQL instances. You can also follow the procedure to configure data synchronization tasks for self-managed PostgreSQL databases.
Prerequisites
- The source and destination ApsaraDB RDS for PostgreSQL instances are created. For more information, see Create an ApsaraDB RDS for PostgreSQL instance.
- The wal_level parameter is set to logical for the source and destination ApsaraDB RDS for PostgreSQL instances. For more information, see Manage the parameters of an ApsaraDB RDS for PostgreSQL instance.
Limits
Category | Description |
---|---|
Limits on the source and destination databases |
|
Other limits |
|
Special cases | If the source instance is an ApsaraDB RDS for PostgreSQL instance, take note of the
following limits:
During data synchronization, do not modify the endpoint and zone of the ApsaraDB RDS for PostgreSQL instance. Otherwise, the data synchronization task fails. |
Billing
Synchronization type | Task configuration fee |
---|---|
Schema synchronization and full data synchronization | Free of charge. |
Incremental data synchronization | Charged. For more information, see Pricing. |
Supported synchronization topologies
DTS supports two-way data synchronization only between two PostgreSQL databases. DTS does not support two-way data synchronization between multiple PostgreSQL databases.
Conflict detection
To ensure data consistency, make sure that data records with the same primary key, business primary key, or unique key are updated only on one of the synchronization nodes. If data records are updated on both nodes, DTS responds to conflicts based on the conflict resolution policy that you specify for the data synchronization task.
- Uniqueness conflicts caused by INSERT operations
INSERT operations that do not comply with the uniqueness constraint cannot be synchronized. For example, if a record with the same primary key value is inserted into the two synchronization nodes at almost the same time, one of the inserted records fails to be synchronized. The synchronization fails because a record with the same primary key value already exists in the other node.
- Inconsistent records caused by UPDATE operations
- If the records to be updated do not exist in the destination instance, DTS converts the UPDATE operation into an INSERT operation. However, uniqueness conflicts may occur.
- The primary keys or unique keys of the records to be inserted may conflict with those of existing records in the destination instance.
- Non-existent records to be deleted
The records to be deleted do not exist in the destination instance. In this case, DTS ignores the DELETE operation regardless of the conflict resolution policy that you specify.
- During two-way synchronization, the system time of the source and destination instances may be different. Synchronization latency may occur. For these reasons, DTS cannot guarantee that the conflict detection mechanism can prevent all data conflicts. To perform two-way synchronization, make sure that records with the same primary key, business primary key, or unique key are updated only on one of the synchronization nodes.
- DTS provides conflict resolution policies to prevent conflicts that may occur during data synchronization. You can select a conflict resolution policy when you configure two-way data synchronization.
SQL operations that can be synchronized
Operation type | SQL statement |
---|---|
DML | INSERT, UPDATE, and DELETE |