This topic describes the usage notes and limits when you synchronize data from a PostgreSQL database, such as a self-managed PostgreSQL database and an ApsaraDB RDS for PostgreSQL database. To ensure that your data synchronization task runs as expected, you must read the usage notes and limits before you configure the task.

Scenarios of synchronizing data from a PostgreSQL database

Take note of usage notes and limits in the following data synchronization scenarios:
Note
By default, Data Transmission Service (DTS) disables FOREIGN KEY constraints for the destination database in a data synchronization task. Therefore, the cascade and delete operations of the source database are not synchronized to the following destination databases:
  • RDS PostgreSQL
  • AnalyticDB for PostgreSQL instance
  • PolarDB O
  • RDS MySQL

Synchronize data between PostgreSQL databases

  • The following table describes the usage notes and limits when you configure one-way synchronization between ApsaraDB RDS for PostgreSQL instances.
    Category Description
    Limits on the source database
    • The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
    • If you select tables as the objects to be synchronized and you want to edit the tables (such as renaming tables or columns) in the destination database, you can synchronize up to 5,000 tables in a single data synchronization task. If you run a task to synchronize more than 5,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to synchronize the tables in batches or configure a task to synchronize the entire database.
    • The following requirements for write-ahead logging (WAL) logs must be met:
      • The value of the wal_level parameter must be set to logical.
      • If you perform only incremental data synchronization, the WAL logs of the source database must be stored for more than 24 hours. If you perform both full data synchronization and incremental data synchronization, the WAL logs of the source database must be stored for at least seven days. Otherwise, DTS may fail to obtain the WAL logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. After the full data synchronization is complete, you can set the retention period to more than 24 hours. Make sure that you set the retention period of WAL logs based on the preceding requirements. Otherwise, the service reliability and performance stated in the Service Level Agreement (SLA) of DTS may not be guaranteed.

    • Limits on operations:

      If you want to perform a primary/secondary switchover on the source ApsaraDB RDS for PostgreSQL instance, the Logical Replication Slot Failover feature must be enabled. This prevents logical subscriptions from being interrupted and ensures that your data synchronization task can run as expected. For more information, see Logical Replication Slot Failover.

    Other limits
    • A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
    • If the schema is selected as the object to be synchronized, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL;statement in the destination table before the data synchronization starts. This ensures data consistency. When you execute this statement, we recommend that you do not lock the table. Otherwise, a deadlock occurs.
      Note
      • Replace the schema and table in the preceding sample statement with the actual schema name and table name.
      • We recommend that you perform this operation during off-peak hours.
    • DTS does not check the validity of metadata such as sequences. You must manually check the validity of metadata.
    • After your workloads are switched to the destination database, newly written sequences do not increment from the maximum value of the sequences in the source database. Therefore, you must query the maximum value of the sequences in the source database before you switch your workloads to the destination database. Then, you must specify the queried maximum value as the initial value of the sequences in the destination database. You can run the following statements to query the maximum value of the sequences in the source database:
      do language plpgsql $$
      declare
        nsp name;
        rel name;
        val int8;
      begin
        for nsp,rel in select nspname,relname from pg_class t2 , pg_namespace t3 where t2.relnamespace=t3.oid and t2.relkind='S'
        loop
          execute format($_$select last_value from %I.%I$_$, nsp, rel) into val;
          raise notice '%',
          format($_$select setval('%I.%I'::regclass, %s);$_$, nsp, rel, val+1);
        end loop;
      end;
      $$;
    • DTS creates the following temporary tables in the source database to obtain the DDL statements of incremental data, the schemas of incremental tables, and the heartbeat information. During data synchronization, do not delete temporary tables in the source database. Otherwise, exceptions occur. After the DTS instance is released, temporary tables are automatically deleted.

      public.DTS_PG_CLASS, public.DTS_PG_ATTRIBUTE, public.DTS_PG_TYPE, public.DTS_PG_ENUM, public.DTS_POSTGRES_HEARTBEAT, public.DTS_DDL_COMMAND, and public.DTS_ARGS_SESSION.

    • To ensure that the latency of data synchronization is accurate, DTS adds a heartbeat table to the source database. The name of the heartbeat table is dts_postgres_heartbeat.
    • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
      Note
      • After the DTS instance is released, the replication slot is automatically deleted. If you modify the password of the source database or delete the IP address whitelist of DTS, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent it from piling up.
      • If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
      Replication slot information
    • Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. During initial full data synchronization, DTS uses read and write resources of the source and destination databases. This may increase the loads on the database servers.
    • During initial full data synchronization, concurrent INSERT operations cause fragmentation in the tables of the destination database. Therefore, after initial full data synchronization is complete, the size of the used tablespace of the destination database is larger than that of the source database.
    • We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on source tables during data synchronization. Otherwise, data synchronization may fail.
    • If you use only DTS to write data to the destination database, you can use DMS to perform online DDL operations on source tables during data synchronization. For more information, see Change schemas without locking tables.
    • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases. For example, if you use tools other than DTS to write data to the destination database, data loss may occur in the destination database when you use Data Management (DMS) to perform online DDL operations.
    • If you perform both full data synchronization and incremental data synchronization and the tables to be synchronized in the source database contain foreign keys, triggers, or event triggers (PostgreSQL V11.5 and later), the session_replication_role parameter in the destination database must be set to replica. After the data synchronization task is released, you can change the value of the session_replication_role parameter back to origin.
    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.

  • The following table describes the usage notes and limits when you synchronize data from a self-managed PostgreSQL database to an ApsaraDB RDS for PostgreSQL instance
    Category Description
    Limits on the source database
    • The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
    • If you select tables as the objects to be synchronized and you want to edit the tables (such as renaming tables or columns) in the destination database, you can synchronize up to 5,000 tables in a single data synchronization task. If you run a task to synchronize more than 5,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to synchronize the tables in batches or configure a task to synchronize the entire database.
    • The following requirements for write-ahead logging (WAL) logs must be met:
      • The value of the wal_level parameter must be set to logical.
      • If you perform only incremental data synchronization, the WAL logs of the source database must be stored for more than 24 hours. If you perform both full data synchronization and incremental data synchronization, the WAL logs of the source database must be stored for at least seven days. Otherwise, DTS may fail to obtain the WAL logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. After the full data synchronization is complete, you can set the retention period to more than 24 hours. Make sure that you set the retention period of WAL logs based on the preceding requirements. Otherwise, the service reliability and performance stated in the Service Level Agreement (SLA) of DTS may not be guaranteed.

    • If you perform a primary/secondary switchover on a self-managed PostgreSQL database, the data synchronization task fails.
    Other limits
    • A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
    • If the schema is selected as the object to be synchronized, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL;statement in the destination table before the data synchronization starts. This ensures data consistency. When you execute this statement, we recommend that you do not lock the table. Otherwise, a deadlock occurs.
      Note
      • Replace the schema and table in the preceding sample statement with the actual schema name and table name.
      • We recommend that you perform this operation during off-peak hours.
    • DTS does not check the validity of metadata such as sequences. You must manually check the validity of metadata.
    • After your workloads are switched to the destination database, newly written sequences do not increment from the maximum value of the sequences in the source database. Therefore, you must query the maximum value of the sequences in the source database before you switch your workloads to the destination database. Then, you must specify the queried maximum value as the initial value of the sequences in the destination database. You can run the following statements to query the maximum value of the sequences in the source database:
      do language plpgsql $$
      declare
        nsp name;
        rel name;
        val int8;
      begin
        for nsp,rel in select nspname,relname from pg_class t2 , pg_namespace t3 where t2.relnamespace=t3.oid and t2.relkind='S'
        loop
          execute format($_$select last_value from %I.%I$_$, nsp, rel) into val;
          raise notice '%',
          format($_$select setval('%I.%I'::regclass, %s);$_$, nsp, rel, val+1);
        end loop;
      end;
      $$;
    • DTS creates the following temporary tables in the source database to obtain the DDL statements of incremental data, the schemas of incremental tables, and the heartbeat information. During data synchronization, do not delete temporary tables in the source database. Otherwise, exceptions occur. After the DTS instance is released, temporary tables are automatically deleted.

      public.DTS_PG_CLASS, public.DTS_PG_ATTRIBUTE, public.DTS_PG_TYPE, public.DTS_PG_ENUM, public.DTS_POSTGRES_HEARTBEAT, public.DTS_DDL_COMMAND, and public.DTS_ARGS_SESSION.

    • To ensure that the latency of data synchronization is accurate, DTS adds a heartbeat table to the source database. The name of the heartbeat table is dts_postgres_heartbeat.
    • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
      Note If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
      Replication slot information
    • Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. During initial full data synchronization, DTS uses read and write resources of the source and destination databases. This may increase the loads on the database servers.
    • During initial full data synchronization, concurrent INSERT operations cause fragmentation in the tables of the destination database. Therefore, after initial full data synchronization is complete, the size of the used tablespace of the destination database is larger than that of the source database.
    • We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on source tables during data synchronization. Otherwise, data synchronization may fail.
    • If you use only DTS to write data to the destination database, you can use DMS to perform online DDL operations on source tables during data synchronization. For more information, see Change schemas without locking tables.
    • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases. If you use tools other than DTS to write data to the destination database, data loss may occur in the destination database when you use DMS to perform online DDL operations.
    • If you perform both full data synchronization and incremental data synchronization and the tables to be synchronized in the source database contain foreign keys, triggers, or event triggers (PostgreSQL V11.5 and later), the session_replication_role parameter in the destination database must be set to replica. After the data synchronization task is released, you can change the value of the session_replication_role parameter back to origin.
  • The following table describes the usage notes and limits when you configure two-way synchronization between ApsaraDB RDS for PostgreSQL instances.
    Category Description
    Limits on the source and destination databases
    • The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
    • If you select tables as the objects to be synchronized and you want to edit the tables (such as renaming tables or columns) in the destination database, you can synchronize up to 5,000 tables in a single data synchronization task. If you run a task to synchronize more than 5,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to synchronize the tables in batches or configure a task to synchronize the entire database.
    • The following requirements for write-ahead logging (WAL) logs must be met:
      • The value of the wal_level parameter must be set to logical.
      • If you perform only incremental data synchronization, the WAL logs of the source database must be stored for more than 24 hours. If you perform both full data synchronization and incremental data synchronization, the WAL logs of the source database must be stored for at least seven days. Otherwise, DTS may fail to obtain the WAL logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. After the full data synchronization is complete, you can set the retention period to more than 24 hours. Make sure that you set the retention period of WAL logs based on the preceding requirements. Otherwise, the service reliability and performance stated in the Service Level Agreement (SLA) of DTS may not be guaranteed.

    • If you want to perform a primary/secondary switchover on the source ApsaraDB RDS for PostgreSQL instance, the Logical Replication Slot Failover feature must be enabled. This prevents logical subscriptions from being interrupted and ensures that your data synchronization task can run as expected. For more information, see Logical Replication Slot Failover.

    Other limits
    • You can configure two-way synchronization between ApsaraDB RDS for PostgreSQL instances only in the China (Hangzhou), China (Shanghai), or China (Qingdao) region.
    • A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
    • If the schema is selected as the object to be synchronized, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL;statement in the destination table before the data synchronization starts. This ensures data consistency. When you execute this statement, we recommend that you do not lock the table. Otherwise, a deadlock occurs.
      Note
      • Replace the schema and table in the preceding sample statement with the actual schema name and table name.
      • We recommend that you perform this operation during off-peak hours.
    • DTS does not check the validity of metadata such as sequences. You must manually check the validity of metadata.
    • After your workloads are switched to the destination database, newly written sequences do not increment from the maximum value of the sequences in the source database. Therefore, you must query the maximum value of the sequences in the source database before you switch your workloads to the destination database. Then, you must specify the queried maximum value as the initial value of the sequences in the destination database. You can run the following statements to query the maximum value of the sequences in the source database:
      do language plpgsql $$
      declare
        nsp name;
        rel name;
        val int8;
      begin
        for nsp,rel in select nspname,relname from pg_class t2 , pg_namespace t3 where t2.relnamespace=t3.oid and t2.relkind='S'
        loop
          execute format($_$select last_value from %I.%I$_$, nsp, rel) into val;
          raise notice '%',
          format($_$select setval('%I.%I'::regclass, %s);$_$, nsp, rel, val+1);
        end loop;
      end;
      $$;
    • DTS creates the following temporary tables in the source database to obtain the DDL statements of incremental data, the schemas of incremental tables, and the heartbeat information. During data synchronization, do not delete temporary tables in the source database. Otherwise, exceptions occur. After the DTS instance is released, temporary tables are automatically deleted.

      public.DTS_PG_CLASS, public.DTS_PG_ATTRIBUTE, public.DTS_PG_TYPE, public.DTS_PG_ENUM, public.DTS_POSTGRES_HEARTBEAT, public.DTS_DDL_COMMAND, and public.DTS_ARGS_SESSION.

    • To ensure that the latency of data synchronization is accurate, DTS adds a heartbeat table to the source database. The name of the heartbeat table is dts_postgres_heartbeat.
    • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
      Note
      • After the DTS instance is released, the replication slot is automatically deleted. If you modify the password of the source database or delete the IP address whitelist of DTS, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent it from piling up.
      • If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
      Replication slot information
    • Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. During initial full data synchronization, DTS uses read and write resources of the source and destination databases. This may increase the loads on the database servers.
    • During initial full data synchronization, concurrent INSERT operations cause fragmentation in the tables of the destination database. Therefore, after initial full data synchronization is complete, the size of the used tablespace of the destination database is larger than that of the source database.
    • We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on source tables during data synchronization. Otherwise, data synchronization may fail.
    • If you use only DTS to write data to the destination database, you can use DMS to perform online DDL operations on source tables during data synchronization. For more information, see Change schemas without locking tables.
    • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases. If you use tools other than DTS to write data to the destination database, data loss may occur in the destination database when you use DMS to perform online DDL operations.
    • If you perform both full data synchronization and incremental data synchronization and the tables to be synchronized in the source database contain foreign keys, triggers, or event triggers (PostgreSQL V11.5 and later), the session_replication_role parameter in the destination database must be set to replica. After the data synchronization task is released, you can change the value of the session_replication_role parameter back to origin.
    • If a table is synchronized in both the forward and reverse synchronization and both the full data and incremental data of the table are synchronized in the forward synchronization, DTS synchronizes only the incremental data of the table in the reverse synchronization.
    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.

Synchronize data from a self-managed PostgreSQL database or an ApsaraDB RDS for PostgreSQL instance to an AnalyticDB for PostgreSQL instance

Category Description
Limits on the source database
  • The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If you select tables as the objects to be synchronized and you want to edit the tables (such as renaming tables or columns) in the destination database, you can synchronize up to 5,000 tables in a single data synchronization task. If you run a task to synchronize more than 5,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to synchronize the tables in batches or configure a task to synchronize the entire database.
  • The following requirements for write-ahead logging (WAL) logs must be met:
    • The value of the wal_level parameter must be set to logical.
    • If you perform only incremental data synchronization, the WAL logs of the source database must be stored for more than 24 hours. If you perform both full data synchronization and incremental data synchronization, the WAL logs of the source database must be stored for at least seven days. Otherwise, DTS may fail to obtain the WAL logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. After the full data synchronization is complete, you can set the retention period to more than 24 hours. Make sure that you set the retention period of WAL logs based on the preceding requirements. Otherwise, the service reliability and performance stated in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • Limits on operations:
    • If you perform a primary/secondary switchover on a self-managed PostgreSQL database, the data synchronization task fails.
    • If you want to perform a primary/secondary switchover on the source ApsaraDB RDS for PostgreSQL instance, the Logical Replication Slot Failover feature must be enabled. This prevents logical subscriptions from being interrupted and ensures that your data synchronization task can run as expected. For more information, see Logical Replication Slot Failover.

