Measured: how much acknowledged data Patroni, pg_auto_failover and CloudNativePG lose when promoting a replica that is behind

Started by Noname5 days ago1 messagesgeneral
Jump to latest
#1Noname
sajishrk@gmail.com

Hi all,

I measured something the docs describe but dont really put numbers on,
posting it here in case its useful.

Setup: stall WAL shipping to a replica so it falls behind by 10 or 100
MiB, kill the primary, count acknowledged transactions missing on the
new primary. 300 runs. Patroni 4.1.5, pg_auto_failover 2.2,
CloudNativePG 1.30.2, asynchronous replication, one host per stack.

Patroni refused slowly formed gaps 20/20. But a gap that formed fast
(about a second of burst writes) passed the automatic check 10/10,
because the leader position stored in the DCS was 24 to 287 MiB stale
and the computed lag came out negative. About 1,200 acknowledged
transactions lost at a 10 MiB gap. A named-candidate patronictl
failover promoted at both gap sizes with no lag check.

pg_auto_failover has a real gate at 16 MiB on last reported LSNs. 100
MiB was refused on automatic and on perform promotion, 10 MiB passed.
When perform promotion is refused the command waits out its 60s
timeout and exits 12, the reason is only in the monitor log.
pg_promote() bypasses the gate.

CloudNativePG at defaults has no lag gate on the paths I measured.
Automatic failover promoted a replica missing 100 MiB in 10/10 runs,
11,763 to 11,778 transactions lost. It did pick the less behind
replica when both were behind. The optional maximumLag readiness probe
was not enabled, and neither was quorum failover.

None of this contradicts the docs as far as I can tell, and
synchronous replication is the real protection against this class of
loss. I just wanted measured numbers.

Writeup: https://sajish85.github.io/2026/11/23/what-a-failover-actually-loses.html
Paper and data: https://doi.org/10.5281/zenodo.24466483 ,
https://github.com/Sajish85/what-promotion-admits

Sajish Krishnan