Near-Zero-Downtime Major Version Upgrades
Use logical replication to upgrade across versions while keeping the application online.
Why pg_upgrade Is Not Enough
A major PostgreSQL version jump (e.g. 14 to 17) changes the on-disk catalog format, so the old data directory can't be opened by the new binary directly.
pg_dump/pg_restoreworks but locks you out for the full dump+load window — hours on a large database.pg_upgrade --linkis fast but still requires the application to be fully stopped during the swap, and it operates in place.
Logical replication breaks this trade-off: it streams row-level changes from the old cluster into a freshly initialized new-version cluster while the application keeps writing. Downtime shrinks to a single, planned cutover of a few seconds.
The Core Idea: Two Clusters, One Stream
The upgrade runs as a publisher / subscriber pair across versions:
- Publisher = your current production cluster (old version).
- Subscriber = a new cluster running the target major version, initialized empty.
Logical replication is version-independent: it ships decoded logical changes (INSERT/UPDATE/DELETE), not physical WAL pages, so a v14 publisher can feed a v17 subscriber. Once the subscriber is fully caught up and lag is near zero, you flip the application's connection string to the new cluster.
All lessons in this course
- Publications, Subscriptions, and Replica Identity
- Offloading Read and Analytic Workloads
- Near-Zero-Downtime Major Version Upgrades
- Monitoring Replication Lag and Slot Bloat