A production PostgreSQL cluster running 20,000+ TPS was upgraded from v13 to v16 with only 10-15 seconds of write downtime. The approach combined physical replication to quickly sync a new server, then switched to logical replication using LSN tracking to bridge the version gap. Key steps included using pg_upgrade with --link mode, carefully managing replication slots and LSN advancement, and finally promoting the upgraded replica to master by setting the old master read-only, syncing, then rerouting load balancer traffic. A critical lesson learned: upgrading pgoutput breaks existing subscriptions, so the logical replication subscription must be created after the pg_upgrade completes, not before.
Table of contents
Creating a new replica: Logical replicationPhysical and logical replicationUpgrading to PostgreSQL 16Combining logical replication with version upgradeTransferring the master role to the new replicaSummary33 Impressions