Other limits
  • Initial schema synchronization is not supported. Before you configure a data synchronization task, you must create databases and tables in the destination instance based on the databases and tables that you want to synchronize.
  • Requirements for the objects to synchronize:
    • Only tables can be selected as the objects to be synchronized.
    • DTS does not synchronize the following types of data: BIT, VARBIT, GEOMETRY, UUID, TSQUERY, TSVECTOR, and TXID_SNAPSHOT.
  • A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
  • If the schema is selected as the object to be synchronized, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL;statement in the destination table before the data synchronization starts. This ensures data consistency. When you execute this statement, we recommend that you do not lock the table. Otherwise, a deadlock occurs.
    Note
    • Replace the schema and table in the preceding sample statement with the actual schema name and table name.
    • We recommend that you perform this operation during off-peak hours.
  • DTS creates the following temporary tables in the source database to obtain the DDL statements of incremental data, the schemas of incremental tables, and the heartbeat information. During data synchronization, do not delete temporary tables in the source database. Otherwise, exceptions occur. After the DTS instance is released, temporary tables are automatically deleted.

    public.DTS_PG_CLASS, public.DTS_PG_ATTRIBUTE, public.DTS_PG_TYPE, public.DTS_PG_ENUM, public.DTS_POSTGRES_HEARTBEAT, public.DTS_DDL_COMMAND, and public.DTS_ARGS_SESSION.

  • To ensure that the latency of data synchronization is accurate, DTS adds a heartbeat table to the source database. The name of the heartbeat table is dts_postgres_heartbeat.
  • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
    Note If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
    Note
    • After the DTS instance is released, the replication slot is automatically deleted. If you modify the password of the source database or delete the IP address whitelist of DTS, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent it from piling up.
    • If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. During initial full data synchronization, DTS uses read and write resources of the source and destination databases. This may increase the loads on the database servers.
  • During initial full data synchronization, concurrent INSERT operations cause fragmentation in the tables of the destination database. Therefore, after initial full data synchronization is complete, the size of the used tablespace of the destination database is larger than that of the source database.
  • We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on source tables during data synchronization. Otherwise, data synchronization may fail.
  • If you use only DTS to write data to the destination database, you can use DMS to perform online DDL operations on source tables during data synchronization. For more information, see Change schemas without locking tables.
  • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases. If you use tools other than DTS to write data to the destination database, data loss may occur in the destination database when you use DMS to perform online DDL operations.
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.

Synchronize data from a self-managed PostgreSQL database to a PolarDB for Oracle cluster

Category Description
Limits on the source database
  • The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If you select tables as the objects to be synchronized and you want to edit the tables (such as renaming tables or columns) in the destination database, you can synchronize up to 5,000 tables in a single data synchronization task. If you run a task to synchronize more than 5,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to synchronize the tables in batches or configure a task to synchronize the entire database.
  • The following requirements for write-ahead logging (WAL) logs must be met:
    • The value of the wal_level parameter must be set to logical.
    • If you perform only incremental data synchronization, the WAL logs of the source database must be stored for more than 24 hours. If you perform both full data synchronization and incremental data synchronization, the WAL logs of the source database must be stored for at least seven days. Otherwise, DTS may fail to obtain the WAL logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. After the full data synchronization is complete, you can set the retention period to more than 24 hours. Make sure that you set the retention period of WAL logs based on the preceding requirements. Otherwise, the service reliability and performance stated in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • If you perform a primary/secondary switchover on a self-managed PostgreSQL database, the data synchronization task fails.
Other limits
  • Initial schema synchronization is not supported. Before you configure a data synchronization task, you must create databases and tables in the destination instance based on the databases and tables that you want to synchronize.
  • A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
  • If the schema is selected as the object to be synchronized, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL;statement in the destination table before the data synchronization starts. This ensures data consistency. When you execute this statement, we recommend that you do not lock the table. Otherwise, a deadlock occurs.
    Note
    • Replace the schema and table in the preceding sample statement with the actual schema name and table name.
    • We recommend that you perform this operation during off-peak hours.
  • DTS does not check the validity of metadata such as sequences. You must manually check the validity of metadata.
  • After your workloads are switched to the destination database, newly written sequences do not increment from the maximum value of the sequences in the source database. Therefore, you must query the maximum value of the sequences in the source database before you switch your workloads to the destination database. Then, you must specify the queried maximum value as the initial value of the sequences in the destination database. You can run the following statements to query the maximum value of the sequences in the source database:
    do language plpgsql $$
    declare
      nsp name;
      rel name;
      val int8;
    begin
      for nsp,rel in select nspname,relname from pg_class t2 , pg_namespace t3 where t2.relnamespace=t3.oid and t2.relkind='S'
      loop
        execute format($_$select last_value from %I.%I$_$, nsp, rel) into val;
        raise notice '%',
        format($_$select setval('%I.%I'::regclass, %s);$_$, nsp, rel, val+1);
      end loop;
    end;
    $$;
  • DTS creates the following temporary tables in the source database to obtain the DDL statements of incremental data, the schemas of incremental tables, and the heartbeat information. During data synchronization, do not delete temporary tables in the source database. Otherwise, exceptions occur. After the DTS instance is released, temporary tables are automatically deleted.

    public.DTS_PG_CLASS, public.DTS_PG_ATTRIBUTE, public.DTS_PG_TYPE, public.DTS_PG_ENUM, public.DTS_POSTGRES_HEARTBEAT, public.DTS_DDL_COMMAND, and public.DTS_ARGS_SESSION.

  • To ensure that the latency of data synchronization is accurate, DTS adds a heartbeat table to the source database. The name of the heartbeat table is dts_postgres_heartbeat.
  • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
    Note If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. During initial full data synchronization, DTS uses read and write resources of the source and destination databases. This may increase the loads on the database servers.
  • During initial full data synchronization, concurrent INSERT operations cause fragmentation in the tables of the destination database. Therefore, after initial full data synchronization is complete, the size of the used tablespace of the destination database is larger than that of the source database.
  • We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on source tables during data synchronization. Otherwise, data synchronization may fail.
  • If you use only DTS to write data to the destination database, you can use DMS to perform online DDL operations on source tables during data synchronization. For more information, see Change schemas without locking tables.
  • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases. If you use tools other than DTS to write data to the destination database, data loss may occur in the destination database when you use DMS to perform online DDL operations.

