Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions roles/postgres/replica/final/defaults/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
---

# © Copyright EnterpriseDB UK Limited 2015-2025 - All rights reserved.

## pg_basebackup timeout for cloning replicas
#
# For large databases, pg_basebackup can take multiple hours to complete.
# This timeout value (in seconds) determines how long to wait for the
# pg_basebackup operation to complete.
#
# Default: 14400 seconds (4 hours)
# For very large databases, increase this value as needed (e.g., 28800 for 8 hours)

pg_basebackup_timeout: 14400
21 changes: 18 additions & 3 deletions roles/postgres/replica/final/tasks/clone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,12 +39,27 @@
extra_option: "{{ waldir_option if pg_wal_dir_outside_pgdata else '' }}"
become_user: "{{ postgres_user }}"
become: true
register: this
failed_when:
this.rc != 0 or 'error' in this.stderr
async: "{{ pg_basebackup_timeout }}"
poll: 0
register: pg_basebackup_job
when:
task_selector|selects('postgres', 'replica')

- name: Wait for pg_basebackup to complete
async_status:
jid: "{{ pg_basebackup_job.ansible_job_id }}"
become_user: "{{ postgres_user }}"
become: true
register: pg_basebackup_result
until: pg_basebackup_result.finished
retries: "{{ [(pg_basebackup_timeout / 10) | int, 1] | max }}"
delay: 10
failed_when:
pg_basebackup_result.rc != 0 or 'error' in (pg_basebackup_result.stderr | default(''))
when:
- task_selector|selects('postgres', 'replica')
- pg_basebackup_job is defined

# If we are cloning an instance with postgres_conf_dir separated from
# postgres_data_dir, we copy its configuration files to the replica's
# postgres_conf_dir (which may or may not be the same as PGDATA, and
Expand Down