zalando / patroni

A template for PostgreSQL High Availability with Etcd, Consul, ZooKeeper, or Kubernetes

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Patroni switchover standby cluster to primary cluster data is not replicate.

murad9911 opened this issue · comments

What happened?

I have two datacenter. I have configure patroni each datacenter. Each datacenter have 3 nodes. Second datacenter standby cluster. I stoped patroni and etcd service primary cluster and perform manual switchover standy-leader. Atter that write some row secondary DC and set secondary DC make standy leader. Start primary cluster again. New data is not streaming Primary cluster.
Do I need additional configuration for 2 side replication ?

How can we reproduce it (as minimally and precisely as possible)?

none

What did you expect to happen?

I think that data streaming from standby-cluster to Primary after datacenter online .

Patroni/PostgreSQL/DCS version

  • Patroni version: patroni 3.1.0
  • PostgreSQL version: postgresql-15
  • DCS (and its version): etcd 3.3.11

Patroni configuration file

# Primary cluster
scope: postgres
namespace: /db/
name: node1


log:
  level: WARNING
  format: '%(asctime)s %(levelname)s: %(message)s'
  dateformat: ''
  max_queue_size: 1000
  dir: /var/log/postgresql
  file_num: 4
  file_size: 25000000
  loggers:
    postgres.postmaster: WARNING
    urllib3: DEBUG


restapi:
    listen: 10.10.90.187:8008
    connect_address: 10.10.90.187:8008

etcd:
    host: 10.10.90.187:2379
bootstrap:
  dcs:
    loop_wait: 10
    maximum_lag_on_failover: 0
    postgresql:
      parameters:
        wal_level: replica
        wal_log_hints: true
        work_mem: 2GB
      use_pg_rewind: true
      use_slots: true
    retry_timeout: 40
    slots:
      standbyslot:
        database: postgres
        type: physical
    synchronous_mode: true
    synchronous_mode_strict: false

    initdb:
    - encoding: UTF8
    - data-checksums

    pg_hba:
    - host replication replicator 127.0.0.1/32 md5
    - host replication replicator 10.10.90.187/0 md5
    - host replication replicator 10.10.90.188/0 md5
    - host replication replicator 10.30.90.187/0 md5
    - host replication replicator 10.30.90.188/0 md5
    - host all all 0.0.0.0/0 md5
    users:
        admin:
            password: pass
            options:
                - createrole
                - createdb
postgresql:
    listen: 10.10.90.187:5432
    connect_address: 10.10.90.187:5432
    data_dir: /var/data/patroni
    bin_dir: /usr/pgsql-15/bin/
    pgpass: /tmp/pgpass
    authentication:
        replication:
            username: replicator
            password: pass
        superuser:
            username: postgres
            password: pass
        test:
            username: test
            password: test
    parameters:
        unix_socket_directories: '.'

tags:
    nofailover: false
    noloadbalance: false
    clonefrom: false
    nosync: false

# Standby_cluster
scope: postgres
namespace: /db/
name: node1

log:
    level: WARNING
    format: '%(asctime)s %(levelname)s: %(message)s'
    dateformat: ''
    max_queue_size: 1000
    dir: /var/log/postgresql
    file_num: 4
    file_size: 25000000
    loggers:
      postgres.postmaster: WARNING
      urllib3: DEBUG


restapi:
    listen: 10.30.90.188:8008
    connect_address: 10.30.90.188:8008

etcd:
    host: 10.30.90.188:2379

bootstrap:
    dcs:
        ttl: 60
        loop_wait: 10
        retry_timeout: 10
        maximum_lag_on_failover: 10485760
        postgresql:
            use_pg_rewind: true
            use_slots: true
        standby_cluster:
            create_replica_methods:
            - basebackup
            host: 192.168.6.107
            port: 5000

    initdb:
    - encoding: UTF8
    - data-checksums

    pg_hba:
    - host replication replicator 127.0.0.1/32 md5
    - host replication replicator 10.10.90.187/0 md5
    - host replication replicator 10.10.90.188/0 md5
    - host replication replicator 10.30.90.187/0 md5
    - host all all 0.0.0.0/0 md5
    users:
        admin:
            password: pass
            options:
                - createrole
                - createdb
postgresql:
    listen: 10.30.90.188:5432
    connect_address: 10.30.90.188:5432
    data_dir: /var/data/patroni/
    bin_dir: /usr/pgsql-15/bin/
    pgpass: /tmp/pgpass
    authentication:
        replication:
            username: replicator
            password: pass
        superuser:
            username: postgres
            password: pass
    parameters:
        unix_socket_directories: '.'
tags:
    nofailover: false
    noloadbalance: false
    clonefrom: false
    nosync: false

patronictl show-config

#Primary
loop_wait: 10
maximum_lag_on_failover: 1048576
postgresql:
  slots:
    standbyslot:
      database: postgres
      type: physical
  synchronous_mode: true
  synchronous_mode_strict: false
  use_pg_rewind: true
  use_slots: true
retry_timeout: 20
ttl: 60



#Standby
loop_wait: 10
maximum_lag_on_failover: 1048576
postgresql:
  use_pg_rewind: true
  use_slots: true
retry_timeout: 10
standby_cluster:
  create_replica_methods:
  - basebackup
  host: 192.168.6.107
  port: 5000
ttl: 60

Patroni log files

none

PostgreSQL log files

none

Have you tried to use GitHub issue search?

  • Yes

Anything else we need to know?

No response

@murad9911 Once your primary cluster is back online, you have to first add it as standby cluster Once all the data is replicated to Old primary cluster, you can again promote it back as primary cluster.