Skip to content

Blue Green deployment and AWS DMS

0

Hi there, We have an AWS RDS PostgreSQL server running on PG 13.5. We plan to upgrade to 16.3 using Blue/Green deployment. We have a few AWS DMS jobs which created logical replication slots and are pushing data into Redshift. We have to stop the DMS jobs and drop the replication slots so carry out Blue/Green upgrade. If we complete the upgrade and then create the same replication slots in the Green environment, will the DMS jobs resume without any problem? I feel the jobs may search for specific LSNs, fail to find them and fail.

1 Answer
0

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:

  1. Stop the DMS jobs and drop the replication slots in the Blue environment.
  2. Upgrade to PostgreSQL 16.3 and recreate the same replication slots in the Green environment.
  3. Create a new DMS task with the same replication slots and let it perform a full data load followed by CDC.
  4. 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

You are not logged in. Log in to post an answer.

A good answer clearly answers the question and provides constructive feedback and encourages professional growth in the question asker.