Database administration
Migrate or upgrade a source database
Run an AWS blue/green deployment or a major version upgrade on a source database, then confirm that your Artie pipeline replicates changes again.
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.
To replace a non-production database with a copy of production, follow Refresh a PostgreSQL source from a snapshot.
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.
Artie does not capture changes that you write between the slot drop and the resume. This period includes the time that AWS needs to create the deployment. If you cannot stop writes, backfill the tables that changed in this period. Start the backfill after the test row check passes.
Do these steps in this order.
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 Let Artie read all changes of the PostgreSQL in-place upgrade.
Pause the pipeline
Pause the pipeline with the Pause pipeline option, not the default Pause delivery only. Follow Pause the pipeline of the PostgreSQL in-place upgrade, including the pause check. 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. The default slot name is
artie. If you set an override, use that name.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. For Aurora, use the cluster 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 run this query to record the writer IP.
SQLSELECT current_setting('server_version') AS postgres_version, inet_server_addr() AS writer_ip;postgres_versionshows the target engine version.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 with the AWS CLI.
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]'Replace the ARN with the ARN of your target group. The only target must be the writer IP that you recorded at the switchover, with the state
healthy.Resume the pipeline
On the pipeline page, select Resume pipeline and confirm. Artie finds no slot, so it resets its saved position and creates a new slot on green. Do the resume check in Resume the pipeline 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 Make sure that a test row gets to the destination of the PostgreSQL in-place upgrade.
Start application writes again
Start application writes again when the test row is in the destination. Monitor the Lag chart on the Analytics page.
In-place major version upgrade
Pause the pipeline before a major version upgrade, for example PostgreSQL 14 to 15. A major upgrade can replace the WAL history, so Artie does not keep its saved PostgreSQL position across it. Resume the pipeline after the upgrade and the database restart.
Back up the database and test the upgrade on a staging database before you upgrade production.
PostgreSQL in-place upgrade
To upgrade with an AWS blue/green deployment, use the Amazon RDS and Aurora PostgreSQL steps.
AWS can keep 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.
Artie does not capture changes that you write between the slot drop and the resume. Keep writes stopped for this period. If you cannot stop writes, backfill the tables that changed.
Do these steps in this order.
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 Lag chart on the Analytics page 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
On the pipeline page, select Pause pipeline…. In the dialog, select the Pause pipeline option, then select Pause pipeline to confirm.
The Pause pipeline option stops Artie from reading the source. The default option, Pause delivery only, keeps Artie reading the source, so do not use it here.
Pausing does not stop a backfill. To stop one, use Cancel backfill on the pipeline page.
If other pipelines share this pipeline’s source reader, pause them the same way. A shared source reader stops only when no pipeline on it is running or has only delivery paused. For a pipeline that already has delivery paused, open More options on the pipeline page and select Pause reading….
Then do the pause check on the source.
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. When you select the Pause pipeline option for a PostgreSQL pipeline, the dialog shows this query with your slot 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
On the pipeline page, select Resume pipeline and confirm. Artie creates a new slot. Then do the resume check on the source.
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 Lag chart on the Analytics page.
Other databases
Use these steps for a source that is not PostgreSQL.
- Schedule application downtime and pause your application.
- On the Analytics page, check the Lag chart to confirm that Artie has caught up.
- On the pipeline page, select Pause pipeline…, select the Pause pipeline option, then confirm.
- Upgrade the database and restart your database server.
- On the pipeline page, select Resume pipeline and confirm.
- Resume your application.
The Pause pipeline option stops Artie from reading the source. The default option, Pause delivery only, does not.
Database-specific considerations
Check these settings on the new version before you resume the pipeline.
PostgreSQL
- Check that
wal_levelislogical. - Check that every extension your database needs is available in the new version.
MySQL
- Check that
binlog_formatisROW. Artie does not start with another value. - Check that binlog retention is at least 24 hours. See MySQL for the setting on your provider.
- If you use GTID, check that
gtid_modeandenforce_gtid_consistencyareON.
MongoDB
- Check that the server is still in a replica set.
- Check that change streams are enabled. Artie reads MongoDB change streams.
- Check that the service account still has its permissions.
Minor version upgrade
Minor version upgrades, for example PostgreSQL 14.1 to 14.2, do not require you to pause the pipeline. On Amazon RDS, when Auto minor version upgrade is on, RDS applies them in your maintenance window. Monitor the Lag chart on the Analytics page during the upgrade.
Resume behavior
For PostgreSQL, 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 PostgreSQL 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 Artie to start a backfill.
Troubleshooting
Changes are missing after an upgrade
Cause: The source received writes that Artie did not read, for example between a slot drop and the resume.
Fix: Contact Artie support, and we start a backfill. Do these steps:
- Record which tables lost changes.
- Record the approximate time window.
- Keep the pipeline paused until Artie support replies.
WAL grows on PostgreSQL while a pipeline is paused
Cause: The Artie replication slot stays on the source while the pipeline is paused, so WAL piles up on disk.
Fix: For a long pause, drop the slot. First run this query on the source 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 for the Artie slot.
Then drop the replication slot. The default slot name is artie.
SELECT pg_drop_replication_slot('artie');Artie creates a new slot when you resume. It misses the changes made while the pipeline was paused, so backfill every table.
The pipeline does not replicate after you resume
Check these causes.
- Replication slot lost: the Replication slot lost alert means that PostgreSQL invalidated the slot (
wal_statusislost). Follow Replication slot lost to drop the slot, deploy the pipeline again, and backfill. - Connection errors: check the database credentials and the network path from Artie to the database.
- Permission errors: check that the service account kept its permissions after the upgrade.
- Schema changes: check whether the upgrade changed a schema that the pipeline replicates.
Was this page helpful?
- Need help? Message us on Slack or email [email protected].
- Want a walkthrough? Book a demo.
- LLM? Read llms.txt.