PostgreSQL 14 Migration: How to Keep the Cutover Short Without Losing Writes
A database upgrade can be fast to execute and still take too long for an application that needs to accept writes. PostgreSQL 14 also changed from a planning issue to a support issue: on November 12, 2026, the project released 14.25 as its final PostgreSQL 14 release and ended community security and bug fixes for the branch. (postgresql.org)
The practical response is not to rush a version upgrade. It is to separate the long data copy from the short period when writes must stop. Here is how I would plan a migration from PostgreSQL 14 to a supported major version, with logical replication as one option and an explicit decision about what happens if cutover fails.
First, choose the outage you can actually afford
Define two limits with the people responsible for the product:
- Write interruption: How long can users, background jobs, and integrations be prevented from changing data?
- Recovery point: Can the business accept losing any acknowledged writes? If not, the cutover must prove that committed source writes reached the destination before it opens for writes.
Also decide whether reads may be temporarily stale or unavailable. A read-only maintenance mode is different from full availability, especially if a page view triggers an audit insert or a session update.
Choose the target version based on its support horizon, extension compatibility, hosting support, and application test results. For example, PostgreSQL 18 is a candidate, not an automatic answer. A managed provider may offer support beyond the community deadline; check its specific terms rather than assuming the dates match. Amazon RDS, for example, publishes a separate PostgreSQL 14 standard-support calendar. (docs.aws.amazon.com)
Pick a migration method before designing the runbook
A full dump and restore is straightforward to reason about, but the final copy can exceed a tight write window. pg_upgrade is worth testing when you control the servers and can afford the required shutdown; its actual duration and rollback characteristics depend on the chosen mode and environment. The PostgreSQL documentation describes the available upgrade modes and their constraints. (postgresql.org)
For a tighter interruption budget, native logical replication can copy existing table data and then apply ongoing changes to a new cluster. That shifts much of the work before the outage, but adds operational complexity and does not replicate every kind of database state. (postgresql.org)
I would choose logical replication only after confirming that its coverage and the extra operational work fit the application. If they do not, a longer maintenance window or a provider-specific migration mechanism may be safer.
Inventory what replication will not move
Before creating a subscription, make a written inventory of databases, tables, partitions, extensions, roles, permissions, scheduled jobs, connection pools, and external writers. Compare the PostgreSQL 14 publisher and target-version documentation for the exact combination you will run.
The easy-to-miss items are:
- Schema and DDL: Create compatible target schema separately. Freeze schema changes during migration, or apply and verify them on both sides in a controlled order.
- Sequences: Replicated rows contain their generated IDs, but sequence state does not follow automatically. Reconcile every relevant sequence after source writers stop, including shared or independently used sequences; do not assume
MAX(id)is universally sufficient. - Large objects: PostgreSQL logical replication does not replicate them. Inventory their use and design a separate copy and validation process.
- Updates and deletes: Verify replica identity for every published table that receives them. Check partition mappings and any
TRUNCATEbehavior involving foreign keys. - Everything outside published tables: Roles, grants, extensions, jobs, and other operational configuration need their own setup and checks.
These are not edge cases to leave for the maintenance window. They determine whether the migration design is complete. (postgresql.org)
Build the target and watch the backlog
Create the destination on a supported major version, install compatible extensions, provision roles and permissions, and restore the schema. Keep application writes away from the destination during replication. Configure the PostgreSQL 14 publisher for logical replication and provision enough replication slots, senders, and destination workers, including capacity for initial table synchronization. Some settings may require a restart, so schedule that separately. (postgresql.org)
Create the publication and subscription, allowing the initial table copy to complete. Before cutover, check that every expected table is present in the subscription and has reached the ready state; a subscription looking healthy is not proof that every intended table was included. PostgreSQL exposes table synchronization state in pg_subscription_rel. (postgresql.org)
Monitor apply health, replication backlog, slot retention, disk space, and the application's normal workload throughout the copy. A stalled slot can retain enough write-ahead log to fill source storage. Conversely, imposing a WAL-retention limit may mean a lagging subscriber can no longer catch up; set thresholds and an escalation plan for both risks. (postgresql.org)
Rehearse with representative data and traffic. Measure the initial copy, the time to drain writers, sequence reconciliation, validation, connection switching, and recovery from a failed attempt. Those measurements—not a generic migration estimate—determine whether the planned pause is credible.
Cut over with a write fence and a marker
A low reported lag is useful monitoring, but it is not a sufficient cutover proof by itself. Use a runbook that makes the order of operations explicit:
- Fence and drain source writes. Enter maintenance or read-only mode, stop workers and integrations, block other write paths, and wait for in-flight write transactions to finish. Confirm that no writer can reconnect and commit to the old primary.
- Commit a cutover marker on the source. Use a dedicated table included in the publication. After the fence, write a unique marker through a controlled administrative connection. Confirm all expected tables are ready before relying on it.
- Wait for the marker on the destination. For each independent subscription or database stream, use a marker covered by that stream and wait for it to appear. A marker in one subscription does not prove another has caught up. PostgreSQL preserves transaction order within a single subscription. (postgresql.org)
- Reconcile non-replicated state. Set sequence state using a reviewed procedure appropriate to each sequence, verify separately copied objects, and check roles, grants, extensions, and jobs. Keep destination application writes fenced.
- Validate, then switch. Compare critical counts and business invariants on the now-stable source and destination; run targeted checks for high-value records. Stop or disable the subscription according to the tested runbook, redirect connections, verify the old primary remains fenced, and only then enable destination writes.
A marker proves ordering for changes in its own replication stream; it does not prove that an omitted table, a large object, or an external system is correct. If any gate fails or the pause budget is exhausted, abort before enabling destination writes.
Make rollback honest
Before destination writes begin, rollback can mean keeping the old primary authoritative, restoring its write access, and fixing the migration before another attempt. Record who can authorize that decision and how traffic is switched back.
After destination writes begin, the old primary is stale. Pointing traffic back to it can discard acknowledged writes. A real post-cutover rollback requires a separately designed and tested reverse-replication or reconciliation process, or an explicit decision to restore from backup with an accepted recovery point. Do not describe an unchanged old server as an automatic rollback plan.
Keep the source protected and retain verified backups, but also define when the old cluster, subscriptions, and replication slots will be retired. Leaving a failed slot behind can create its own storage problem.
FAQ
Can PostgreSQL 14 be upgraded with zero downtime?
Native logical replication can shorten the interruption by copying and catching up while the source is live. This runbook still requires a write fence and cutover pause; it does not guarantee zero downtime.
Is PostgreSQL 14.25 a substitute for a major-version migration?
No. It is the final community release of PostgreSQL 14, which no longer receives community security and bug fixes. Provider-specific support may differ. (postgresql.org)
What should I do if replication cannot catch up?
Do not cut over. Investigate the apply worker, errors, workload, and source WAL retention; resolve the bottleneck or reconsider the migration method. If required WAL is no longer available, plan for the affected subscription to be rebuilt according to your tested procedure.
The next useful step is a rehearsal, not a production date: pick the target, inventory non-replicated state, and measure a complete cutover against the application's actual write-interruption budget.