简体   繁体   中英

Disable foreign key constrains in AWS DMS Migration not working for Postgres

Hi I want to migrate my data from one Postgres RDS instance to another. However my database contains tables that have foreign key constraints. As per official Migration documentation provided, AWS DMS migrates only required schema and does not migrate foreign key and other secondary indexes. So the approach I followed for now is, migrate the schema manually first and then run DMS Job with Target Mode set to do nothing. However my load fails with foreign key constraint violation error as DMS tries to migrate tables in parallel and is perhaps selecting parent child tables parallelly for load. I tried setting session_replication_role=replica as suggested in official documentation to disable constraints temporarily at session level but that doesn't seems to be getting applied either(Note: Its said in AWS DMS documentation that this property only works in CDC mode, so tried that as well but doesn't seems to get applied and I face the same issue of foreign key constraint violation). Can anyone help how this can be achieved?

I ran into this problem as well. That parameter (session_replication_role) has to be set at the parameter group level, not at the DB session, and then reboot the target database. The steps I follower were:

  1. Duplicate previous parameter group and set the parameter session_replication_role=replica
  2. reboot the target database
  3. start the DMS task again and wait for all tables to be validated
  4. Revert back to the previous parameter group once the DMS task was concluded

I had to duplicate the parameter groups because I was sharing the same PG across several RDS instances.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM