mirror of
https://github.com/outbackdingo/patroni.git
synced 2026-08-25 14:53:37 +00:00
Adds a new configuration variable synchronous_mode. When enabled Patroni will manage synchronous_standby_names to enable synchronous replication whenever there are healthy standbys available. With synchronous mode enabled Patroni will automatically fail over only to a standby that was synchronously replicating at the time of master failure. This effectively means zero lost user visible transactions. To enforce the synchronous failover guarantee Patroni stores current synchronous replication state in the DCS, using strict ordering, first enable synchronous replication, then publish the information. Standby can use this to verify that it was indeed a synchronous standby before master failed and is allowed to fail over. We can't enable multiple standbys as synchronous, allowing PostreSQL to pick one because we can't know which one was actually set to be synchronous on the master when it failed. This means that on standby failure commits will be blocked on the master until next run_cycle iteration. TODO: figure out a way to poke Patroni to run sooner or allow for PostgreSQL to pick one without the possibility of lost transactions. On graceful shutdown standbys will disable themselves by setting a nosync tag for themselves and waiting for the master to notice and pick another standby. This adds a new mechanism for Ha to publish dynamic tags to the DCS. When the synchronous standby goes away or disconnects a new one is picked and Patroni switches master over to the new one. If no synchronous standby exists Patroni disables synchronous replication (synchronous_standby_names=''), but not synchronous_mode. In this case, only the node that was previously master is allowed to acquire the leader lock. Added acceptance tests and documentation. Implementation by @ants with extensive review by @CyberDem0n.
83 lines
2.2 KiB
YAML
83 lines
2.2 KiB
YAML
scope: batman
|
|
#namespace: /service/
|
|
name: postgresql0
|
|
|
|
restapi:
|
|
listen: 127.0.0.1:8008
|
|
connect_address: 127.0.0.1:8008
|
|
# certfile: /etc/ssl/certs/ssl-cert-snakeoil.pem
|
|
# keyfile: /etc/ssl/private/ssl-cert-snakeoil.key
|
|
# authentication:
|
|
# username: username
|
|
# password: password
|
|
|
|
etcd:
|
|
host: 127.0.0.1:2379
|
|
|
|
bootstrap:
|
|
# this section will be written into Etcd:/<namespace>/<scope>/config after initializing new cluster
|
|
# and all other cluster members will use it as a `global configuration`
|
|
dcs:
|
|
ttl: 30
|
|
loop_wait: 10
|
|
retry_timeout: 10
|
|
maximum_lag_on_failover: 1048576
|
|
synchronous_mode: false
|
|
postgresql:
|
|
use_pg_rewind: true
|
|
# use_slots: true
|
|
parameters:
|
|
# wal_level: hot_standby
|
|
# hot_standby: "on"
|
|
# wal_keep_segments: 8
|
|
# max_wal_senders: 5
|
|
# max_replication_slots: 5
|
|
# wal_log_hints: "on"
|
|
# archive_mode: "on"
|
|
# archive_timeout: 1800s
|
|
# archive_command: mkdir -p ../wal_archive && test ! -f ../wal_archive/%f && cp %p ../wal_archive/%f
|
|
# recovery_conf:
|
|
# restore_command: cp ../wal_archive/%f %p
|
|
|
|
# some desired options for 'initdb'
|
|
initdb: # Note: It needs to be a list (some options need values, others are switches)
|
|
- encoding: UTF8
|
|
- data-checksums
|
|
|
|
pg_hba: # Add following lines to pg_hba.conf after running 'initdb'
|
|
- host replication replicator 127.0.0.1/32 md5
|
|
- host all all 0.0.0.0/0 md5
|
|
# - hostssl all all 0.0.0.0/0 md5
|
|
|
|
# Additional script to be launched after initial cluster creation (will be passed the connection URL as parameter)
|
|
# post_init: /usr/local/bin/setup_cluster.sh
|
|
|
|
# Some additional users users which needs to be created after initializing new cluster
|
|
users:
|
|
admin:
|
|
password: admin
|
|
options:
|
|
- createrole
|
|
- createdb
|
|
|
|
postgresql:
|
|
listen: 127.0.0.1:5432
|
|
connect_address: 127.0.0.1:5432
|
|
data_dir: data/postgresql0
|
|
# bin_dir:
|
|
pgpass: /tmp/pgpass0
|
|
authentication:
|
|
replication:
|
|
username: replicator
|
|
password: rep-pass
|
|
superuser:
|
|
username: postgres
|
|
password: zalando
|
|
parameters:
|
|
unix_socket_directories: '.'
|
|
tags:
|
|
nofailover: false
|
|
noloadbalance: false
|
|
clonefrom: false
|
|
nosync: false
|