All Products
Search
Document Center

Data Transmission Service:Precautions and limits for synchronizing data from a PostgreSQL database

Last Updated:Oct 27, 2023

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

Scenarios of synchronizing data from a PostgreSQL database

The following list provides the scenarios of synchronizing data from a PostgreSQL database. The precautions and limits in the scenarios may vary. You can go to the related section to view the precautions and limits in a specific scenario.

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:

  • ApsaraDB RDS for PostgreSQL

  • AnalyticDB for PostgreSQL

  • PolarDB for Oracle

  • ApsaraDB RDS for MySQL

  • PolarDB for PostgreSQL

Synchronize data between PostgreSQL databases

  • Configure one-way data 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 or configure a task to synchronize the entire database.

    • The following requirements for WAL logs must be met:

      • The value of the wal_level parameter is 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 full data synchronization is completed, 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

    • Limits on operations to be performed on the source database:

      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.

    • If the source database has long-running transactions and incremental data is synchronized in the data synchronization task, the WAL logs generated before the long-running transactions in the source database are committed may be accumulated. As a result, the disk space of the source database may be insufficient.

    Other limits

    • A 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.

    • During data synchronization, if you select a schema as the object to synchronize, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 starting value of the sequences in the destination database. You can execute 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 can obtain the incremental logs of the source database within the last 15 minutes by using this replication slot.

      Note
      • After the DTS instance is released, the replication slot is automatically deleted. If you change the password of the source database or delete the IP addresses of DTS from the IP address whitelist, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent the replication slot 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 PostgreSQL database, you must log on to the secondary database to clear the replication slot.

      Amazon slot查询信息
    • 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 the read and write resources of the source and destination databases. This may increase the loads of 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.

    • If you use only DTS to write table 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 DMS to perform online DDL operations.

    • If you use a privileged account or superuser account as the destination database account to perform full data synchronization or incremental data synchronization, and the tables to be synchronized in the source database contain foreign keys, triggers, or event triggers, DTS temporarily sets the session_replication_role parameter to replica at the session level. If the destination database account does not have the required permissions, you must manually set the session_replication_role parameter to replica. If the value of the session_replication_role parameter is replica and you perform the cascade update or delete operations on the source database during full data synchronization or incremental data synchronization, data inconsistency may occur. After the DTS 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 or zone of the ApsaraDB RDS for PostgreSQL instance. Otherwise, the data synchronization task fails.

  • 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 or configure a task to synchronize the entire database.

    • The following requirements for WAL logs must be met:

      • The value of the wal_level parameter is 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 full data synchronization is completed, 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

    • If you perform a primary/secondary switchover on the source self-managed PostgreSQL database, the data synchronization task fails.

    • If the source database has long-running transactions and incremental data is synchronized in the data synchronization task, the WAL logs generated before the long-running transactions in the source database are committed may be accumulated. As a result, the disk space of the source database may be insufficient.

    Other limits

    • A 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.

    • During data synchronization, if you select a schema as the object to synchronize, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 starting value of the sequences in the destination database. You can execute 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 can obtain the incremental logs of the source database within the last 15 minutes by using this replication slot.

      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 self-managed PostgreSQL database, you must log on to the secondary database to clear the replication slot.

      Amazon slot查询信息
    • 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 the read and write resources of the source and destination databases. This may increase the loads of 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.

    • If you use only DTS to write table 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 DMS to perform online DDL operations.

    • If you use a privileged account or superuser account as the destination database account to perform full data synchronization or incremental data synchronization, and the tables to be synchronized in the source database contain foreign keys, triggers, or event triggers, DTS temporarily sets the session_replication_role parameter to replica at the session level. If the destination database account does not have the required permissions, you must manually set the session_replication_role parameter to replica. If the value of the session_replication_role parameter is replica and you perform the cascade update or delete operations on the source database during full data synchronization or incremental data synchronization, data inconsistency may occur. After the DTS synchronization task is released, you can change the value of the session_replication_role parameter back to origin.

  • Configure two-way data 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 or configure a task to synchronize the entire database.

    • The following requirements for WAL logs must be met:

      • The value of the wal_level parameter is 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 full data synchronization is completed, 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 or performance 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.

    • If the source database has long-running transactions and incremental data is synchronized in the data synchronization task, the WAL logs generated before the long-running transactions in the source database are committed may be accumulated. As a result, the disk space of the source database may be insufficient.

    Other limits

    • A 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.

    • During data synchronization, if you select a schema as the object to synchronize, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 starting value of the sequences in the destination database. You can execute 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 can obtain the incremental logs of the source database within the last 15 minutes by using this replication slot.

      Note
      • After the DTS instance is released, the replication slot is automatically deleted. If you change the password of the source database or delete the IP addresses of DTS from the IP address whitelist, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent the replication slot 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 PostgreSQL database, you must log on to the secondary database to clear the replication slot.

      Amazon slot查询信息
    • 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 the read and write resources of the source and destination databases. This may increase the loads of 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.

    • If you use only DTS to write table 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 DMS to perform online DDL operations.

    • If you use a privileged account or superuser account as the destination database account to perform full data synchronization or incremental data synchronization, and the tables to be synchronized in the source database contain foreign keys, triggers, or event triggers, DTS temporarily sets the session_replication_role parameter to replica at the session level. If the destination database account does not have the required permissions, you must manually set the session_replication_role parameter to replica. If the value of the session_replication_role parameter is replica and you perform the cascade update or delete operations on the source database during full data synchronization or incremental data synchronization, data inconsistency may occur. After the DTS 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 or 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 or configure a task to synchronize the entire database.

  • The following requirements for WAL logs must be met:

    • The value of the wal_level parameter is 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 full data synchronization is completed, 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • Limits on operations to be performed on the source database:

    • If you perform a primary/secondary switchover on the source 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.

  • If the source database has long-running transactions and incremental data is synchronized in the data synchronization task, the WAL logs generated before the long-running transactions in the source database are committed may be accumulated. As a result, the disk space of the source database may be insufficient.

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.

  • Requirements for the objects to synchronize:

    • Only tables can be selected as the objects to be synchronized.

    • DTS does not synchronize data of the following types: BIT, VARBIT, GEOMETRY, UUID, TSQUERY, TSVECTOR, and TXID_SNAPSHOT.

  • A 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.

  • During data synchronization, if you select a schema as the object to synchronize, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 can obtain the incremental logs of the source database within the last 15 minutes by using this replication slot.

    Note
    • After the DTS instance is released, the replication slot is automatically deleted. If you change the password of the source database or delete the IP addresses of DTS from the IP address whitelist, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent the replication slot 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 PostgreSQL database, you must log on to the secondary database to clear the replication slot.

    Amazon slot查询信息
  • 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 the read and write resources of the source and destination databases. This may increase the loads of 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.

  • If you use only DTS to write table 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 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 or 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 PostgreSQL(Compatible with 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 or configure a task to synchronize the entire database.

  • The following requirements for WAL logs must be met:

    • The value of the wal_level parameter is 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 full data synchronization is completed, 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • If you perform a primary/secondary switchover on the source self-managed PostgreSQL database, the data synchronization task fails.

  • If the source database has long-running transactions and incremental data is synchronized in the data synchronization task, the WAL logs generated before the long-running transactions in the source database are committed may be accumulated. As a result, the disk space of the source database may be insufficient.

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.

  • A 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.

  • During data synchronization, if you select a schema as the object to synchronize, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 starting value of the sequences in the destination database. You can execute 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 can obtain the incremental logs of the source database within the last 15 minutes by using this replication slot.

    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 self-managed PostgreSQL database, you must log on to the secondary database to clear the replication slot.

    Amazon slot查询信息
  • 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 the read and write resources of the source and destination databases. This may increase the loads of 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.

  • If you use only DTS to write table 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 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 or configure a task to synchronize the entire database.

  • The following requirements for WAL logs must be met:

    • The value of the wal_level parameter is 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 full data synchronization is completed, 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • Limits on operations to be performed on the source database:

    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.

  • If the source database has long-running transactions and incremental data is synchronized in the data synchronization task, the WAL logs generated before the long-running transactions in the source database are committed may be accumulated. As a result, the disk space of the source database may be insufficient.

Other limits

  • A 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.

  • During data synchronization, if you select a schema as the object to synchronize, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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. The DDL statements are not written to the destination database. 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 can obtain the incremental logs of the source database within the last 15 minutes by using this replication slot.

    Note
    • After the DTS instance is released, the replication slot is automatically deleted. If you change the password of the source database or delete the IP addresses of DTS from the IP address whitelist, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent the replication slot 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.

    Amazon slot查询信息
  • 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 the read and write resources of the source and destination databases. This may increase the loads of 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.

  • If you use only DTS to write table 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 DMS to perform online DDL operations.

  • If DDL statements fail to be written to the destination database, the DTS task continues to run. You can view the DDL statements that fail to be executed in the task logs. For more information about how to view the task logs, see View task logs.

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 or 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 or configure a task to synchronize the entire database.

  • The following requirements for WAL logs must be met:

    • The value of the wal_level parameter is 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 full data synchronization is completed, 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • During data synchronization, do not modify the endpoint or zone of the ApsaraDB RDS for PostgreSQL instance. Otherwise, the data synchronization task fails.

  • If the source database has long-running transactions and incremental data is synchronized in the data synchronization task, the WAL logs generated before the long-running transactions in the source database are committed may be accumulated. As a result, the disk space of the source database may be insufficient.

Other limits

  • A 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.

  • During data synchronization, if you select a schema as the object to synchronize, take note of the following limits: If you create a table in the schema or run the RENAME command to rename the table, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 can obtain the incremental logs of the source database within the last 15 minutes by using this replication slot.

    Note
    • After the DTS instance is released, the replication slot is automatically deleted. If you change the password of the source database or delete the IP addresses of DTS from the IP address whitelist, the replication slot cannot be automatically deleted. In this case, you must delete the replication slot in the source database to prevent the replication slot 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 PostgreSQL database, you must log on to the secondary database to clear the replication slot.

    Amazon slot查询信息
  • 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 the read and write resources of the source and destination databases. This may increase the loads of 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.

  • If you use only DTS to write table 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 DMS to perform online DDL operations.

  • 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 starting value of the sequences in the destination database. You can execute 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;
    $$;