- Newest
- Most votes
- Most comments
Option 1: Retain the Replication Slot
The best approach is to retain the replication slots without dropping them. When you stop the DMS tasks, you can leave the replication slot in place. This ensures that DMS continues tracking the LSN without interruption. You can pause the DMS task, upgrade the PostgreSQL database to version 16.3, and keep the replication slot intact.
Here’s how you can stop and resume DMS tasks without dropping replication slots:
# Stop the DMS replication task aws dms stop-replication-task --replication-task-arn arn:aws:dms:region:account-id:replication-task:task-id # Perform your Blue/Green deployment # Resume the DMS replication task aws dms start-replication-task --replication-task-arn arn:aws:dms:region:account-id:replication-task:task-id --start-replication-task-type resume-processing
By keeping the replication slot and the LSN intact, DMS will continue from where it left off after the upgrade.
Option 2: If You Must Drop the Replication Slot
If you must drop the replication slots due to some constraints, you will have to recreate the replication slots in the Green environment and perform a full load followed by CDC (Change Data Capture).
Steps to follow:
- Stop the DMS jobs and drop the replication slots in the Blue environment.
- Upgrade to PostgreSQL 16.3 and recreate the same replication slots in the Green environment.
- Create a new DMS task with the same replication slots and let it perform a full data load followed by CDC.
- Monitor the DMS jobs to ensure they are syncing correctly with the Redshift target.
Here’s how you can create new replication slots in the Green environment:
-- Create new logical replication slots on the upgraded PostgreSQL 16.3 instance SELECT pg_create_logical_replication_slot('your_slot_name', 'pgoutput');
Then, restart the DMS task to resume processing:
aws dms start-replication-task --replication-task-arn arn:aws:dms:region:account-id:replication-task:task-id --start-replication-task-type full-load-and-cdc
Option 3: Use DMS to Handle Slot and LSN Management
You could also use DMS's built-in CDC resume capability. If you drop and recreate the replication slots, make sure that DMS is able to resume replication from the correct LSN by providing the correct configuration in the DMS task. However, this is only possible if you use the same replication slot name and ensure that DMS can connect to the source PostgreSQL database with the correct permissions.
Example AWS CLI for Dropping and Creating Replication Slots:
# Drop the old replication slot in Blue environment psql -h your-db-endpoint -U your-username -c "SELECT pg_drop_replication_slot('your_slot_name');" # Create a new replication slot in Green environment psql -h your-db-endpoint -U your-username -c "SELECT pg_create_logical_replication_slot('your_slot_name', 'pgoutput');"
answered 2 years ago

If we try to start a Blue Green migration with even inactive replication slots, we will get an error - "Creation of blue/green deployment failed due to external replication on the blue primary instance. See https://docs.aws.amazon.com/AmazonRDS/latest/UserGuide/blue-green-deployments-creating.html#blue-green-deployments-creating-preparing-postgres to help resolve the issues, then delete and recreate the blue/green deployment."