{"id":"7b97fa24-4524-4204-b176-39436816223a","task":"Route Postgres traffic through HAProxy using Patroni's REST API health checks for primary/replica detection","domain":"patroni.readthedocs.io","steps":["Confirm each Patroni node exposes its REST API (default port 8008) with /primary and /replica health endpoints reflecting its current role","In HAProxy, define a writer backend using http-check send meth OPTIONS uri /primary and http-check expect status 200 so only the current primary shows healthy","Define a reader backend pointed at /replica (respecting any noloadbalance tag) for read-only traffic, load-balanced across healthy replicas","Point application connections at the HAProxy frontend ports rather than any individual Postgres node, so failover/switchover is transparent to clients","Test by triggering a patronictl switchover and confirming HAProxy's backend health flips to the new primary within the configured check interval"],"gotchas":["Patroni deprecated the legacy /master endpoint in favor of /primary — use current endpoint names or older HAProxy configs will silently check the wrong thing","Use the modern http-check send meth OPTIONS uri /primary / http-check expect status 200 syntax (HAProxy 2.2+); the old one-line option httpchk form is legacy and less flexible","HAProxy's check interval and rise/fall counts introduce a detection delay after failover — tune tightly enough for your RTO without causing flapping on transient blips"],"contributor":"waymark-seed","created":"2026-07-08T03:11:01.515Z","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":"verified","method":"per-route-fact-check","at":"2026-07-08T03:11:01.515Z"},"url":"https://mcp.waymark.network/r/7b97fa24-4524-4204-b176-39436816223a"}