# High availability roadmap

> The post-MVP design for production HA, and the fault tests that informed it.

---

LLMS index: [llms.txt](/llms.txt)

---

> [!IMPORTANT]
> Production high availability is a **post-MVP roadmap** design (`Planned`). The current MVP release candidate (`v0.1.0-rc2`) runs against a single PostgreSQL 18 primary and does not automate primary failover or fencing; after a primary switchover, operators must restart the pgetcd gateway.

## Target topology {#topology}

The post-MVP production HA design calls for three PostgreSQL 18 data nodes, an independent Distributed Consensus Store (DCS), and at least two stateless `pgetcd` gateways per tenant. The PostgreSQL cluster and its DCS must bootstrap independently—never host a Patroni cluster's own DCS inside the `pgetcd` service backed by that same PostgreSQL cluster.

The target Patroni synchronous replication settings are:

```yaml
synchronous_mode: on
synchronous_mode_strict: true
synchronous_node_count: 1
check_timeline: true
```

To prevent split-brain writes or stale reads during a network partition, an isolated or stalled old primary must be fenced via hardware/kernel `watchdog.mode: required` or validated STONITH before a standby promotes. A VIP, load balancer health check, or SQL `pg_is_in_recovery()` query is not a substitute for primary fencing.

## Admission and route retirement {#admission}

In the target HA lifecycle, each gateway incarnation starts with client admission closed. Opening admission requires verifying:

1. Valid primary authority and an eligible synchronous standby.
2. Matching database identity, extension version (`0.1.0`), schema version (`2`), and SQL ABI (`1`).
3. A successful logged publication barrier commit.
4. Completed Lease background worker reconstruction for the current worker generation.
{.steps}

When primary authority or worker readiness is lost, the gateway must immediately close new request admission, terminate active Watch delivery, and wait for in-flight SQL connections and sender goroutines to drain before retiring the route.

## Component fault-injection findings (Design 0028) {#functional-evidence}

On 2026-10-14, research candidate `1205/v6` ran component-level synchronous replication and physical promotion fault tests on Linux amd64 with PostgreSQL 18.6 (three PostgreSQL instances per test container):

| Fault test | Result | Observed behavior |
| --- | --- | --- |
| Abnormal SyncRep writer | `102 / 102 PASS` (34 cancel, 34 terminate, 34 disconnect) | Local state left visible by a canceled SyncRep wait is withheld by the read barrier; canceling the barrier returns zero bytes; restoring the synchronous standby allows a normal `COMMIT` to publish |
| Protocol observation gating | `PASS` | `Range`, read-only `Txn`, and state-dependent `Compact` errors wait for synchronous barrier certification before leaving the gateway |
| Fresh Lease promotion | `50 / 50 PASS` | After synchronous flush/replay and standby promotion, the new Lease worker reconstructs durable Leases with a new owner generation and a full TTL; synchronous standby covers the new watermark |
| Old-primary crash and restart | `1 / 1 PASS` | Crashed primary recovers local state but withholds uncertified reads until synchronous replication and qualified promotion complete |
{.wide}

These runs validated the C extension and Publisher `COMMIT` invariants across physical replication promotions inside a single container. They do not establish multi-host network partition tolerance, independent DCS/watchdog fencing, or automatic gateway endpoint switching.

## Post-MVP acceptance gates {#gates}

Before claiming production HA support in a future release, the roadmap (Design 0119 / `ha-recovery`) requires:

| Area | Target gate |
| --- | --- |
| Failover promotions | At least 50 planned and fault-driven promotions in a 3-node PostgreSQL + independent DCS + 2-gateway topology, with target RTO `<= 30 s` when an eligible synchronous candidate exists |
| Synchronous replication faults | At least 100 seeded abnormal SyncRep fault scenarios with zero exposed uncertified state |
| Endurance | 72-hour mixed-fault run with zero linearizability violations, premature Lease expirations, or silent Watch stalls |
| Multi-tenant capacity | Measured steady-state runs across 1, 3, and 20 tenants (requiring an extension of the current 8-database Lease worker allowlist) |
{.wide}

## Upgrade boundaries {#upgrade}

Rolling gateway upgrades require a compatible SQL ABI (`etcd._abi()`). An incompatible `pg_etcd` extension upgrade requires a maintenance window: draining gateways, taking a verified backup, running the SQL migration, restarting PostgreSQL sessions that loaded the old shared library, and verifying `/readyz` before reopening client traffic.

---

Backlinks:

- [Architecture](/docs/etcd/architecture/)
- [Security](/docs/etcd/architecture/security/)
- [Transactions and revisions](/docs/etcd/architecture/transactions/)
- [Design](/docs/etcd/design/)
- [Monitoring](/docs/etcd/operations/monitoring/)
- [Status](/docs/etcd/status/)
