Skip to content

Commit

Permalink
Use pg_old_bindir
Browse files Browse the repository at this point in the history
  • Loading branch information
vitabaks committed Nov 8, 2024
1 parent 76a429b commit 37a8253
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions automation/roles/upgrade/tasks/pre_checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@

- name: '[Pre-Check] Test PostgreSQL database access using a unix socket'
ansible.builtin.command: >
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc 'select 1'
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc 'select 1'
register: socket_access_result
changed_when: false
failed_when: "socket_access_result.rc != 0 and 'no pg_hba.conf entry' not in socket_access_result.stderr"
Expand All @@ -60,7 +60,7 @@

- name: '[Pre-Check] Check the current version of PostgreSQL'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select setting::integer/10000 from pg_settings where name = 'server_version_num'"
register: pg_current_version
changed_when: false
Expand All @@ -71,7 +71,7 @@
# for compatibility with Postgres 9.x
- name: '[Pre-Check] Check the current version of PostgreSQL'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select substring(setting from '^[0-9]+\.[0-9]+') from pg_settings where name = 'server_version'"
register: pg_current_version_9x
changed_when: false
Expand Down Expand Up @@ -110,7 +110,7 @@
# which will later be cleaned up before executing initdb for a new version of PostgreSQL
- name: '[Pre-Check] Ensure new data directory is different from the current one'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"show data_directory"
changed_when: false
register: pg_current_datadir
Expand Down Expand Up @@ -138,7 +138,7 @@

- name: '[Pre-Check] Make sure that physical replication is active'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select count(*) from pg_stat_replication
where application_name != 'pg_basebackup'"
register: pg_replication_state
Expand All @@ -156,7 +156,7 @@

- name: '[Pre-Check] Make sure there is no high replication lag (more than {{ max_replication_lag_bytes | human_readable }})'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select pg_wal_lsn_diff(pg_current_wal_lsn(),replay_lsn) as pg_lag_bytes
from pg_stat_replication
order by pg_lag_bytes desc limit 1"
Expand All @@ -183,7 +183,7 @@
# for compatibility with Postgres 9.x
- name: '[Pre-Check] Make sure there is no high replication lag (more than {{ max_replication_lag_bytes | human_readable }})'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select pg_xlog_location_diff(pg_current_xlog_location(),replay_location) as pg_lag_bytes
from pg_stat_replication
order by pg_lag_bytes desc limit 1"
Expand All @@ -209,7 +209,7 @@

- name: '[Pre-Check] Make sure there are no long-running transactions (more than {{ max_transaction_sec }} seconds)'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select pid, usename, client_addr, clock_timestamp() - xact_start as xact_age,
state, wait_event_type ||':'|| wait_event as wait_events,
left(regexp_replace(query, E'[ \\t\\n\\r]+', ' ', 'g'),100) as query
Expand Down Expand Up @@ -242,7 +242,7 @@
# for compatibility with Postgres 9.x
- name: '[Pre-Check] Make sure there are no long-running transactions (more than {{ max_transaction_sec }} seconds)'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select pid, usename, client_addr, clock_timestamp() - xact_start as xact_age,
state, left(regexp_replace(query, E'[ \\t\\n\\r]+', ' ', 'g'),100) as query
from pg_stat_activity
Expand Down Expand Up @@ -332,7 +332,7 @@
# Tablespaces
- name: '[Pre-Check] Check if PostgreSQL tablespaces exist'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
{{ pg_old_bindir }}/psql -p {{ postgresql_port }} -U {{ patroni_superuser_username }} -d postgres -tAXc
"select pg_tablespace_location(oid) as tablespace_location
from pg_tablespace
where spcname not in ('pg_default','pg_global')"
Expand Down Expand Up @@ -374,7 +374,7 @@
# Test access via unix socket to be able to perform 'PAUSE' command
- name: '[Pre-Check] Test PgBouncer access via unix socket'
ansible.builtin.command: >-
{{ postgresql_bin_dir }}/psql -h /var/run/pgbouncer{{ '-%d' % (idx + 1) if idx > 0 else '' }}
{{ pg_old_bindir }}/psql -h /var/run/pgbouncer{{ '-%d' % (idx + 1) if idx > 0 else '' }}
-p {{ pgbouncer_listen_port }}
-U {{ patroni_superuser_username }}
-d pgbouncer
Expand Down

0 comments on commit 37a8253

Please sign in to comment.