Skip to content

Commit

Permalink
PITR: don't try to stop postgres if "pg_ctl status" returned 4 ( dire…
Browse files Browse the repository at this point in the history
…ctory "/path/to/data" is not a database cluster directory)

Fixed:

TASK [patroni : Stop PostgreSQL] ***********************************************
fatal: [10.129.8.81]: FAILED! => {"changed": true, "cmd": ["/usr/bin/pg_ctlcluster", "14", "mds", "stop", "-m", "fast", "--", "-w", "-t", "600"], "delta": "0:00:00.075440", "end": "2023-02-20 13:02:21.789506", "msg": "non-zero return code", "rc": 2, "start": "2023-02-20 13:02:21.714066", "stderr": "", "stderr_lines": [], "stdout": "Cluster is not running.", "stdout_lines": ["Cluster is not running."]}
changed: [10.129.8.80]
fatal: [10.129.8.77]: FAILED! => {"changed": true, "cmd": ["/usr/bin/pg_ctlcluster", "14", "mds", "stop", "-m", "fast", "--", "-w", "-t", "600"], "delta": "0:00:00.095513", "end": "2023-02-20 13:02:21.830583", "msg": "non-zero return code", "rc": 2, "start": "2023-02-20 13:02:21.735070", "stderr": "", "stderr_lines": [], "stdout": "Cluster is not running.", "stdout_lines": ["Cluster is not running."]}
  • Loading branch information
vitabaks committed Feb 20, 2023
1 parent 9313991 commit 6a9934c
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions roles/patroni/tasks/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -699,12 +699,12 @@
- name: Stop PostgreSQL # "Debian"
command: "/usr/bin/pg_ctlcluster {{ postgresql_version }} {{ postgresql_cluster_name }} stop -m fast -- -w -t 600"
when: ansible_os_family == "Debian" and
(pg_ctl_status_result.rc is defined and pg_ctl_status_result.rc != 3)
(pg_ctl_status_result.rc is defined and (pg_ctl_status_result.rc != 3 and pg_ctl_status_result.rc != 4))

- name: Stop PostgreSQL # "RedHat" or PostgresPro
command: "{{ postgresql_bin_dir }}/pg_ctl stop -D {{ postgresql_data_dir }} -m fast -w -t 600"
when: (ansible_os_family == "RedHat" or postgresql_packages|join(" ") is search("postgrespro")) and
(pg_ctl_status_result.rc is defined and pg_ctl_status_result.rc != 3)
(pg_ctl_status_result.rc is defined and (pg_ctl_status_result.rc != 3 and pg_ctl_status_result.rc != 4))
when: patroni_cluster_bootstrap_method == "pgbackrest"
become: true
become_user: postgres
Expand Down

0 comments on commit 6a9934c

Please sign in to comment.