postgres-operator icon indicating copy to clipboard operation
postgres-operator copied to clipboard

synchronous_mode not working.

Open sudoroot-null opened this issue 5 years ago • 7 comments

  • Which image of the operator are you using? - registry.opensource.zalan.do/acid/postgres-operator:v1.5.0
  • Where do you run it - cloud or metal? Kubernetes or OpenShift? - AWS K8s
  • Are you running Postgres Operator in production? - no
  • Type of issue?- Bug report

registry.opensource.zalan.do/acid/spilo-12:1.6-p3 I tried spilo-19 image.

Hello, I have a cluster of 3 nodes. I'm trying to use synchronous_mode and synchronous_mode_strict parameters. I added those parameters to CR, and in pod ENV I can see it:

SPILO_CONFIGURATION={"postgresql":{"bin_dir":"/usr/lib/postgresql/12/bin","parameters":{"hot_standby_feedback":"on","max_standby_archive_delay":"300s","max_standby_streaming_delay":"300s"}},"bootstrap":{"initdb":[{"auth-host":"md5"},{"auth-local":"trust"}],"users":{"zalandos":{"password":"","options":["CREATEDB","NOLOGIN"]}},"dcs":{"ttl":34,"synchronous_mode":true,"synchronous_mode_strict":true}}}

But! In patroni config, I can't see those parameters. If I add it manually by patronictl edit-config - all its work!

Part of CR config:

patroni:
    synchronous_mode: true
    synchronous_mode_strict: true
    ttl: 34 # - i change TTL to be see the changes in patroni config, but nothing..
  postgresql:
    parameters:
      hot_standby_feedback: "on"
      max_standby_archive_delay: 300s
      max_standby_streaming_delay: 300s
    version: "12"

Async replication works great.

sudoroot-null avatar Feb 11 '21 12:02 sudoroot-null

Can you try with the latest operator / spilo release?

FxKu avatar Feb 19 '21 08:02 FxKu

I tried with: registry.opensource.zalan.do/acid/postgres-operator:v1.5.0 registry.opensource.zalan.do/acid/postgres-operator:v1.6.0 registry.opensource.zalan.do/acid/postgres-operator:v1.6.1

And spilo: registry.opensource.zalan.do/acid/spilo-12:1.6-p3 registry.opensource.zalan.do/acid/spilo-13:2.0-p4

On each version, I have a problem.

sudoroot-null avatar Feb 19 '21 12:02 sudoroot-null

If you start a new cluster with these settings, does it work then. Read up older issues and it sounds similar to #447 in that it's only reflected on init.

FxKu avatar Feb 20 '21 10:02 FxKu

I tried on a new cluster. It's work! Thank you so much! Then will be a fix of this issue?

sudoroot-null avatar Feb 20 '21 10:02 sudoroot-null

I think this PR - https://github.com/zalando/postgres-operator/pull/513 must fix this? Do you have an understanding, when you will check and merge it?

sudoroot-null avatar Feb 20 '21 11:02 sudoroot-null

Is there an update on this issue, Can someone confirm if this issue still exists @SpecialForce3331 @FxKu I have tested synchronous mode and it seem to be working. Following is the image registry.opensource.zalan.do/acid/spilo-13:2.0-p7

kubectl exec acid-minimal-cluster-1 -n default -- patronictl list

+ Cluster: acid-minimal-cluster (6979610586794590276) --------+----+-----------+
| Member                 | Host      | Role         | State   | TL | Lag in MB |
+------------------------+-----------+--------------+---------+----+-----------+
| acid-minimal-cluster-0 | 10.40.0.8 | Replica      | running | 18 |         0 |
| acid-minimal-cluster-1 | 10.32.0.8 | Leader       | running | 18 |           |
| acid-minimal-cluster-2 | 10.46.0.3 | Sync Standby | running | 18 |         0 |
+------------------------+-----------+--------------+---------+----+-----------+

select pid,application_name,sync_priority,sync_state from pg_stat_replication;

 pid |    application_name    | sync_priority | sync_state 
-----+------------------------+---------------+------------
 388 | acid-minimal-cluster-0 |             0 | async
 357 | acid-minimal-cluster-2 |             1 | sync

Following is my manifest

apiVersion: "acid.zalan.do/v1"
kind: postgresql
metadata:
  name: acid-minimal-cluster
  namespace: default
spec:
  teamId: "acid"
  volume:
    size: 10Gi
    storageClass: postgres-local-storage   #Storage class and PV should already be Created
  additionalVolumes:
   - name: timezone
     mountPath: /etc/timezone
     targetContainers:
       - postgres
     volumeSource:
       hostPath:
         path: /etc/timezone
         readyOnly: true
   - name: localtime
     mountPath: /etc/localtime
     targetContainers:
       - postgres
     volumeSource:
       hostPath:
         path: /etc/localtime
         readyOnly: true
  numberOfInstances: 3   # Postgres Replicas
  users:  #Define User tester
    tester:
    - superuser
    - createdb
    - bypassrls
    - createrole
  databases:
    testdb: tester  # dbname: owner
  postgresql:
    version: "13"
    parameters:
      max_wal_senders: "16"
      max_connections: "100"
      shared_buffers: "100MB"
      tcp_keepalives_interval: "100"
      wal_keep_size: "100MB"
      synchronous_commit:  "on"          #For Synchronous Replication
      synchronous_standby_names:  "'*'"  #For Synchronous Replication
 
  patroni:
    initdb:
      encoding: "UTF8"
      locale: "en_US.UTF-8"
      data-checksums: "true"
    ttl: 30
    loop_wait: &loop_wait 10
    retry_timeout: 10
    synchronous_mode: true            #For Synchronous Replication
    synchronous_mode_strict: true     #For Synchronous Replication
    maximum_lag_on_failover: 339999

venkat-jaligama avatar Jul 01 '21 15:07 venkat-jaligama

With #1535 merged, a change in synchronous_mode should now be reflected in the Postgres config. Closing this issue then. Feel free to reopen, if it still doesn't work for you with the latest image.

FxKu avatar Aug 09 '21 14:08 FxKu