All Products
Search
Document Center

Data Transmission Service:Usage notes and limits for migrating data from a PostgreSQL database

Last Updated:Apr 02, 2025

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

Scenarios of migrating data from a PostgreSQL database

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

Migrate data between PostgreSQL databases

  • Migrate data between ApsaraDB RDS for PostgreSQL instances

    Category

    Description

    Limits on the source database

    • The tables to be migrated must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination cluster may contain duplicate data records.

      Note

      If a table that you want to use to receive data is not created by using DTS (Schema Synchronization is not selected for the Synchronization Types parameter), make sure that the table and the table to be migrated from the source database have the same PRIMARY KEY or NOT NULL UNIQUE constraints. Otherwise, the destination database may contain duplicate data records.

      The name of the source database cannot contain hyphens (-). Example: dts-testdata.

    • If you select tables as the objects to be migrated and you need to edit the tables, such as renaming tables or columns in the destination database, up to 1,000 tables can be migrated in a single data migration task. If you run a task to migrate more than 1,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to migrate the tables, or configure a task to migrate the entire database.

    • DTS cannot migrate temporary tables in the source database, internal triggers, or some internal procedures and functions written in the C programming language. DTS can migrate custom parameters of the COMPOSITE, ENUM, and RANGE types. The tables to be migrated must have the PRIMARY KEY, FOREIGN KEY, UNIQUE, or CHECK constraints.

    • If you need to migrate incremental data, you must make sure that the following requirements are met:

      • The value of the wal_level parameter must be set to logical.

      • If you perform only incremental data migration, the write-ahead logging (WAL) logs of the source database must be stored for more than 24 hours. If you perform both full data migration and incremental data migration, the WAL logs of the source database must be stored for at least seven days. Otherwise, Data Transmission Service (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 migration 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

    • Limits on operations to perform on the source database:

      • During schema migration and full data migration, do not perform DDL operations to change the schemas of databases or tables. Otherwise, the data migration task fails.

      • If you perform only full data migration, do not write data to the source database during data migration. Otherwise, data inconsistency between the source and destination databases occurs. To ensure data consistency, we recommend that you select schema migration, full data migration, and incremental data migration as the migration types.

      • The logical subscription from source database has limits on the usage of DTS. If the size of a single data to be migrated from the source database exceeds 256 MB upon incremental data changes, the data migration instance that is running fails to run and cannot be recovered. You need to configure the task again.

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

    • If a major version upgrade for the source database of a data migration instance that is running is performed, the instance fails to run and cannot be recovered. You need to configure the task again.

    Other limits

    • If you need 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 migration task can run as expected. For more information, see Logical Replication Slot Failover.

    • A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.

    • A table that can be inherited across schemas cannot be migrated.

    • If the table to be migrated includes SERIAL field, a sequence is created in the source database. If you select Schema Migration as the Migration Types when you configure the Source Objects parameter, we recommend that you select Sequence or a complete schema migration. Otherwise, the migration instance fails to run.

    • If you select a schema as the object to be migrated and create a table in the schema or execute the RENAME statement to rename a table in the schema during incremental data migration, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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, new sequences do not increment from the maximum value of the sequences in the source database. Therefore, before you switch your workloads to the destination database, you must update the starting value of sequences in the destination database.

    • 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 migration, 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.

    • If you run a full or incremental data migration task, the tables to be migrated from the source database contain foreign keys, triggers, or event triggers, and the account of the destination database is a privileged account or an account that has the permissions of the superuser role, DTS temporarily sets the session_replication_role parameter to replica at the session level during full or incremental data migration. If the account of the destination database does not have the permissions, you must manually set the session_replication_role parameter to replica in the destination database. After the session_replication_role parameter is set to replica during full or incremental data migration, if a cascade update or delete operation is performed in the source database, data inconsistency may occur. After the data migration task is released, you can change the value of the session_replication_role parameter to origin.

    • To ensure that the latency of incremental data migration is accurate, DTS creates a heartbeat table named dts_postgres_heartbeat in the source database.

    • During incremental data migration, DTS creates a replication slot in the source database to replicate data. The replication slot is prefixed with dts_sync_. By using this replication slot, DTS can obtain the incremental logs of the source database within the last 15 minutes.

      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 addresses of DTS from the IP address whitelist, the replication slot cannot be automatically deleted. In that case, you must manually delete the replication slot from the source database to prevent the replication slot from piling up.

      • If the data migration task is released or fails, DTS automatically deletes the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB for PostgreSQL instance, you must log on to the secondary instance to delete the replication slot.

    • Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. During full data migration, DTS uses the read and write resources of the source and destination databases. This may increase the loads of the database servers.

    • During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the tablespace of the destination database is larger than that of the source database.

    • You must ensure that the precision settings for columns of the FLOAT or DOUBLE data type meet your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.

    • DTS attempts to resume a data migration task that failed within the last seven days. Before you switch workloads to the destination cluster, you must stop or release the failed tasks. You can also execute the REVOKE statement to revoke the write permissions from the accounts that are used by DTS to access the destination database. Otherwise, the data in the source database will overwrite the data in the destination database after the failed task is resumed.

    • If a DTS task fails to run, DTS technical support will try to restore the task within 8 hours. During the restoration, the task may be restarted, and the parameters of the task may be modified.

      Note

      Only the parameters of the task may be modified. The parameters of databases are not modified. The parameters that may be modified include but are not limited to the parameters in the "Modify instance parameters" section of the Modify the parameters of a DTS instance topic.

    Special cases

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

  • Migrate data from a self-managed PostgreSQL database to an ApsaraDB RDS for PostgreSQL instance

    Category

    Description

    Limits on the source database

    • The server on which the source database resides must have sufficient outbound bandwidth. Otherwise, the data migration speed is affected.

    • The tables to be migrated must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination cluster may contain duplicate data records.

      Note

      If a table that you want to use to receive data is not created by using DTS (Schema Synchronization is not selected for the Synchronization Types parameter), make sure that the table and the table to be migrated from the source database have the same PRIMARY KEY or NOT NULL UNIQUE constraints. Otherwise, the destination database may contain duplicate data records.

      The name of the source database cannot contain hyphens (-). Example: dts-testdata.

    • If you select tables as the objects to be migrated and you need to edit the tables, such as renaming tables or columns in the destination database, up to 1,000 tables can be migrated in a single data migration task. If you run a task to migrate more than 1,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to migrate the tables, or configure a task to migrate the entire database.

    • DTS cannot migrate temporary tables in the source database, internal triggers, or some internal procedures and functions written in the C programming language. DTS can migrate custom parameters of the COMPOSITE, ENUM, and RANGE types. The tables to be migrated must have the PRIMARY KEY, FOREIGN KEY, UNIQUE, or CHECK constraints.

    • If you need to migrate incremental data, you must make sure that the following requirements are met:

      • The value of the wal_level parameter must be set to logical.

      • If you perform only incremental data migration, the write-ahead logging (WAL) logs of the source database must be stored for more than 24 hours. If you perform both full data migration and incremental data migration, the WAL logs of the source database must be stored for at least seven days. Otherwise, Data Transmission Service (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 migration 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

    • Limits on operations to perform on the source database:

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

      • During schema migration and full data migration, do not perform DDL operations to change the schemas of databases or tables. Otherwise, the data migration task fails.

      • The logical subscription from source database has limits on the usage of DTS. If the size of a single data to be migrated from the source database exceeds 256 MB upon incremental data changes, the data migration instance that is running fails to run and cannot be recovered. You need to configure the task again.

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

      • If a major version upgrade for the source database of a data migration instance that is running is performed, the instance fails to run and cannot be recovered. You need to configure the task again.

    Other limits

    • Data may be inconsistent between the primary and secondary nodes of the source database due to migration latency. Therefore, you must use the primary node as the data source when you migrate data.

    • A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.

    • A table that can be inherited across schemas cannot be migrated.

    • If the table to be migrated includes SERIAL field, a sequence is created in the source database. If you select Schema Migration as the Migration Types when you configure the Source Objects parameter, we recommend that you select Sequence or a complete schema migration. Otherwise, the migration instance fails to run.

    • If you select a schema as the object to be migrated and create a table in the schema or execute the RENAME statement to rename a table in the schema during incremental data migration, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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, new sequences do not increment from the maximum value of the sequences in the source database. Therefore, before you switch your workloads to the destination database, you must update the starting value of sequences in the destination database.

    • 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 migration, 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 incremental data migration is accurate, DTS creates a heartbeat table named dts_postgres_heartbeat in the source database.

    • During incremental data migration, DTS creates a replication slot in the source database to replicate data. The replication slot is prefixed with dts_sync_. By using this replication slot, DTS can obtain the incremental logs of the source database within the last 15 minutes.

      Note

      If the data migration task is released or fails, DTS automatically deletes 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 delete the replication slot.

      Amazon slot查询信息

    • If you run a full or incremental data migration task, the tables to be migrated from the source database contain foreign keys, triggers, or event triggers, and the account of the destination database is a privileged account or an account that has the permissions of the superuser role, DTS temporarily sets the session_replication_role parameter to replica at the session level during full or incremental data migration. If the account of the destination database does not have the permissions, you must manually set the session_replication_role parameter to replica in the destination database. After the session_replication_role parameter is set to replica during full or incremental data migration, if a cascade update or delete operation is performed in the source database, data inconsistency may occur. After the data migration task is released, you can change the value of the session_replication_role parameter to origin.

    • Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. During full data migration, DTS uses the read and write resources of the source and destination databases. This may increase the loads of the database servers.

    • During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the tablespace of the destination database is larger than that of the source database.

    • You must ensure that the precision settings for columns of the FLOAT or DOUBLE data type meet your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.

    • DTS attempts to resume a data migration task that failed within the last seven days. Before you switch workloads to the destination cluster, you must stop or release the failed tasks. You can also execute the REVOKE statement to revoke the write permissions from the accounts that are used by DTS to access the destination database. Otherwise, the data in the source database will overwrite the data in the destination database after the failed task is resumed.

    • If a DTS task fails to run, DTS technical support will try to restore the task within 8 hours. During the restoration, the task may be restarted, and the parameters of the task may be modified.

      Note

      Only the parameters of the task may be modified. The parameters of databases are not modified. The parameters that may be modified include but are not limited to the parameters in the "Modify instance parameters" section of the Modify the parameters of a DTS instance topic.

    Special cases

    • If the source database is a self-managed PostgreSQL database, the values of the max_wal_senders and max_replication_slots parameters must be greater than the sum of the following numbers: the number of used replication slots in the self-managed PostgreSQL database and the number of DTS instances that must be created to migrate data from this database.

    • If the source database is a Cloud SQL for PostgreSQL instance provided by Google Cloud Platform, you must set the Database Account parameter to a database account with the cloudsqlsuperuser permission for the source database. When you select the objects to be migrated, you must select the objects that the specified account is authorized to manage. Otherwise, you must grant the OWNER permission on the selected objects to the specified account.

      Note

      An account with the cloudsqlsuperuser permission cannot manage the data that is owned by other accounts that have the cloudsqlsuperuser permission.

Migrate data from a PostgreSQL database to a MySQL database

The following table describes the usage notes and limits that you must take note of when you migrate data from a PostgreSQL database to a MySQL database.

Category

Description

Limits on the source database

  • The server on which the source database resides must have sufficient outbound bandwidth. Otherwise, the data migration speed is affected.

  • The tables to be migrated must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination cluster may contain duplicate data records.

    Note

    If a table that you want to use to receive data is not created by using DTS (Schema Synchronization is not selected for the Synchronization Types parameter), make sure that the table and the table to be migrated from the source database have the same PRIMARY KEY or NOT NULL UNIQUE constraints. Otherwise, the destination database may contain duplicate data records.

    The name of the source database cannot contain hyphens (-). Example: dts-testdata.

  • If you select tables as the objects to be migrated and you need to edit the tables, such as renaming tables or columns in the destination database, up to 1,000 tables can be migrated in a single data migration task. If you run a task to migrate more than 1,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to migrate the tables, or configure a task to migrate the entire database.

  • If you need to migrate incremental data, you must make sure that the following requirements are met:

    • The value of the wal_level parameter must be set to logical.

    • If you perform only incremental data migration, the write-ahead logging (WAL) logs of the source database must be stored for more than 24 hours. If you perform both full data migration and incremental data migration, the WAL logs of the source database must be stored for at least seven days. Otherwise, Data Transmission Service (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 migration 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • Limits on operations to perform on the source database:

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

    • If you need 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 migration task can run as expected. For more information, see Logical Replication Slot Failover.

    • During full data migration, do not perform DDL operations to change the schemas of databases or tables. Otherwise, the data migration task fails.

    • The logical subscription from source database has limits on the usage of DTS. If the size of a single data to be migrated from the source database exceeds 256 MB upon incremental data changes, the data migration instance that is running fails to run and cannot be recovered. You need to configure the task again.

    • If you perform only full data migration, do not write data to the source database during data migration. Otherwise, data inconsistency between the source and destination databases occurs. To ensure data consistency, we recommend that you select Full Data Migration and Incremental Data Migration as the migration types.

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

  • If a major version upgrade for the source database of a data migration instance that is running is performed, the instance fails to run and cannot be recovered. You need to configure the task again.

Other limits

  • If the data to be migrated contains information such as rare characters or emojis that takes up four bytes, the destination databases and tables to receive the data must use UTF8mb4 character set.

    Note

    If you use the schema migration feature of DTS, set the instance parameter character_set_server in the destination database to UTF8mb4 character set.

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

  • If you write column names that differ only in capitalization to the same table in the destination MySQL database, the data migration result may not meet your expectations because the column names in MySQL databases are not case-sensitive.

  • After data migration is complete, that is, the Status of the instance changes to Completed, we recommend that you run the analyze table <table name> command to check whether data is written to the destination table. For example, if a high-availability (HA) switchover is triggered in the destination MySQL database, data may be written only to the memory. As a result, data loss occurs.

  • A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.

  • A table that can be inherited across schemas cannot be migrated.

  • If you select a schema as the object to be migrated and create a table in the schema or execute the RENAME statement to rename a table in the schema during incremental data migration, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 migration, 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 incremental data migration is accurate, DTS creates a heartbeat table named dts_postgres_heartbeat in the source database.

  • During incremental data migration, DTS creates a replication slot in the source database to replicate data. The replication slot is prefixed with dts_sync_. By using this replication slot, DTS can obtain the incremental logs of the source database within the last 15 minutes.

    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 addresses of DTS from the IP address whitelist, the replication slot cannot be automatically deleted. In that case, you must manually delete the replication slot from the source database to prevent the replication slot from piling up.

    • If the data migration task is released or fails, DTS automatically deletes the replication slot. If a primary/secondary switchover is performed on the source ApsaraDB for PostgreSQL instance, you must log on to the secondary instance to delete the replication slot.

  • Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. During full data migration, DTS uses the read and write resources of the source and destination databases. This may increase the loads of the database servers.

  • During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the tablespace of the destination database is larger than that of the source database.

  • You must ensure that the precision settings for columns of the FLOAT or DOUBLE data type meet your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.

  • DTS attempts to resume a data migration task that failed within the last seven days. Before you switch workloads to the destination cluster, you must stop or release the failed tasks. You can also execute the REVOKE statement to revoke the write permissions from the accounts that are used by DTS to access the destination database. Otherwise, the data in the source database will overwrite the data in the destination database after the failed task is resumed.

  • If a DTS task fails to run, DTS technical support will try to restore the task within 8 hours. During the restoration, the task may be restarted, and the parameters of the task may be modified.

    Note

    Only the parameters of the task may be modified. The parameters of databases are not modified. The parameters that may be modified include but are not limited to the parameters in the "Modify instance parameters" section of the Modify the parameters of a DTS instance topic.

Special cases

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

  • If the source database is a self-managed PostgreSQL database, the values of the max_wal_senders and max_replication_slots parameters must be greater than the sum of the following numbers: the number of used replication slots in the self-managed PostgreSQL database and the number of DTS instances that must be created to migrate data from this database.

  • If the source database is a Cloud SQL for PostgreSQL instance provided by Google Cloud Platform, you must set the Database Account parameter to a database account with the cloudsqlsuperuser permission for the source database. When you select the objects to be migrated, you must select the objects that the specified account is authorized to manage. Otherwise, you must grant the OWNER permission on the selected objects to the specified account.

    Note

    An account with the cloudsqlsuperuser permission cannot manage the data that is owned by other accounts that have the cloudsqlsuperuser permission.

  • If you migrate data to an ApsaraDB RDS for MySQL instance, DTS automatically creates a destination database in the destination instance. However, if the name of the source database does not meet the naming conventions of the destination ApsaraDB RDS for MySQL instance, you must manually create a database in the destination instance before you configure the data migration task. For more information, see Manage databases.

Migrate data from a PostgreSQL database to a PolarDB for PostgreSQL (Compatible with Oracle) cluster

The following table describes the usage notes and limits that you must take note of when you migrate data from a PostgreSQL database to a PolarDB for PostgreSQL (Compatible with Oracle) cluster.

Category

Description

Limits on the source database

  • The server on which the source database resides must have sufficient outbound bandwidth. Otherwise, the data migration speed is affected.

  • The tables to be migrated must have PRIMARY KEY or UNIQUE constraints, and all fields must be unique. Otherwise, the destination cluster may contain duplicate data records.

    Note

    If a table that you want to use to receive data is not created by using DTS (Schema Synchronization is not selected for the Synchronization Types parameter), make sure that the table and the table to be migrated from the source database have the same PRIMARY KEY or NOT NULL UNIQUE constraints. Otherwise, the destination database may contain duplicate data records.

    The name of the source database cannot contain hyphens (-). Example: dts-testdata.

  • If you select tables as the objects to be migrated and you need to edit the tables, such as renaming tables or columns in the destination database, up to 1,000 tables can be migrated in a single data migration task. If you run a task to migrate more than 1,000 tables, a request error occurs. In this case, we recommend that you configure multiple tasks to migrate the tables, or configure a task to migrate the entire database.

  • If you need to migrate incremental data, you must make sure that the following requirements are met:

    • The value of the wal_level parameter must be set to logical.

    • If you perform only incremental data migration, the write-ahead logging (WAL) logs of the source database must be stored for more than 24 hours. If you perform both full data migration and incremental data migration, the WAL logs of the source database must be stored for at least seven days. Otherwise, Data Transmission Service (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 migration 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 or performance in the Service Level Agreement (SLA) of DTS may not be guaranteed.

  • Limits on operations to perform on the source database:

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

    • The logical subscription from source database has limits on the usage of DTS. If the size of a single data to be migrated from the source database exceeds 256 MB upon incremental data changes, the data migration instance that is running fails to run and cannot be recovered. You need to configure the task again.

    • During full data migration, do not perform DDL operations to change the schemas of databases or tables. Otherwise, the data migration task fails.

    • If you perform only full data migration, do not write data to the source database during data migration. Otherwise, data inconsistency between the source and destination databases occurs. To ensure data consistency, we recommend that you select Full Data Migration and Incremental Data Migration as the migration types.

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

  • If a major version upgrade for the source database of a data migration instance that is running is performed, the instance fails to run and cannot be recovered. You need to configure the task again.

Other limits

  • If you run a full or incremental data migration task, the tables to be migrated from the source database contain foreign keys, triggers, or event triggers, and the account of the destination database is a privileged account, DTS temporarily sets the session_replication_role parameter to replica at the session level during full or incremental data migration. If the account of the destination database is not a privileged account, you must manually set the session_replication_role parameter to replica in the destination database. During full or incremental data migration, if you perform cascade update or delete operations on the source database while the session_replication_role parameter is set to replica, data inconsistency may occur. After the data migration task is released, you can change the value of the session_replication_role parameter to origin.

  • If the table to be migrated includes SERIAL field, a sequence is created in the source database. If you select Schema Migration as the Migration Types when you configure the Source Objects parameter, we recommend that you select Sequence or a complete schema migration. Otherwise, the migration instance fails to run.

  • If you select a schema as the object to be migrated and create a table in the schema or execute the RENAME statement to rename a table in the schema during incremental data migration, you must execute the ALTER TABLE schema.table REPLICA IDENTITY FULL; statement before you write data to the table. 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 migration, 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 incremental data migration is accurate, DTS creates a heartbeat table named dts_postgres_heartbeat in the source database.

  • During incremental data migration, DTS creates a replication slot in the source database to replicate data. The replication slot is prefixed with dts_sync_. By using this replication slot, DTS can obtain the incremental logs of the source database within the last 15 minutes.

    Note

    If the data migration task is released or fails, DTS automatically deletes 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 delete the replication slot.

    Amazon slot查询信息

  • A single data migration task can migrate data from only one database. To migrate data from multiple databases, you must create a data migration task for each database.

  • A table that can be inherited across schemas cannot be migrated.

  • Before you migrate data, evaluate the impact of data migration on the performance of the source and destination databases. We recommend that you migrate data during off-peak hours. During full data migration, DTS uses the read and write resources of the source and destination databases. This may increase the loads of the database servers.

  • During full data migration, concurrent INSERT operations cause fragmentation in the tables of the destination database. After full data migration is complete, the tablespace of the destination database is larger than that of the source database.

  • You must ensure that the precision settings for columns of the FLOAT or DOUBLE data type meet your business requirements. DTS uses the ROUND(COLUMN,PRECISION) function to retrieve values from columns of the FLOAT or DOUBLE data type. If you do not specify a precision, DTS sets the precision for the FLOAT data type to 38 digits and the precision for the DOUBLE data type to 308 digits.

  • DTS attempts to resume a data migration task that failed within the last seven days. Before you switch workloads to the destination cluster, you must stop or release the failed tasks. You can also execute the REVOKE statement to revoke the write permissions from the accounts that are used by DTS to access the destination database. Otherwise, the data in the source database will overwrite the data in the destination database after the failed task is resumed.

  • 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, new sequences do not increment from the maximum value of the sequences in the source database. Therefore, before you switch your workloads to the destination database, you must update the starting value of sequences in the destination database.

  • If a DTS task fails to run, DTS technical support will try to restore the task within 8 hours. During the restoration, the task may be restarted, and the parameters of the task may be modified.

    Note

    Only the parameters of the task may be modified. The parameters of databases are not modified. The parameters that may be modified include but are not limited to the parameters in the "Modify instance parameters" section of the Modify the parameters of a DTS instance topic.

Special cases

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

  • If the source database is a Cloud SQL for PostgreSQL instance provided by Google Cloud Platform, you must set the Database Account parameter to a database account with the cloudsqlsuperuser permission for the source database. When you select the objects to be migrated, you must select the objects that the specified account is authorized to manage. Otherwise, you must grant the OWNER permission on the selected objects to the specified account.

    Note

    An account with the cloudsqlsuperuser permission cannot manage the data that is owned by other accounts that have the cloudsqlsuperuser permission.

  • If the source database is a self-managed PostgreSQL database, the values of the max_wal_senders and max_replication_slots parameters must be greater than the sum of the following numbers: the number of used replication slots in the self-managed PostgreSQL database and the number of DTS instances that must be created to migrate data from this database.