Synchronize data from an ApsaraDB RDS for PostgreSQL instance to an ApsaraDB RDS for MySQL instance

Category Description
Limits on the source database
  • The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If you select tables as the objects to be synchronized and you want to edit the tables (such as renaming tables or columns) in the destination database, you can synchronize up to 5,000 tables in a single data synchronization task. If you run a task to synchronize more than 5,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to synchronize the tables in batches or configure a task to synchronize the entire database.
  • The following requirements for write-ahead logging (WAL) logs must be met:
    • The value of the wal_level parameter must be set to logical.
    • If you perform only incremental data synchronization, the WAL logs of the source database must be stored for more than 24 hours. If you perform both full data synchronization and incremental data synchronization, the WAL logs of the source database must be stored for at least seven days. Otherwise, DTS may fail to obtain the WAL logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. After the full data synchronization is complete, you can set the retention period to more than 24 hours. Make sure that you set the retention period of WAL logs based on the preceding requirements. Otherwise, the service reliability and performance stated in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • Limits on operations:

    If you want to perform a primary/secondary switchover on the source ApsaraDB RDS for PostgreSQL instance, the Logical Replication Slot Failover feature must be enabled. This prevents logical subscriptions from being interrupted and ensures that your data synchronization task can run as expected. For more information, see Logical Replication Slot Failover.

Other limits
  • A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
  • If the schema is selected as the object to be synchronized, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL;statement in the destination table before the data synchronization starts. This ensures data consistency. When you execute this statement, we recommend that you do not lock the table. Otherwise, a deadlock occurs.
    Note
    • Replace the schema and table in the preceding sample statement with the actual schema name and table name.
    • We recommend that you perform this operation during off-peak hours.
  • DTS creates the following temporary tables in the source database to obtain the DDL statements of incremental data, the schemas of incremental tables, and the heartbeat information. During data synchronization, do not delete temporary tables in the source database. Otherwise, exceptions occur. After the DTS instance is released, temporary tables are automatically deleted.

    public.DTS_PG_CLASS, public.DTS_PG_ATTRIBUTE, public.DTS_PG_TYPE, public.DTS_PG_ENUM, public.DTS_POSTGRES_HEARTBEAT, public.DTS_DDL_COMMAND, and public.DTS_ARGS_SESSION.

  • To ensure that the latency of data synchronization is accurate, DTS adds a heartbeat table to the source database. The name of the heartbeat table is dts_postgres_heartbeat.
  • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
    Note
    • After the DTS instance is released, the replication slot is automatically deleted. If you modify the password of the source database or delete the IP address whitelist of DTS, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent it from piling up.
    • If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. During initial full data synchronization, DTS uses read and write resources of the source and destination databases. This may increase the loads on the database servers.
  • During initial full data synchronization, concurrent INSERT operations cause fragmentation in the tables of the destination database. Therefore, after initial full data synchronization is complete, the size of the used tablespace of the destination database is larger than that of the source database.
  • We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on source tables during data synchronization. Otherwise, data synchronization may fail.
  • If you use only DTS to write data to the destination database, you can use DMS to perform online DDL operations on source tables during data synchronization. For more information, see Change schemas without locking tables.
  • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases. If you use tools other than DTS to write data to the destination database, data loss may occur in the destination database when you use DMS to perform online DDL operations.
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.

