Configure synchronous replication with quorum (ANY) or priority (FIRST)
PostgreSQLReplicationCommand
-- Quorum: commit completes once any 1 standby in the list confirms
ALTER SYSTEM SET synchronous_standby_names = 'ANY 1 (stby_a, stby_b)';
-- Priority based: the first connected standby in the list is sync, the others 'potential'
-- ALTER SYSTEM SET synchronous_standby_names = 'FIRST 1 (stby_a, stby_b)';
SELECT pg_reload_conf();
SELECT application_name, state, sync_state, sync_priority FROM pg_stat_replication ORDER BY application_name;What it does
Defines which standbys must confirm before a commit completes: ANY N is quorum-based (sync_state = quorum), FIRST N makes the first N connected standbys in list order synchronous (sync) and the rest standbys-in-waiting (potential). The confirmation level is set by synchronous_commit (remote_write, on, remote_apply).
When to use it
On systems that require no data loss on failover (RPO = 0); with several standbys, ANY is preferred so that a single standby failure does not stop writes.
Caution
If the required number of synchronous standbys is not connected, commits hang without an error and the application freezes. Names in the list must match the standbys' application_name. In an emergency a single session can bypass it with SET synchronous_commit = local. Under Patroni, manage this with synchronous_mode instead of setting it manually.