Database administration
Database migrations
Learn how to safely perform database migrations while maintaining data replication with Artie.
Overview
Database migrations are a critical part of maintaining and upgrading your database infrastructure. This guide explains how to safely perform database migrations while ensuring your data replication continues to work correctly with Artie.
Blue/green source database migration
An AWS blue/green deployment copies your database to a new green environment and then switches your application to it.
Amazon RDS and Aurora PostgreSQL
Use these steps when you upgrade an Amazon RDS or Aurora PostgreSQL database with an AWS blue/green deployment. The steps follow the limits that AWS documents:
- AWS does not create a blue/green deployment when non-physical replication slots exist. Creation fails with the error
Replica creation is canceled due to external replication. See the AWS troubleshooting article. - The blue database cannot be a logical replication publisher. See the AWS blue/green deployment considerations.
Do these steps in this order:
- Stop application writes.
- Let Artie read all changes.
- Pause the pipeline.
- Drop the Artie replication slot.
- Create the blue/green deployment.
- Switch over to green.
- Point the network path to the green writer.
- Resume the pipeline.
- Make sure that a test row gets to the destination.
- Start application writes again.
Stop application writes
Stop all application writes to blue. Let open transactions finish. Keep writes stopped until the last step.
Let Artie read all changes
Keep the pipeline running. Do the read check in step 2 of the PostgreSQL in-place upgrade.
Pause the pipeline
Pause the pipeline. Do the pause check in step 3 of the PostgreSQL in-place upgrade. The slot must show
activeasfalse.Drop the Artie replication slot
Drop the slot. Then make sure that no other non-physical slots remain on blue.
SQLSELECT pg_drop_replication_slot('artie'); SELECT slot_name, plugin, active FROM pg_replication_slots WHERE slot_type <> 'physical';The second query must return no rows. If slots remain, other consumers use them. Decide what to do with them before you create the deployment.
Create the blue/green deployment
Create the deployment with the target engine version. Make sure that
rds.logical_replicationis1in the green parameter group.Do not run DDL,
GRANTorREVOKEon blue during the deployment. AWS blocks the switchover after these changes.Switch over to green
Do the switchover. Green takes the original endpoints. Connect to the writer endpoint and record the writer IP for the next step.
SQLSELECT current_setting('server_version') AS postgres_version, inet_server_addr() AS writer_ip;Point the network path to the green writer
Make sure that the network path from Artie gets to the green writer before you resume Artie. If Artie resumes before this, it connects to the old blue database.
For PrivateLink with an NLB IP target, a Lambda function keeps the target IP current. Run the Lambda, or wait for its next run. Then check the target group.
Bashaws elbv2 describe-target-health \ --target-group-arn arn:aws:elasticloadbalancing:us-east-1:123456789012:targetgroup/artie-postgres/0a1b2c3d4e5f6a7b \ --query 'TargetHealthDescriptions[].[Target.Id,TargetHealth.State]'The only target must be the writer IP from the last step, with the state
healthy.Resume the pipeline
Resume the pipeline. Artie finds no slot, so it resets its saved position and creates a new slot on green. Do the resume check in step 6 of the PostgreSQL in-place upgrade.
Make sure that a test row gets to the destination
Insert a test row on green and find it in the destination. Use the test row check in step 7 of the PostgreSQL in-place upgrade.
Start application writes again
Start application writes again when the test row is in the destination. Monitor the pipeline lag in the analytics portal.
In-place major version upgrade
PostgreSQL in-place upgrade
To upgrade with an AWS blue/green deployment, use the Amazon RDS and Aurora PostgreSQL steps.
Do these steps in this order:
- Stop application writes.
- Let Artie read all changes.
- Pause the pipeline.
- Drop the Artie replication slot.
- Upgrade the database.
- Resume the pipeline.
- Make sure that a test row gets to the destination.
- Start application writes again.
AWS keeps logical replication slots during a major version upgrade only when the source is PostgreSQL 17 or later. These steps drop the slot on all versions. When you resume, Artie finds that its slot is missing or that the major version changed. Artie then resets its saved position and starts on a new slot.
Stop application writes
Stop all application writes to the source database. Let open transactions finish. Keep writes stopped until the last step.
Let Artie read all changes
Keep the pipeline running. Wait until the analytics portal shows that Artie has caught up. Then do the read check on the source.
SQLSELECT slot_name, active, pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn) AS behind_bytes FROM pg_replication_slots WHERE slot_name = 'artie';Run the query again after one minute.
behind_bytesmust be small, and it must not increase.Pause the pipeline
In the analytics portal, click Pause pipeline and choose the Pause pipeline option. This option also stops Artie from reading the source. Then do the pause check.
SQLSELECT slot_name, active, active_pid FROM pg_replication_slots WHERE slot_name = 'artie';The slot must show
activeasfalse.Drop the Artie replication slot
The default slot name is
artie. If you set an override, use that name.SQLSELECT pg_drop_replication_slot('artie');Upgrade the database
Upgrade the database to the new major version and restart it. Check the PostgreSQL considerations before you resume.
Resume the pipeline
Resume the pipeline in the analytics portal. Artie creates a new slot. Then do the resume check.
SQLSELECT current_setting('server_version') AS postgres_version, slot_name, active, pg_wal_lsn_diff(pg_current_wal_lsn(), confirmed_flush_lsn) AS behind_bytes FROM pg_replication_slots WHERE slot_name = 'artie';postgres_versionmust show the new version.activemust betrue.behind_bytesmust be zero or more. A negative value means that Artie uses an old position. If you see a negative value, keep writes stopped and contact Artie.Make sure that a test row gets to the destination
The slot checks can pass when no data gets to the destination. Do the test row check to see that data moves from the source to the destination. Insert a row with a unique ID into a small table that the pipeline replicates.
SQL-- Source INSERT INTO public.upgrade_checks (check_id, note) VALUES ('pg-upgrade-2026-11-07', 'post-upgrade check');Then find the row in the destination.
SQL-- Destination SELECT check_id, note FROM analytics.upgrade_checks WHERE check_id = 'pg-upgrade-2026-11-07';The query must return the row with the same values.
Start application writes again
Start application writes again when the test row is in the destination. Monitor the pipeline lag in the analytics portal.
Other databases
- Schedule an application downtime and pause your application.
- In the analytics portal, check that Artie has caught up. Then click Pause pipeline and choose the Pause pipeline option, which also stops Artie from reading the source.
- Perform the database upgrade and restart your database server.
- Resume your Artie pipeline.
- Resume your application.
Database-specific considerations
PostgreSQL
- Ensure
wal_levelis set tologicalin your new version - Verify that all required extensions are available in the new version
- Check that your replication slots are properly configured
MySQL
- Verify
binlog_formatis set toROW - Ensure
binlog_retention_hoursis set appropriately (recommended 24+ hours) - Check that GTID is enabled if you’re using it
MongoDB
- Ensure your replica set is properly configured in the new version
- Verify that change streams are enabled
- Check that your service account has the correct permissions
Minor version upgrade
Minor version upgrades (e.g., PostgreSQL 14.1 to 14.2) do not require stopping database replication. These upgrades are typically handled automatically by your database provider and applied during your maintenance window.
Best practices
- Always test migrations in a staging environment first
- Back up your data before any major version upgrade
- Monitor replication lag during and after the upgrade
- Keep your Artie pipeline paused until the upgrade is complete
- Verify data consistency after the upgrade
Troubleshooting
What happens when Artie is resumed?
For Postgres, Artie finds or creates a replication slot. The default slot name is artie, unless you set an override. If the slot is missing or the Postgres major version changed, Artie resets its saved position. Artie then starts on the new slot and captures changes from that point.
For other sources, Artie resumes from the last position it saved. If the database no longer has that position, contact us so we can backfill.
What should I do if there is data loss?
If you lose data, contact us and we’ll start a backfill. We recommend:
- Document the extent of data loss
- Note the approximate time window affected
- Contact our support team immediately
- Keep your pipeline paused until we can assist
Postgres tips
For Postgres, you can run this query to see all the replication slots on the server:
SELECT
slot_name,
wal_status,
pg_size_pretty(
pg_wal_lsn_diff(
pg_current_wal_lsn(), restart_lsn)) AS retained_wal,
active,
restart_lsn FROM pg_replication_slots;Make sure that active is false. Then drop the replication slot.
SELECT pg_drop_replication_slot('artie');Common issues
- Replication slot overflow: If you see this error, you may need to increase your WAL retention period
- Connection issues: Verify your database credentials and network connectivity
- Permission errors: Ensure your service account has the correct permissions after the upgrade
- Schema changes: Check if any schema changes were made during the upgrade that might affect replication