Synchronize data from an ApsaraDB RDS for PostgreSQL instance to a PolarDB for PostgreSQL cluster

Category Description
Limits on the source database
  • The tables to be synchronized must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination database may contain duplicate data records.
  • If you select tables as the objects to be synchronized and you want to edit the tables (such as renaming tables or columns) in the destination database, you can synchronize up to 5,000 tables in a single data synchronization task. If you run a task to synchronize more than 5,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to synchronize the tables in batches or configure a task to synchronize the entire database.
  • The following requirements for write-ahead logging (WAL) logs must be met:
    • The value of the wal_level parameter must be set to logical.
    • If you perform only incremental data synchronization, the WAL logs of the source database must be stored for more than 24 hours. If you perform both full data synchronization and incremental data synchronization, the WAL logs of the source database must be stored for at least seven days. Otherwise, DTS may fail to obtain the WAL logs and the task may fail. In exceptional circumstances, data inconsistency or loss may occur. After the full data synchronization is complete, you can set the retention period to more than 24 hours. Make sure that you set the retention period of WAL logs based on the preceding requirements. Otherwise, the service reliability and performance stated in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • During data synchronization, do not modify the endpoint and zone of the ApsaraDB RDS for PostgreSQL instance. Otherwise, the data synchronization task fails.
Other limits
  • A single data synchronization task can synchronize data from only one database. To synchronize data from multiple databases, you must create a data synchronization task for each database.
  • If the schema is selected as the object to be synchronized, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL;statement in the destination table before the data synchronization starts. This ensures data consistency. When you execute this statement, we recommend that you do not lock the table. Otherwise, a deadlock occurs.
    Note
    • Replace the schema and table in the preceding sample statement with the actual schema name and table name.
    • We recommend that you perform this operation during off-peak hours.
  • DTS creates the following temporary tables in the source database to obtain the DDL statements of incremental data, the schemas of incremental tables, and the heartbeat information. During data synchronization, do not delete temporary tables in the source database. Otherwise, exceptions occur. After the DTS instance is released, temporary tables are automatically deleted.

    public.DTS_PG_CLASS, public.DTS_PG_ATTRIBUTE, public.DTS_PG_TYPE, public.DTS_PG_ENUM, public.DTS_POSTGRES_HEARTBEAT, public.DTS_DDL_COMMAND, and public.DTS_ARGS_SESSION.

  • To ensure that the latency of data synchronization is accurate, DTS adds a heartbeat table to the source database. The name of the heartbeat table is dts_postgres_heartbeat.
  • During data synchronization, DTS creates a replication slot for the source database. The replication slot is prefixed with dts_sync_. DTS automatically clears historical replication slots every 120 minutes to reduce storage usage.
    Note
    • After the DTS instance is released, the replication slot is automatically deleted. If you modify the password of the source database or delete the IP address whitelist of DTS, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent it from piling up.
    • If the data synchronization task is released or fails, DTS automatically clears the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB RDS for PostgreSQL instance, you must log on to the secondary database to clear the replication slot.
    Replication slot information
  • Before you synchronize data, evaluate the impact of data synchronization on the performance of the source and destination databases. We recommend that you synchronize data during off-peak hours. During initial full data synchronization, DTS uses read and write resources of the source and destination databases. This may increase the loads on the database servers.
  • During initial full data synchronization, concurrent INSERT operations cause fragmentation in the tables of the destination database. Therefore, after initial full data synchronization is complete, the size of the used tablespace of the destination database is larger than that of the source database.
  • We recommend that you do not use gh-ost or pt-online-schema-change to perform DDL operations on source tables during data synchronization. Otherwise, data synchronization may fail.
  • If you use only DTS to write data to the destination database, you can use DMS to perform online DDL operations on source tables during data synchronization. For more information, see Change schemas without locking tables.
  • During data synchronization, we recommend that you use only DTS to write data to the destination database. This prevents data inconsistency between the source and destination databases. If you use tools other than DTS to write data to the destination database, data loss may occur in the destination database when you use DMS to perform online DDL operations.