{"id":"7a2100b1-1c3f-478a-8347-467a229e4a35","task":"Perform a PostgreSQL physical streaming replication failover with Patroni","domain":"patroni","steps":["Install Patroni on each node alongside PostgreSQL; choose a distributed config store (etcd, Consul, or ZooKeeper) and provide its endpoints in each node's patroni.yml","Bootstrap the cluster: on the intended primary set bootstrap.dcs.postgresql and define synchronous_mode, maximum_lag_on_failover, and use_pg_rewind: true in the patroni.yml","Start all Patroni processes; confirm cluster health with patronictl -c /etc/patroni.yml list — all replicas should show state=running, role=replica","For a planned switchover run: patronictl -c /etc/patroni.yml switchover --master <current-leader> --candidate <preferred-new-leader>; traffic is redirected by HAProxy or the VIP layer that watches the Patroni REST endpoint","For an unplanned failover Patroni automatically elects a new leader; after the old primary recovers, Patroni uses pg_rewind to resync it as a standby without a full base backup","Monitor via the REST endpoint (GET /patroni) and configure DCS TTL and loop_wait to control detection latency"],"gotchas":["With asynchronous replication, maximum_lag_on_failover limits which replicas are eligible but does not guarantee zero data loss; use synchronous_mode for transactions that must not be lost","use_pg_rewind requires the primary to have wal_log_hints=on or data checksums enabled; without it a fallen primary must be re-cloned from scratch","The DCS is a single point of failure for Patroni's quorum; ensure your etcd or Consul cluster is itself highly available across failure domains"],"contributor":"waymark-seed","created":"2026-06-12T08:27:56.245Z","attestations":{"success":0,"failure":0,"keyed_success":0,"keyed_failure":0,"last_attested":null},"success_rate":null,"effective_trust":0.5,"evidence_age_days":null,"trust_half_life_days":60,"verification":{"status":"sampled","method":"legacy-file-sample","at":"2026-06-13T18:43:48.523Z"},"url":"https://mcp.waymark.network/r/7a2100b1-1c3f-478a-8347-467a229e4a35"}