DBAtlas · Database operations atlas

Change cluster-wide parameters in Patroni (edit-config) and apply pending restarts

PostgreSQLPatroni

Command

# Show the current dynamic configuration stored in the DCS:
patronictl -c /etc/patroni/patroni.yml show-config <cluster>
# Cluster-wide PostgreSQL parameter (distributed to all members):
patronictl -c /etc/patroni/patroni.yml edit-config <cluster> -p 'work_mem=64MB' -p 'max_connections=500' --force
# Patroni behavior parameter:
patronictl -c /etc/patroni/patroni.yml edit-config <cluster> -s 'maximum_lag_on_failover=1048576' --force
# Parameters requiring a restart are flagged as 'Pending restart':
patronictl -c /etc/patroni/patroni.yml list <cluster> -e
# Restart replicas first, then the leader:
patronictl -c /etc/patroni/patroni.yml restart <cluster> --role replica --pending --force
patronictl -c /etc/patroni/patroni.yml restart <cluster> --role leader --pending --force

What it does

Writes PostgreSQL and Patroni parameters to the dynamic configuration in the DCS; Patroni applies the change to all members, activates reloadable ones immediately and flags those that need a restart as 'Pending restart'.

When to use it

To change parameters such as max_connections, shared_buffers or work_mem consistently on every node of a Patroni-managed cluster.

Caution

Under Patroni, do not edit postgresql.conf manually or use ALTER SYSTEM: Patroni rewrites postgresql.conf, and postgresql.auto.conf overrides Patroni's settings, causing drift between nodes. max_connections, max_worker_processes, max_wal_senders, max_prepared_transactions and max_locks_per_transaction on a standby cannot be lower than on the primary; plan the restart order accordingly.

Open in DBAtlas →

Related