---
title: "Designing a planned switchover for minimum disruption"
description: "Neki performs planned Postgres primary switchovers without stopping the old primary."
url: "https://swe.quest/articles/designing-a-planned-switchover-for-minimum-disruption-c09f9387b5a40465"
canonical: "https://planetscale.com/blog/designing-a-planned-switchover-for-minimum-disruption"
source: "PlanetScale"
published: "2026-10-29"
difficulty: "hard"
kind: "Deep dive"
reading_minutes: 8
tags: ["postgres","replication","resilience","deployment"]
---

# Designing a planned switchover for minimum disruption

A post on [PlanetScale](https://swe.quest/sources/planetscale.md), published 2026-10-29, 8 min read, Deep dive. Original: [https://planetscale.com/blog/designing-a-planned-switchover-for-minimum-disruption](https://planetscale.com/blog/designing-a-planned-switchover-for-minimum-disruption)

## Summary

Neki performs planned Postgres primary switchovers without stopping the old primary. Routers buffer primary-bound queries, the primary is set read-only by default, and every replica except the target is disconnected so its receive\_lsn fixes a final WAL position the target must replay through. Preflight checks cover shard state, failover slots and capacity settings such as max\_connections, and post-convergence checks cover slots and having at least one synchronous standby attached. If any check fails before promotion, a config reload makes the old primary writable again for a fast rollback. With ANY 1 synchronous replication and synchronous\_commit=on, every acknowledged commit is present on the target when it is promoted.

Written by swe.quest, not by the author.

**Difficulty:** Hard: written for specialists in the field

## Topics

- [PostgreSQL](https://swe.quest/tags/postgres.md) (Data & databases)
- [Replication](https://swe.quest/tags/replication.md) (Distributed systems)
- [Resilience](https://swe.quest/tags/resilience.md) (Distributed systems)
- [Deployment](https://swe.quest/tags/deployment.md) (Reliability & operations)

## Prerequisites

- Postgres streaming replication ([easy posts on PostgreSQL](https://swe.quest/tags/postgres.md?difficulty=easy))
- WAL and LSNs
- synchronous replication ([easy posts on Replication](https://swe.quest/tags/replication.md?difficulty=easy))
- high-availability failover

## Keywords

Neki, PlanetScale, Patroni, synchronous\_commit, WAL, Kubernetes

## Related posts

- [Designing a reliable unplanned failover](https://swe.quest/articles/designing-a-reliable-unplanned-failover-ab0dd731f569d08c.md): PlanetScale · 2026-11-05 · Hard · 10 min read · PostgreSQL, Replication, Resilience, Distributed systems, Distributed databases
  Neki, PlanetScale's Postgres sharding system, declares a primary dead only when its control plane (Admin) cannot reach it and at least one reachable replica reports broken replication with none contradicting.
- [Fencing a Postgres primary that might still be alive](https://swe.quest/articles/fencing-a-postgres-primary-that-might-still-be-alive-67043bdd5aea0f6c.md): ClickHouse · 2026-11-04 · Hard · 10 min read · PostgreSQL, Replication, Resilience, Networking, Cloud platforms
  Before promoting a standby, a managed Postgres control plane must fence the old primary, because promotion and DNS changes alone don't stop writes: async standbys, per-session synchronous\_commit overrides, quorum commit with a remaining standby, and canceled commits already in WAL can all let a still-alive primary accept writes.
- [When failover isn’t safe: Building high-availability PostgreSQL on Kubernetes](https://swe.quest/articles/when-failover-isn-t-safe-building-high-availability-postgresql-on-kubernetes-ee0014d4b5265bb2.md): Datadog Engineering · 2026-06-04 · Medium · 22 min read · PostgreSQL, Replication, Kubernetes, Resilience, Chaos engineering
  A staging gameday simulating zonal network latency left Datadog's Kubernetes-hosted PostgreSQL clusters stuck: with asynchronous replication, every standby exceeded Patroni's maximum\_lag\_on\_failover, so no failover candidate could be promoted safely.
- [Blocking cutovers to save replication slots](https://swe.quest/articles/blocking-cutovers-to-save-replication-slots-d52d9d5fcc4a6789.md): PlanetScale · 2026-09-21 · Medium · 5 min read · PostgreSQL, Replication, Event-driven architecture, Deployment
  PlanetScale Postgres blocks planned cutovers (resizes, parameter changes, maintenance) when logical replication slots aren't synchronized to the replica being promoted, because vanilla Postgres will promote a replica without the slot and silently break CDC consumers.
- [Production Postgres on Railway: From First Deploy to High Availability](https://swe.quest/articles/production-postgres-on-railway-from-first-deploy-to-high-availability-70a3bcba84354fc9.md): Railway · 2026-10-15 · Medium · 13 min read · PostgreSQL, Replication, Resilience, Cloud platforms
  Railway Postgres can grow from a single private-networked database to a production setup with volume backups, point-in-time recovery, PgBouncer connection pooling and Patroni-based high availability, demonstrated with an orders API that uses idempotency keys so retries stay safe.

Browse: [Latest posts](https://swe.quest/index.md) · [Topics](https://swe.quest/tags.md) · [Sources](https://swe.quest/sources.md) · [Topic map](https://swe.quest/map.md) · [Site guide (llms.txt)](https://swe.quest/llms.txt)
