DEVOURED
Move the elephant, keep the lights on
Logical replication enables major PostgreSQL version upgrades with seconds of downtime, maintaining the old cluster as a safe rollback path.
What: The procedure involves running a target PostgreSQL instance in parallel with the source, streaming changes via logical replication, and cutting over once the data is verified. It is compatible with any PostgreSQL server version 10 or newer.
Why it matters: Logical replication decouples migration from hardware and major version constraints, providing a safer, more flexible alternative to in-place `pg_upgrade` for critical production environments.
Takeaway: When migrating, remember that logical replication does not automatically transfer DDL (schema changes), sequences, or large objects; handle these explicitly before cutover.
Deep dive
- Logical replication decodes the Write-Ahead Log (WAL) into row-level operations.
- It allows migration between different cloud providers or versions, unlike physical replication.
- DDL changes must be manually applied to the target before the source.
- Sequences require manual synchronization at the time of cutover (until PostgreSQL 19 natively supports sequence replication).
- Large objects require a separate
pg_dumpof only the large objects after writes have stopped. - Always verify data integrity via count and hash checks before flipping traffic.
- Clean up replication slots on the source post-migration to prevent WAL accumulation that can fill disks.
Decoder
- Logical Replication: A method of replicating data changes (INSERT, UPDATE, DELETE) based on their replication identity, usually the primary key.
- WAL (Write-Ahead Log): A standard method for ensuring data integrity by logging changes before they are applied to the database files.
- DDL (Data Definition Language): SQL commands like
CREATE,ALTER, orDROPthat modify the database structure.
Original article
Full article content is not available for inline reading.
Explore all 69 articles in today's digest
Fresh dev news, AI-digested daily. Never miss a trend at devoured.fyi