WAL-lag failover protection
A Patroni replica that is far behind the leader is a poor failover target: promoting it loses every transaction it has not replayed. Jarwis protects against this in two places — Patroni's own automatic failover, and manual switchovers started from the console.
The lag limit
Each PostgreSQL Patroni cluster has a maximum failover lag (default 1 MiB, allowed range 64 KiB–1 TiB). Change it from the Switchover dialog (cluster Overview tab, ?tab=overview) or the cluster settings API (pg_max_failover_lag_bytes); Jarwis writes it live to Patroni's maximum_lag_on_failover. A replica whose lag exceeds the limit is not allowed to become leader during automatic failover.
Candidate report
The Switchover dialog lists every member with its replay lag in bytes and a verdict: eligible or the reason it is not — lag exceeds threshold, lag unknown, not running, unreachable or nofailover tag. The report is read live from each member's Patroni.
Switchover guard
- No candidate chosen: Jarwis picks the eligible replica with the least replay lag. If none is eligible it refuses and shows the report.
- A candidate that lags too much is refused before anything starts, with the lag and the limit in the message.
- A stopped, unreachable or
nofailovercandidate is also refused.
Forced promote
When the leader is gone and only lagging replicas remain, an administrator can force a promotion of a named replica. It requires an explicit candidate and an explicit acknowledgement that data will be lost. Jarwis then:
- writes the estimated data loss (WAL position difference in bytes and the time gap) to the task log;
- raises a critical forced promote alert that stays open until you resolve it;
- records the action in the audit log.